Connecting to a Database

NOTE

After you learn how to connect to your database, the type of server that you are using will not matter—JDBC provides a server-independent approach to database access. That's one of JDBC's major benefits!

Database drivers enable communication between your code and the database server. The hsql database comes with several database drivers that are packaged in the hsqldb.jar file. You will use a Type 4 driver to communicate between your code and the hsql database server. The first thing that you will need to do is load the driver. You can do this by using the forName() method of the java.lang.Class class:

Class.forName("org.hsqldb.jdbcDriver");

org.hsqldb.jdbcDriver is the JDBC driver that is provided in the hsqldb.jar ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.