Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
开发者_JAVA技巧 Improve this questioni 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.
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
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.
Investigate object-relational mapping (ORM) libraries such as Hibernate. They encapsulate the JDBC API in a way that simplifies coding.
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.
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.
精彩评论