Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL Connection in Eclipse 3.2

 
nijava
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am a beginner in Java and Eclipse.

I have installed Eclipse 3.2
I want to access MySQL Database in Java GUI program.

Can anyone give me simple step by step methods for setting up Database Connection.

Are there any nice free Database plugins for eclipse??

Thank you for help.
 
Martin Wingert
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Download the MySQL connector for Java from MySQL website (http://dev.mysql.com/downloads/connector/j/5.1.html) and put it in your classpath. Then create a connection and query away.

There are many tutorials for how to connect to the db but in short you load a driver and then get a connection:

Class.forName(driverName);
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "username";
String password = "password";
Connection connection = DriverManager.getConnection(url, username, password);

Then if you expect a lot of users of your app then you could add a db pool like apache.commons.dbcp or proxool.

Not sure what you mean with db plugins for Eclipse but if you mean a object/relational persistence and query service then look into http://www.hibernate.org/

Hmmmm...why have you installed an old version of Eclipse? Latest version is 3.4 Ganymede.

BR // Martin
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nijava", please check your private messages.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nijava:
Are there any nice free Database plugins for eclipse??


Eclipse has this plugin: Eclipse Data Tools Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic