aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse an MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse an MySQL" Watch "Eclipse an MySQL" New topic
Author

Eclipse an MySQL

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

I am using Eclipse 3.4.2 and MySQL 5.1.26 with the JDBC driver mysql-connector-java-5.1.6.jar. I configured a driver for a MySQL database within Eclipse as follows:

Connection URL: jdbc:mysql://localhost:3306/
Database name: somedb
Driver class: com.mysql.jdbc.Driver
Password: somepassword
User id: someuser

Then in the Data Source Explorer window I configured a datasource using the above driver and:

Database: somedb
URL: jdbc:mysql://localhost:3306/
User name: someuser
Password: somepassword

Testing the connection results in a successful ping. Changing any of the properties to an invalid value results in a ping failure, so I know I am not getting a false positive and that Eclipse really can connect to the database. In addition, I can see the connections in MySQL Administrator.

But, in the Data Source Explorer, when I expand the datasource using "somedb > schemas > somedb > tables", there are no tables showing, yet the database does have tables.

By the way, I have tried the URLs both with (e.g., jdbc:mysql://localhost:3306/somedb) and without (e.g., jdbc:mysql://localhost:3306/) the database name, in both the driver and datasource definitions; a post I found on another site recommended not placing the database name in the driver URL, but that was for Eclipse 3.3 and 5.0.6 MySQL connector.

Does anybody know how to get MySQL properly configured in Eclipse? Actually, I would ignore this (my app works fine), but I have some JPA entity beans and the red underlines are driving me batty.




JBoss In Action
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Interesting. I can get rid of the JPA-related errors by closing the database connection. Works for me. But it would still be nice to know how to set up a MySQL connection properly.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

False alarm. It turns out that when I created the database and user, my grant statement was wrong. I did this:

GRANT ALL PRIVILEGES ON somedb TO 'someuser'@'localhost' IDENTIFIED BY 'somepassword' WITH GRANT OPTION;

when I should have done this:

GRANT ALL PRIVILEGES ON somedb.* TO 'someuser'@'localhost' IDENTIFIED BY 'somepassword' WITH GRANT OPTION;

With this change, I can see the tables in Eclipse.

That's what happens when I decide to type the command in by hand rather than use the SQL text file that I already have set up for doing this kind of thing. Sigh.


M sallu
Ranch Hand

Joined: Dec 13, 2009
Posts: 42
Peter need your help at this topic link
http://www.coderanch.com/t/482279/Ant-Maven-Other-Build-Tools/MVN-build-error-could-not#2165224
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse an MySQL
 
Similar Threads
Database Connection Error with JSTL
Are there alternatives to JSTL and scriptlet database connection?
MySQL JDBC ConnectionPool Configuration in GrassFish v2.1
mysql url connection issues
Number of Open Connections