How do I use JDBC to query a MySQL database?
Author: Deron Eriksson
Description: This Java tutorial describes using JDBC to query a MySQL database.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1 || MySQL 5.0.27


Page: < 1 2

(Continued from page 1)

The execution of the MySqlJdbcTest class is shown below. The ID, First Name, and Last Name for each employee row is displayed in the console.

execution of the MySqlJdbcTest class

As an aside, it's also possible to instantiate a MySQLW driver by passing the class name as a JVMW argument.

-Djdbc.drivers=com.mysql.jdbc.Driver
instantiating a MySQL driver via a VM argument

Of course, if you use this technique, you can remove the Class.forName("com.mysql.jdbc.Driver").newInstance() instantiation from your source code.

Page: < 1 2