Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting with MySql

 
abhijeet srivastava
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I am trying to connect MySql using connector mysql-connector-java-3.0.17-ga-bin.jar. Driver is loaded but it is
not getting connected. Though in Windows it works fine but give problem in linux fedora 6. I am using connection string

jdbc:mysql://localhost:3306/test

with username and password. It shows following error-

SQLException:java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.SocketException: java.net.ConnectException: Connection refused

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:143)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:225)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1805)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Check.main(Check.java:27)


** END NESTED EXCEPTION **


Whats wrong?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijeet,
From the connection refused message, I suspect a firewall setting or bad password. Can you connect at the command line?
 
abhijeet srivastava
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no problem in connnection on command line. I have also disabled firewall. still same problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic