0

I am trying to connect to MySql database but I failed again and again. I checked all my JDBC configuration but all are working in other laptop but when I run my project on my system I am getting an error.

Jdpc.properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.dialect=org.hibernate.dialect.MySQLDialect
jdbc.databaseurl=jdbc:mysql://localhost:3308/test1
jdbc.username=root
jdbc.password=root

I am getting this error.

INFO: SessionListener: contextInitialized()
Jun 24, 2015 1:17:12 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet employee threw exception
java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.<init>(Socket.java:425)
    at java.net.Socket.<init>(Socket.java:241)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2132)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
David Levesque
  • 22,181
  • 8
  • 67
  • 82
  • 1
    can you try all the steps in the accepted answer given here http://stackoverflow.com/questions/6876266/java-net-connectexception-connection-refused – smoggers Jun 23 '15 at 20:08
  • 1
    as @smoggers said, could you confirm that you can connect to your mysql db through a command line or any interface you have: `mysql -u root -proot -h 127.0.0.1 -P 3308 test1` – Hamed Jun 23 '15 at 20:11
  • according to this link i did all that things but still unable to connect @smoggers – Naveen kumawat Jun 23 '15 at 20:15
  • 1
    If it works on your other laptop doesn't mean that it needds to run here. The other laptop may have a db running on localhost and this might not. – Alexander Jun 24 '15 at 00:16
  • yeah my local database is listening on port 3308 @DavidLevesque – Naveen kumawat Jun 24 '15 at 04:35
  • I am getting same error when i run my other project that i was working fine @Alexander – Naveen kumawat Jun 24 '15 at 04:38
  • Check for typos: You mention jdpc.properties (p instead of b). Also replace localhost with 127.0.0.1 - I've seen firewalls blocking one but not the other. (localhost nowadays resolves to ::1, the IPV6 version of the same concept) – Olaf Kock Jun 24 '15 at 08:17

0 Answers0