aspose file tools*
The moose likes JDBC and the fly likes Connecting with MySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting with MySql" Watch "Connecting with MySql" New topic

Connecting with MySql

abhijeet srivastava

Joined: Aug 22, 2006
Posts: 26
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


with username and password. It shows following error-

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

MESSAGE: Connection refused

STACKTRACE: Connection refused
at com.mysql.jdbc.StandardSocketFactory.connect(
at com.mysql.jdbc.MysqlIO.<init>(
at com.mysql.jdbc.Connection.createNewIO(
at com.mysql.jdbc.Connection.<init>(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at Check.main(


Whats wrong?
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 29275

From the connection refused message, I suspect a firewall setting or bad password. Can you connect at the command line?

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
abhijeet srivastava

Joined: Aug 22, 2006
Posts: 26
There is no problem in connnection on command line. I have also disabled firewall. still same problem.
I agree. Here's the link:
subject: Connecting with MySql
Similar Threads
Getting while running client
Error inserting data into database after few successfull insert.
another JDBC driver question
MySQL 4.1 [ Connection refused] Connection refused: connect