It is currently Sun May 26, 2019 9:13 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Connection with MySQL in Java refused
PostPosted: Wed Aug 08, 2007 7:52 am 
Newbie
Newbie

Joined: Wed Aug 08, 2007 7:45 am
Posts: 5
Hello,

I am trying to connect with java to my database on the mysql server of freehostia. I wrote the following code:

------------Java code--------------------
...
try{
Class.forName("com.mysql.jdbc.Driver");
DriverManager.setLoginTimeout(0);
Connection con = DriverManager.getConnection("jdbc:mysql://mysql3.freehostia.com:3306/mydatabasename", "myusername", "mypass");
con.close();
}
catch(SQLException e){
e.printStackTrace();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
...
--------------------------------------------

But when I execute the code, it gives the following error

------------Java stacktraces-------------

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.ConnectException
MESSAGE: Connection timed out: connect

STACKTRACE:

java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2744)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at HoofdApplet.registreer(HoofdApplet.java:19)
at HoofdApplet.init(HoofdApplet.java:12)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


** END NESTED EXCEPTION **



Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2820)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at HoofdApplet.registreer(HoofdApplet.java:19)
at HoofdApplet.init(HoofdApplet.java:12)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at StartApplet.paint(StartApplet.java:46)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at StartApplet.paint(StartApplet.java:46)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
------------------------------------------------

Does anybody know what's wrong? I think the url 'jdbc:mysql://mysql3.freehostia.com:3306/mydatabasename' isn't right, but I don't get what's wrong with it :(

Help please !!! ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 8:03 am 
Newbie
Newbie

Joined: Thu Aug 09, 2007 7:30 am
Posts: 2
I am not sure, but I think as the java applet is run on the user machine and not the freehostia-server the mysql-server refuses the connection. In my experience the source of the query has to be a script or programm running on freehostia's servers. so if you run a php script that is fine, but if you host an applet and the clients runs it freehostia treats that as if somebody from the outside is using the database which to my knowledge they, unfortunately, not allow.

hope that helps


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 7:21 pm 
Support Tech
Support Tech

Joined: Fri Mar 24, 2006 7:21 pm
Posts: 842
The script used for the connection to your database should be located in your account files structure in order to be operational. Remote connections to the database are not allowed due to security reasons.

_________________
Best Regards,
Burton
ModeratorsTeam
Freehostia.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 25, 2007 2:23 pm 
Newbie
Newbie

Joined: Wed Aug 08, 2007 7:45 am
Posts: 5
thanks, i'll try it another way ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011