eclipse - JDBC connectivity issue while connecting to college server -


i have tried connect college server workplace , receive response:

connection failed! check output console  

my code:

public jdbcbasicexample() {         // todo auto-generated constructor stub     }     public static void main(string[] argv) {          system.out.println("-------- mysql jdbc connection testing ------------");          try {             class.forname("com.mysql.jdbc.driver");         } catch (classnotfoundexception e) {             system.out.println("where mysql jdbc driver?");             e.printstacktrace();             return;         }          system.out.println("mysql jdbc driver registered!");         connection connection = null;          try {             connection = drivermanager             .getconnection("jdbc:mysql://collegeservername:portnumber/databasenameinserver",               "username","password");          } catch (sqlexception e) {             system.out.println("connection failed! check output console");             e.printstacktrace();             return;         }          if (connection != null) {             system.out.println("you made it, take control database now!");         } else {             system.out.println("failed make connection!");         }       } 

i getting following 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.readpacket(mysqlio.java:675)     @ com.mysql.jdbc.mysqlio.dohandshake(mysqlio.java:1086)     @ com.mysql.jdbc.connectionimpl.coreconnect(connectionimpl.java:2486)     @ com.mysql.jdbc.connectionimpl.connectonetryonly(connectionimpl.java:2519)     @ com.mysql.jdbc.connectionimpl.createnewio(connectionimpl.java:2304)     @ 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)     @ testingdatabase.jdbcbasicexample.main(jdbcbasicexample.java:29) caused by: java.io.eofexception: can not read response server. expected read 4 bytes, read 0 bytes before connection unexpectedly l`enter code here`ost.     @ com.mysql.jdbc.mysqlio.readfully(mysqlio.java:3119)     @ com.mysql.jdbc.mysqlio.readpacket(mysqlio.java:599)     ... 16 more 

can please me resolve this? new , have tried many other ways replacing collegeservername:portnumber ip address though didnt work. have tried other remote address , port name no success. kindly give me suggestions.

connection fail simple check list:

  1. your networking working properly.
  2. is there firewall in college server blocks or allows connections set of ip address?
  3. the address , port of database server correct?? check make sure external ip available internally.
  4. does mysql service start?? (check system service list , tcp listening list, mysql listen connection??)
  5. can login database via mysql shell workspace?? (open terminal, enter mysql -h your_database_host -u your_username -p login)
  6. does database allow remote access?? (check my.cnf file in databaes server , remove line bind-address=127.0.0.1)

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -