[ Team LiB ] |
PointBase Database ServerBefore proceeding with the discussion on the features of JDBC, let's take a minute and talk about a pure-Java database server that we'll use in our examples. PointBase is a pure-Java implementation of a relational database management system (RDBMS). You must have a JVM installed on your machine to use PointBase server, which you will if you have WebLogic Server installed. PointBase documentation says the server works on all platforms with a Java Virtual Machine. It has been tested on a variety of platforms including Microsoft Windows NT, Macintosh, Solaris, and Linux. It comes equipped with a graphical database management console to enable you to create and work with database schemas. PointBase comes in three different flavors:
WebLogic Server 8.1 ships with an evaluation version of PointBase Server Edition. At the time this book is being written, the version shipping with WebLogic 8.1 is PointBase Server Edition 4.4. You can download an evaluation copy of a later version of PointBase (if available) from http://www.pointbase.com, although doing so isn't required for the purpose of this chapter. In this section, we discuss how to work with the PointBase server version 4.4 that ships with WebLogic 8.1. Looking for PointBase Components in Your WebLogic InstallationThe PointBase server components can be found under the subdirectory common/eval/pointbase (${POINTBASE_HOME}) under the WebLogic installation directory (${WL_HOME}) on your machine. The docs subdirectory contains useful documentation for using the server and the console. The lib sub-directory contains the JAR files needed to use the database Server. The tools subdirectory contains scripts that you can use to start the default PointBase database instance and the console to connect to it. Three JARs make up the PointBase database server. They are as follows:
NOTE The names of the actual JAR files might include the version number (and perhaps also the build number); for example, the server JAR file might be named pbserver44.jar. In the following sections, we refer to the JAR files with their basic names (for example, pbserver.jar); you must substitute them with the actual filename if required. Also, any reference to these JAR files implies that the JAR files are present in the ${POINTBASE_HOME}/lib subdirectory, unless otherwise specified. Starting the PointBase ServerTo start the PointBase server, set your CLASSPATH to include the JAR files $JAVA_HOME/lib/tools.jar and the full path to the pbserver.jar. Now execute the class file com.pointbase.net.netServer. Some of the command-line parameters used by this class are
The class takes other command-line parameters, which can be found in the PointBase documentation. NOTE If you want to use the default database instance shipped with your WebLogic installation, you can simply use the scripts provided under the ${POINTBASE_HOME}/tools subdirectory. Starting the PointBase ConsoleTo start the PointBase console, include the JAR files pbclient.jar and pbtools.jar in your CLASSPATH. Execute the class com.pointbase.tools.toolsConsole to bring up the PointBase console. The console uses Sun Microsystems' Swing library for its GUI. After it starts, you must provide four parameters in order to connect to the database:
After you provide these values and click the OK button, the console will connect with the database server. NOTE You can use the scripts provided under the ${POINTBASE_HOME}/tools subdirectory for starting the console. Working with the PointBase ConsoleThe PointBase Console has a self-descriptive GUI and you can access several of its features from its menu. Clicking on the menu item Catalog, Catalog opens the catalog as a tree view and enables you to browse through the different schemas available in the current database. You can create a new schema by selecting the DBA, Create, Schema option. Right-clicking on a schema name in the tree view gives you the option of creating new tables. You may also create a new table by selecting the DBA, Create, Table menu option, which starts a wizard for creating new tables. You may enter one or more SQL command in the Enter SQL Commands window on the main screen. The SQL commands can then be executed by selecting the SQL, Execute All menu item. The SQL menu also provides for mechanisms by which you can commit or rollback updates to the database. Right-clicking a table in the Catalog tree view also provides you with easy access to some simple predefined SQL statements. You can perform several other tasks using the PointBase console, but it's beyond the scope of this chapter to discuss how to work with the console to perform those tasks. NOTE You can refer to the PointBase console documentation that ships with your WebLogic installation for working with the console. You can find the PDF files in the docs subdirectory of your ${POINTBASE_HOME}. The PointBase Database DriverThe PointBase driver is used to access PointBase databases using JDBC. The name of the PointBase driver that ships with the installation is com.pointbase.jdbc.jdbcUniversalDriver. (Sound familiar? The console uses JDBC behind the scenes to access the PointBase database.) The driver uses the parameters passed in while connecting to the server (such as URL, username, password, and so on) to connect to the PointBase database. This driver is a Type 4, or a native protocol all-Java driver, which directly accesses the PointBase database for servicing calls. Case Study: XYZ ConfectionariesNow that we are familiar with the usage of the PointBase database server, let's create a schema for use in our examples. Let's take a simple case study and work with it as we discuss the features of JDBC. We are building a schema for a billing system for a confectionary store, XYZ Confectionaries. The system must keep track of items and each item's unit price, as well as information about each sale. When we model our case study, we'll have the following tables in our schema:
Create a schema called XYZCONF in the PointBase database. Then create the tables as described in this section under this schema. You can create the schema either by using the PointBase console Table Creation Wizard, or by executing the schema.sql that can be found along with the examples for this chapter. An easy way to execute the schema.sql file is to open the PointBase console and select File, Open. This enables you to pick the SQL file from your hard disk. Select the schema.sql file and open it. This will list the contents of this SQL file in the Enter SQL Commands window. You can then execute the commands by clicking the Execute All button. NOTE The schema contains DROP TABLE commands that attempt to drop the tables before creating them. This is useful if you want to re-create your schema in future for any reason. The first time you create the schema, these statements may generate errors because the tables do not exist yet. This should not cause any problem. |
[ Team LiB ] |