views:

37

answers:

5

i need to write a program in java that will connect to a mysql database and execute some sql queries and display the result. suggest me a link with similar implementation / discussion of such concepts for guidance.

A: 

Investigate object-relational mapping (ORM) libraries such as Hibernate. They encapsulate the JDBC API in a way that simplifies coding.

ewg
While I think ORM is great in many instances, it may be overkill for what the user is looking for, especially if they are asking about guidance on connecting to a database. I think jdbc is the place to start, and then if needed move onto other concepts such as ORM.
broschb
+1  A: 

I would look here: http://dev.mysql.com/usingmysql/java/ you will need the connector jar from mysql. And then a basic jdbc tutorial from sun here: http://java.sun.com/docs/books/tutorial/jdbc/index.html


broschb
A: 

First start with the JDBC tutorial to learn the generic JDBC concepts. You can consult the MySQL JDBC documentation for more MySQL-specific details such as how to create a connection string and more JDBC code examples. As next step you can learn the DAO pattern how to manage your JDBC code nicely. If you want to go more further, then you can take a look for JPA.

BalusC
A: 

Probably the easiest would be to use the predefined Desktop Database Template included with NetBeans.

It's based on the Swing Application Framework.

Benefits:

  • drag and drop GUI
  • all the pre-wiring is done. I mean... it would be hard to make more simple.

There's a complete tutorial here. And another one there.

JRL
A: 

NetBeans is not my favourite IDE but I must admit they have really nice tutorials and screencasts, especially for beginners.

So, you could maybe start with Connecting to a MySQL Database. Then, have a look at Creating a Simple Web Application Using a MySQL Database. If you are more into Swing, maybe you'll prefer NetBeans Platform CRUD Application Tutorial.

Without more details on the technologies you want to use and the type of application you want to build, it's actually hard to provide more guidance.

Pascal Thivent