unable to connect mysql database to eclipse

97 views
Skip to first unread message

henry joe

unread,
Mar 6, 2013, 3:12:05 PM3/6/13
to JPassion.com: Java Programming
Hello guys,

Recently, I was working with persistent entity in Jee6 and I tried to add/connect my database to eclipse. Here is what i did:

1.First I started the MySQL server using MAMP and changed my Eclipse perspective to Database Development
2. on the left side, is the database connections in the database source Explorer
3.Right clicked on the database Connection and chose new.
4. The new connection profile panel shows up and there, I chose MySQL and entered the name "MySQL JDatabase local host" and clicked next

5. The "Specify a Driver and connection Details" panel shows up and in there, I clicked on the "new driver" icon next to the Drivers dropbox
6.In the "Available Driver template", I chose the version 5.1 then chose the "JAR list" tabbed pane and added the jar/zip mysql jdbc driver I downloaded from mysql. 

7. In the properties table, here are my own inputs:
Database: help_desk
URL: jdbc:mysql://localhost:3306/help_desk
username: root
password : ""

and finally I clicked the "Test connection" BUT I got a "PINGING FAILED!" message pane. 

I have tried all day to rectify this but to no avail. Has anyone been able to connect MySQL to their Eclipse?

I am using the Eclipse Juno on Mac. 

Here is the error log:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:355)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2461)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:214)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:73)
at org.eclipse.datatools.enablement.internal.mysql.connection.JDBCMySQLConnectionFactory.createConnection(JDBCMySQLConnectionFactory.java:28)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:218)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)
... 22 more



Thanks. 

Snap10

unread,
Jan 14, 2015, 9:16:54 AM1/14/15
to jpassi...@googlegroups.com
Anyone solived this yet? Same Problem for me with MAMP ( not MAMP Pro)

Miguel Vieyra

unread,
Jan 27, 2015, 7:09:45 AM1/27/15
to kan...@gmail.com, JPassion.com: Java Programming
Hello Henry:

The Exception might be produced because of the firewall. Please check if the port 3306 is open.

Bye.

--
You received this message because you are subscribed to the Google Groups "JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpassion_jav...@googlegroups.com.
Visit this group at http://groups.google.com/group/jpassion_java?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages