Java remote mysql database error? -
hi i'm trying develop application remote database on site. try close firewall , ping mysite's ip address , receive packets normally. , still receive problem:
com.mysql.jdbc.exceptions.jdbc4.communicationsexception: communications link failure last packet sent server 0 milliseconds ago. driver has not received packets server. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) @ java.lang.reflect.constructor.newinstance(unknown source) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.sqlerror.createcommunicationsexception(sqlerror.java:1116) @ com.mysql.jdbc.mysqlio.<init>(mysqlio.java:344) @ com.mysql.jdbc.connectionimpl.coreconnect(connectionimpl.java:2332) @ com.mysql.jdbc.connectionimpl.connectonetryonly(connectionimpl.java:2369) @ com.mysql.jdbc.connectionimpl.createnewio(connectionimpl.java:2153) @ com.mysql.jdbc.connectionimpl.<init>(connectionimpl.java:792) @ com.mysql.jdbc.jdbc4connection.<init>(jdbc4connection.java:47) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) @ java.lang.reflect.constructor.newinstance(unknown source) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.connectionimpl.getinstance(connectionimpl.java:381) @ com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver.java:305) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ connectdb.<init>(connectdb.java:15) @ connectdb.main(connectdb.java:35) caused by: java.net.connectexception: connection timed out: connect @ java.net.dualstackplainsocketimpl.connect0(native method) @ java.net.dualstackplainsocketimpl.socketconnect(unknown source) @ java.net.abstractplainsocketimpl.doconnect(unknown source) @ java.net.abstractplainsocketimpl.connecttoaddress(unknown source) @ java.net.abstractplainsocketimpl.connect(unknown source) @ java.net.plainsocketimpl.connect(unknown source) @ java.net.sockssocketimpl.connect(unknown source) @ java.net.socket.connect(unknown source) @ java.net.socket.connect(unknown source) @ java.net.socket.<init>(unknown source) @ java.net.socket.<init>(unknown source) @ com.mysql.jdbc.standardsocketfactory.connect(standardsocketfactory.java:257) @ com.mysql.jdbc.mysqlio.<init>(mysqlio.java:294) ... 16 more
and here code:
try { class.forname("com.mysql.jdbc.driver"); con=drivermanager.getconnection("jdbc:mysql://ipaddress:3306/javadb","user","pass"); stmnt=con.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); rst=stmnt.executequery("select * employee"); while(rst.next()) { system.out.println(rst.getint(1)+"\t"+rst.getstring(2)+"\t"+rst.getstring(3)); } } catch(classnotfoundexception e) { e.printstacktrace(); } catch(sqlexception e) { e.printstacktrace(); }
please me problem. appreciate it. note: ipaddress,database, user, password example.
Comments
Post a Comment