java - unable to connect to remote database located on server -
i trying update database table hosted on server through mysql jdbc connector using eclipse.
class.forname("com.mysql.jdbc.driver"); string url = "jdbc:mysql://49.**.***.115:3306/databasename"; string name = "user"; string password = "passs";
but not able connect database local machine. checked information provided above correct.
can please tell me next?
here error:
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:1121) @ com.mysql.jdbc.mysqlio.<init>(mysqlio.java:357) @ com.mysql.jdbc.connectionimpl.coreconnect(connectionimpl.java:2479) @ com.mysql.jdbc.connectionimpl.connectonetryonly(connectionimpl.java:2516) @ com.mysql.jdbc.connectionimpl.createnewio(connectionimpl.java:2301) @ com.mysql.jdbc.connectionimpl.<init>(connectionimpl.java:834) @ 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:416) @ com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver.java:346) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ connecttodb.getconnection(connecttodb.java:27) @ updatedb.main(updatedb.java:17) caused by: java.net.connectexception: connection refused: 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:259) @ com.mysql.jdbc.mysqlio.<init>(mysqlio.java:307) ... 16 more
have verified can connect database server machine running code on? looks there network problem. idea first step diagnosing mysql connection problems try connecting command line rule out networking or credentials problems
mysql -uuser -p -h49.**.***.115 databasename
where "user" username "databasename" database , "49.**.***.115" ip of database server.
Comments
Post a Comment