File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse + MySQL = cannot connect" Watch "Eclipse + MySQL = cannot connect" New topic

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(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.secureAuth411(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.Connection.createNewIO(
at com.mysql.jdbc.Connection.<init>(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(
at org.eclipse.datatools.enablement.internal.mysql.connection.JDBCMySQLConnectionFactory.createConnection(
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(

Thanks ;-)
Paul Clapham

Joined: Oct 14, 2005
Posts: 19896

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: 1864

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.

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


Steve Luke

Joined: Jan 28, 2003
Posts: 4181

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.

azyan yusof

Joined: Mar 12, 2014
Posts: 1
work like charm
I agree. Here's the link:
subject: Eclipse + MySQL = cannot connect
It's not a secret anymore!