File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Connecting with MySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
author & internet detective

Joined: May 26, 2003
Posts: 33102

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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
It's not a secret anymore!