java - DatabaseException CommunicationsException: Communications link failure -



java - DatabaseException CommunicationsException: Communications link failure -

i utilize ubuntu & net-beans. create java desktop database application netbeans wizard. utilize mysql database can open & run query services → databases. when run got exception below. when clean & build project run jar file, same exception. have installed windows in same machine dual boot way, , have same mysql database & java. when run jar file create using ubuntu netbeans, run in windows , show database data. did other way also, create same java application in windows netbeans using same database , run both withing netbeans , jar file. when seek run in ubuntu, both in netbeans & jar file show below exception.

[toplink info]: 2012.01.29 11:16:58.898--serversession(285416048)--toplink, version: oracle toplink essentials - 2.0.1 (build b09d-fcs (12/06/2007)) jan 29, 2012 11:16:59 org.jdesktop.application.application$1 run severe: application class customerrecordsu.customerrecordsuapp failed launch local exception stack: exception [toplink-4002] (oracle toplink essentials - 2.0.1 (build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.

the lastly packet sent server 0 milliseconds ago. driver has not received packets server. error code: 0 @ oracle.toplink.essentials.exceptions.databaseexception.sqlexception(databaseexception.java:305)

... lot of more

caused by: java.net.socketexception: can't connect socks proxy:connection refused @ java.net.sockssocketimpl.connect(sockssocketimpl.java:427)

... lot of more

below part of 'my.cnf' file removing comments.

[client] port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] user = mysql socket = /var/run/mysqld/mysqld.sock port = 3306 skip-external-locking bind-address = 127.0.0.1

below part of persistance.xml file

<property name="toplink.jdbc.driver" value="com.mysql.jdbc.driver"/> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/mybusinessrecords"/> <property name="toplink.jdbc.user" value="root"/> <property name="toplink.jdbc.password" value="password"/>

netbeans wizard utilize jpa, & top link. create programme without wizard pure java, worked in ubuntu expected , show database data. programme below. both above , below utilize same java mysql connector.jar.

public static void main(string[] args) { connection con = null; statement st = null; resultset rs = null; int id = 0; string name = null; seek { string url = "jdbc:mysql://localhost:3306/mybusinessrecords"; class.forname("com.mysql.jdbc.driver").newinstance(); con = drivermanager.getconnection(url, "root", "5843"); if (con != null) { system.out.println("a database connection has been establised!"); st = con.createstatement(); rs = st.executequery("select * countries"); while(rs.next()){ id = rs.getint(1); name = rs.getstring(2); system.out.println("id = " + id + " name = " + name); } } } grab (exception e) { system.out.println("problem" + e.tostring()); } { if (con != null) { seek { rs.close(); st.close(); con.close(); } grab (exception e) { system.out.println(e.tostring()); } con = null; } } }

this system

java version "1.7.0_01" java hotspot(tm) 64-bit server vm (build 21.1-b02, mixed mode) ubuntu 11.10. os type 64 bit mysql version- mysql 5.1.58-1ubuntu1 mysql client version 5.1.58 socket: /var/run/mysqld/mysqld.sock

i read q & more 15 in site same question, 1 helped me. please help me.

string url = "jdbc:mysql://localhost:3306/mybusinessrecords";

caused by: java.net.socketexception: can't connect socks proxy: non-existant socks proxy bind-address = 127.0.0.1 can seek bind-address = 0.0.0.0 or jdbc:mysql://127.0.0.1:3306/mybusinessrecords"

java mysql netbeans ubuntu jdbc

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -