Step 10.5: Modifying the JDBC constants (EXPERT ONLY)


Step 10.5: Modifying the JDBC constants (EXPERT ONLY!)

click to expand
Note  

If you intend to use the HSQLDB database that was included on the CD-ROM (or if you downloaded HSQLDB yourself), then the constants are all set correctly, and you can continue directly to Step 10.6.

If you have your own SQL database and are a skilled JDBC programmer, you can modify this program to use your database. Do not attempt this unless you have already written JDBC programs.

The following code initializes the four JDBC constants:

 private static final String SQLCLASS = "org. hsqldb.jdbcDriver"; private static final String SQLURL   = "jdbc:hsqldb:hsqldb"; private static final String SQLUSER  = "sa"; private static final String SQLPWD   = ""; 

The SQLCLASS field defines the name of the driver. This really identifies the database provider, such as Oracle or PostGreSQL. In this case, org.hsqldb.jdbcDriver is the name of the HSQLDB driver.

The SQLURL field identifies the specific database you are connecting to (such as test or production). The format of this field depends on the database provider. For HSQLDB, the syntax shown says to use a database named "hsqldb" located in the current working directory.

Finally, the SQLUSER and SQLPWD fields identify the user ID and password that will be used to access the database. For this example, user "sa" is a special user (system administrator), that tells HSQLDB to create the database from scratch if it doesn't exist.

If you change these values, be sure you know what to change them to. A change here will also change which JAR file must be added in Step 10.6. I have included some example configurations for other databases in Sidestep 5.




Eclipse
Eclipse: Step by Step (Step-by-Step series)
ISBN: 1583470441
EAN: 2147483647
Year: 2003
Pages: 90
Authors: Joe Pluta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net