I want to connect to the database mysql .
I am using Type IV driver Connector/J.
How to connect to the database.

When i load the driver class its working after that i get this error

SQL Exception :Communications link failure due to underlying exception:


MESSAGE: Connection refused: connect


java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:207)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:268)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2745)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at myjdbc1.main(myjdbc1.java:20)


Last packet sent to the server was 15 ms ago. 08S01 0

Is the database running? Is it running on port 3306? Is there a firewall active blocking the port? Are you attempting to connect to the right host? Are you attempting to connect to 3306? Are you using the correct tablename in the connection url? Is the username and password correct? Is MySQL configured to allow that user, with that password, to connect from where the user is attempting to connect from?

I think that pretty much covers the possibilites.

Very good. It has been awhile since a new poster here has been willing to work through his own problem. Good Job.

This question has already been answered. Start a new discussion instead.