Step 10: Adding the Database


Step 9 introduced you to a Java user interface. You used the SWT classes to create and deploy a simple application. Now it's time to connect that application to a database. Step 10 is all about the data.

Overview

In the steps that led to this point, you've become accustomed to the Eclipse workbench and you've created a simple user interface. The last step in the journey is to attach that user interface to a back-end database.

I'll be using JDBC for this. Unfortunately, due to the limitations of most of the available SQL databases, I'll only be able to use the original JDBC syntax (sometimes called JDBC1). I suggest, however, if you haven't already done so, that you take the time to learn about JDBC2 and JDBC3. JDBC2 in particular, with scrollable and updatable result sets, goes a long way towards making JDBC functional in a business application.

You may have your own SQL database available. For example, you may have access to an Oracle SQL engine or a Microsoft Sequel Server. Or you might be running MySQL on your workstation, or any one of a number of other workstation-based SQL engines. Or you might be using IBM's Java Toolkit to access the database on an IBM iSeries.

If you have your own JDBC-capable database, then you simply need to know the following pieces of information:

  1. The name of the driver class

  2. The name and location of the JAR file containing the driver

  3. The URL used to access the database

  4. The user ID and password

You must have the authority to add and delete tables in the database. If all of these conditions have been met, you can proceed directly to Step 10.2.

Otherwise, Step 10.1 will guide you through installing HSQLDB, the free open -source SQL engine from SourceForge. HSQLDB is 100% Pure Java and is very easy to get started with. It doesn't currently support JDBC2, but it's perfectly adequate for learning purposes.

For more information on other SQL databases, please see 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