Sun Microsystems Logo

 

 
 

Sun[tm] ONE Studio 4, Enterprise Edition for Java[tm] with Application Server 7 Tutorial
Setting Up Database Connectivity
PREV PREV NEXT

 

Since the enterprise application uses the Java Database Connectivity (JDBC[tm]) API to record greetings to a database, you need to define the necessary JDBC-related settings in the application server environment prior to deploying and exercising the application. JDBC configuration involves setting up a JDBC driver, defining a JDBC connection pool and registering the JDBC resources used by your application.

Once you define the necessary JDBC connection pool and resource entries, you will start the PointBase Server database.

  1. Configure the JDBC Driver
  2. Define the JDBC Connection Pool
  3. Define the JDBC Resource
  4. Start the PointBase Database

1. Configure the JDBC Driver

A JDBC driver must be configured in the classpath of the application server before you can exercise applications that use JDBC.

Since the PointBase Type 4 JDBC driver should already be configured in your application server instance's environment (based on either the combined installation of the application server with PointBase or through your installation and configuration of PointBase), there is no need for you to perform any additional JDBC driver set up steps.

Solaris 9 Users: If the application server was installed as part of a Solaris 9 installation, you should have already followed the Getting Started Guide for Sun ONE Application Server 7. While performing the steps in the Getting Started Guide, you should have installed PointBase and configured the application server to use the PointBase JDBC driver. If you have not already done so, make sure that you've completed the Getting Started Guide prior to continuing with this tutorial.


2. Define the JDBC Connection Pool

Before running the sample application, you need to define a suitable JDBC connection pool that maps to the PointBase database server and a JDBC resource that associates the JDBC references made in the sample application to the JDBC connection pool definition.

If you already exercised this sample application as part of the Getting Started Guide, the JDBC connection pool may already be defined with the application server.

To determine whether or not the connection pool has already been registered:

1. Select the Runtime tab of the Explorer window.

2. Expand the Server Registry, Installed Servers, Sun ONE Application Server 7 nodes.

3. Expand the localhost:4848 node followed by the server1(localhost:port) node. Use the appropriate administrative server port number for your environment.

4. Attempt to expand the Registered JDBC Connection Pool node to list any registered connection pools.

If you either cannot expand the connection pool node or do not see a connection pool entry named PointBasePool, continue with the next section to register the appropriate connection pool.

If you see an entry named PointBasePool, scan the following instructions to ensure that the settings of this pool match the requirements of the application.

To register the JDBC connection pool:

1. Right-click the Unregistered JDBC Connection Pools node and select Add New JDBC Connection Pool.

The Properties of JdbcConnectionPool property sheet is displayed.

2. Type com.pointbase.jdbc.jdbcDataSource in the Datasource Classname.

3. Type PointBasePool in the Name field.

4. Select the Properties field and then click the ellipsis (...) button.

A property editor appears without any entries.

5. Add the following sets of values to the property name, value, and description fields, using the Add button:

Name Value
DatabaseName

jdbc:pointbase:server://localhost/sun-appserv-samples

User jdbc
Password jdbc

Non-default PointBase Server Port: If you made your own copy of the PointBase Server environment and selected a PointBase server port number other than the default value of 9092, then you need to specify the port number in the DatabaseName property.

The DatabaseName property specified for the JDBC Connection Pool must be changed from:

jdbc:pointbase:server://localhost/sun-appserv-samples

to:

jdbc:pointbase:server://localhost:<port>/sun-appserv-samples

Where <port> is the port number specified in the StartServer script for PointBase.

6. Click OK.

7. Clear the value of the Table Name field.

8. Close the property sheet.

9. Right-click the PointBasePool node and choose Register.

A new Select Server to Register dialog box appears.

10. Select server1 and click Register.

An Information dialog box appears indicating a successful registration.

11. Click OK to close the Information dialog box.

12. Click OK to close the Select Server to Register to dialog box.

13. Expand the Registered JDBC Connection Pools node under the server1(localhost:4848) node.

The registered PointBasePool JDBC connection pool is displayed.

If you do not see the PointBasePool node under the Registered JDBC Connection Pools node, right-click the Registered JDBC Connection Pools node and select Refresh List.

3. Define the JDBC Resource

Now that the JDBC connection pool definition has been created, you are ready to define a JDBC resource and associate it with the connection pool entry.

If you already exercised this sample application as part of the Getting Started Guide, a suitable JDBC resource may already be defined with the application server.

To determine whether or not a suitable JDBC resource has already been registered:

1. Expand the localhost:4848 node followed by the server1(localhost:port) node. Use the appropriate administrative server port number for your environment.

2. Attempt to expand the Registered JDBC DataSources node to list the registered JDBC resources.

If you either cannot expand the JDBC DataSources node or do not see a datasource entry named jdbc/jdbc-simple, continue with the next section to register the appropriate resource.

If you see an entry named jdbc/jdbc-simple, scan the following instructions to ensure that the settings of this resource match the requirements of the application.

To register the JDBC resource (referred to as a JDBC "DataSource" in the IDE):

1. Right-click the Unregistered JDBC DataSources node and select Add new Data Source.

The Properties of DataSource property sheet is displayed, and a new DataSource node is created under the Unregistered Data Sources node

2. Type jdbc/jdbc-simple in the JNDI Name field.

The resource name here must match the JNDI name that you have assigned when creating the web application.

3. Select PointBase(server1:localhost:port) in the Pool Name field.

4. Close the property sheet.

5. Right-click the new jdbc-simple node and choose Register...

A Select Server to Register to dialog box is displayed.

6. Select server1 and click Register.

An Information dialog box appears indicating a success.

7. Click OK to close the Information dialog box.

8. Click OK to close the Select Server to Register to dialog box.

9. Expand the Registered JDBC DataSources node under the server1 (localhost:4848) node.

The registered jdbc/jdbc-simple data source is displayed.


4. Start the PointBase Server Database

The database server can be started by performing one of the following actions:

Windows Platforms:

PointBase installed with the application server:

Start -> Programs -> Sun Microsystems -> Sun ONE Application Server 7 -> Start PointBase

PointBase downloaded and installed separately:

Execute: <pointbase_install_dir>/tools/server/startserver.bat

UNIX Platforms:

PointBase installed with the application server:

Execute: <appserver_install_dir>/pointbase/server/StartServer.sh

PointBase downloaded and installed separately:

Execute: <pointbase_install_dir>/tools/server/startserver.sh

Once you execute this script, you will see the following text in either a command window or at the UNIX terminal prompt:

    Server started, listening on port 9092, display level: 0 ...
    >

You are finally ready to exercise the application. Proceed to Deploying and Running the Enterprise Application.

PREV PREV NEXT