C H A P T E R  8

Using Databases With the IDE

This chapter describes how to configure Javatrademark DataBase Connectivity (JDBCtrademark) software. Most of the information pertains to the PointBase Server 4.2 Restricted Edition (PointBase), which is used with many of the Sun ONE Studio examples and tutorials. General information about using other databases with the IDE is also covered.

PointBase is the default database provided as part of the standard Sun ONE Studio installation. PointBase can be found in the Sun ONE Application Server 7 installation subdirectory, for example, s1studio-install-directory\appserver7\pointbase.

This chapter covers:


Setting Up PointBase Connectivity

An enterprise application uses the JDBC API to interact with a database. Enterprise applications require pooling of database connections so that the business objects in the system can share database access. A JDBC data source lets you make connections to a database. A persistent manager is a component responsible for the persistence of the entity beans installed in the container. The connection pool, JDBC data source and JDBC persistent manager are referred to as connectivity resources.

Before you can deploy and execute an enterprise application that uses a database with Sun ONE Application Server 7, you need to enable the database's JDBC driver in the application server environment and create the three connectivity resources.

When the IDE and Sun ONE Application Server 7 are installed together the following are done for you:

Microsoft Windows users of the IDE who do not have administrator privileges, Solaris OS users, and Linux OS users who plan to use the Sun ONE Studio examples and tutorials should follow the procedure, To Set PointBase JDBC Resources for the Examples and Tutorials to configure the PointBase resources.

To use the IDE examples and tutorials in cases where you have installed Sun ONE Application Server 7 independently of your IDE installation, see To Use an External PointBase Installation With the IDE.


procedure icon  To Confirm the PointBase Resource Configuration

1. In the Runtime tab of the IDE Explorer, expand the Server Registry node and expand the Installed Servers node.

2. Expand the default admin server node (localhost:4848) and the default application server node (server1(localhost:xxxx)).

The variable xxxx = the port number assigned to your application server instance.

3. Expand the registered resources for JDBC Connection Pools, JDBC Data Sources, and Persistent Mangers.

If the IDE installer was able to configure your PointBase connectivity resources for the Sun ONE Application Server, you see the following nodes:

Segment of Runtime tab of the Explorer window showing the three registered JDBC nodes. 

procedure icon  To Set PointBase JDBC Resources for the Examples and Tutorials

Users in Solaris and Linux environments, who typically run the IDE without superuser privileges, need to set the PointBase JDBC resources in the application server environment. This procedure creates the JDBC connection resources for running many of the Sun ONE Studio examples and tutorials.



Note - Before starting this procedure, make sure both the admin server and the application server are running (see Using the Sun ONE Application Server 7).



1. In the Runtime tab of the IDE Explorer, expand the Server Registry node and expand the Installed Servers node.

2. Locate your application server instance.

It is labeled app-server-name (app-server-host:app-server-port), for example, MyServer (localhost:4850).

3. Right-click the application server instance node and choose Preconfigure PointBase JDBC Resources from the contextual menu.

A timer icon (such as an hour glass) appears. When the process is complete, the cursor reverts to its usual icon.

4. Expand the registered resources for JDBC Connection Pools, JDBC Data Sources, and Persistent Managers.

You should see the following nodes:

Segment of Runtime tab of the Explorer window showing the three registered nodes. 

procedure icon  To Use an External PointBase Installation With the IDE

If you have a PointBase installation external to the IDE, perform the following actions to connect the IDE to that external PointBase installation. If you do not have access to a PointBase installation, you must install PointBase before using Sun ONE Studio examples and tutorials. See the Sun ONE Application Server 7 Getting Started Guide for instructions on how to install PointBase.

To complete this procedure, you will be writing to the IDE installation directories, so you must have root or administrator privileges.

1. On your file system, find the PointBase installation directory.

If your system had a pre-existing Sun ONE Application Server 7 installation, then PointBase may be installed as part of that installation. Look for a pointbase subdirectory in the s1as7-install-directory.

If you installed PointBase separately from other Sun software, locate your PointBase installation directory.

2. In the PointBase installation, locate the pbclientxxx.jar JDBC driver library file.

3. Copy the pbclientxxx.jar file to the s1studio-install-directory/lib/ext directory.

The PointBase JDBC driver is now enabled.

4. Restart the IDE.

5. In the IDE, choose Tools right arrow PointBase Network Server right arrow Configure.

The Configure PointBase dialog box is displayed.

6. In the text fields, type the PointBase installation directory and server port number; and click OK.

You can now start your PointBase server and console from the IDE.

7. In the Runtime tab of the IDE Explorer, select your application server instance.

It is labeled app-server-name (app-server-host:app-server-port). For example, the default server is server1(localhost:80), or a standard user's server could be MyServer (localhost:4850).

8. Right-click the application server instance node and choose Properties.

The properties window displays.

9. Open the property editor for the Classpath Suffix property.

Click on the value field of this property, then on the ellipsis button that appears. The Classpath Suffix editor window is displayed.

10. Click the Add JAR/ZIP button.

Use the Add JAR File file finder to locate your pbclientxxx.jar file.

11. Select the pbclientxxx.jar file and click OK.

12. Click OK to close the property editor window.

The external PointBase JDBC driver for the Sun ONE Application Server 7 runtime is now located.


Using the PointBase Server and Console

For detailed information on using this database software, see the PointBase documentation in the s1studio-install-directory/appserver7/pointbase/docs directory.

You must start the PointBase database server before you can access a PointBase database from an application you developed using the IDE or before you can create your own tables or database with PointBase software.


procedure icon  To Start the PointBase Server

1. From the main IDE window, Choose Tools right arrow PointBase Network Server.

2. Then choose Start Server.

The PointBase 4.2 window appears.


procedure icon  To Stop the PointBase Server

1. From the main IDE window Choose Tools right arrow PointBase Network Server.

2. Then choose Stop Server or choose Server right arrow Shutdown! from the PointBase 4.2 window.


procedure icon  To Start the PointBase Client Console

1. With the PointBase Server running, from the main IDE window choose Tools right arrow PointBase Network Server.

2. Then choose Start Console.

The Connect to Database dialog box appears.

3. Click OK to continue.


procedure icon  To Stop the PointBase Client Console

Do one of the following:

or


Using Other JDBC Enabled Databases

The following information applies to database drivers other than the driver for the PointBase Server 4.2 Restricted Edition database.

You can configure Sun ONE Application Server 7 to connect to other databases by performing actions similiar to those described for PointBase as follows:

To enable other JDBC drivers, you must place the database driver files in the s1studio-install-directory/lib/ext directory before you start the Sun ONE Studio IDE. If you do not do this, the dbschema wizard does not enable you to select the proper database driver when you create a new schema. You cannot mount the driver file in the IDE's Explorer, nor can you simply place the driver file in the CLASSPATH environment variable. You must copy the driver file into the lib/ext folder.

For information on configuring the connectivity resources for other databases, see the Sun ONE Application Server 7 Getting Started Guide. This book can be found at http://docs.sun.com/db/coll/s1_asse_en.

If you want to use the IDE with an Oracle database, see the Sun ONE Studio 5 J2EE Application Tutorial found on the Sun ONE Studio Developer Resources portal at: http://forte.sun.com/ffj/documentation/tutorialsandexamples.html