aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse + MySQL = cannot connect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse + MySQL = cannot connect" Watch "Eclipse + MySQL = cannot connect" New topic
Author

Eclipse + MySQL = cannot connect

Lenny Peter
Ranch Hand

Joined: Apr 22, 2008
Posts: 52
I cannot connect mySQL to eclipse :-( why?

1) mysql-connector-java-5.0.8-bin---> C:\Program Files\Java\jdk1.6.0_16\jre\lib\ext

2) MySQL Server 5.0

3) Windows XP

4) Username: root?

5) Data Source Explorer, Database Connection, new MySQL ....

6) TestConnection: Ping failed.
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database 'database'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:206)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:104)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:53)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:72)
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:355)
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:55)



Thanks ;-)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I don't see any code, but guessing from that stack trace, your JDBC URL string said you wanted to connect to a database named "database". The MySQL server responds that there isn't any such database. Given that response, you might want to change your URL string to reference a database which does exist.
Lenny Peter
Ranch Hand

Joined: Apr 22, 2008
Posts: 52
I have not a database ;-)..I thought that I could connect eclipse to mySql without to have a database..just import DB driver..

I have tried to make connection to DB i NetBeans - Oracle, but not in Eclipse (+MySQL)
Where can I find a "connect Eclipse to mySql tutorial" or a just a example what I can do? Step by step...
I have searched in google, but I have not found some good example...

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1850
Hi

I tried the same thing in my eclipse.

The driver is different in my case mysql-connector-java-5.0.4-bin.jar, but that should not be the problem

Try accessing the mysql server via the command prompt. and then execute the command

show databases;

This should help you understand the databases that exist in your system.

In eclipse on the page

Select a driver from the drop-down and provide login details for the connection.
database : use one from the command result 'show databases;'
URL : jdbc:mysql://localhost:3306/

rest should workfine.

I had a problem that after i put in the database the URL also had database specified. Needed to remove that.

BR
Rahul P.Mahindrakar






[Thumbnail for remove.JPG]

Lenny Peter
Ranch Hand

Joined: Apr 22, 2008
Posts: 52
I have removed (database)
from URL : jdbc:mysql://localhost:3306/database
to URL : jdbc:mysql://localhost:3306/ and it works well

Thanks Rahul
Lenny Peter
Ranch Hand

Joined: Apr 22, 2008
Posts: 52

One more question ;-)

I have logedd into MySQLAdministrator as root + my password. After that I create a new user...exit...login to MySQLQueryBrowser as new user + password
and I try to create a new schema = Error while executing query + MySql Error NUmber 1044

??

Thanks
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

There is a pretty good MySQL Tutorial on the MySQL web site. They also have a list of the Errors you will get and what they mean. Perhaps using those resources properly will help you through this.


Steve
azyan yusof
Greenhorn

Joined: Mar 12, 2014
Posts: 1
work like charm
 
jQuery in Action, 2nd edition
 
subject: Eclipse + MySQL = cannot connect