HP (Hewlett-Packard) Reliable Transaction Router Network Router User Manual


 
Application Programming Interfaces
Figure 4–6 RTR Service Provider
JNDI
VM-1181A-AI
Service Provider
DataSource
Connection Pool
JDBC Driver
JRTR Server
Application
A database resource is represented by a datasource object.
For the application to locate the datasource representing the
database resource, a naming service that implements the
Java Naming and Directory Interface (JNDI) must be present.
Registering a datasource with the JNDI service enables the
RTR Java J2EE-based application to locate the datasource and
connect to its corresponding database. Once the datasource is
located and the datasource object is instantiated, the datasource
method getConnection( ) is called to obtain a connection object.
Sample Java
server code
The sample Java code from a server Java application illustrates
Java use of a datasource and a connection pool.
// Get a datasource that has been configured by the administrator
DataSource ds = (DataSource)LookupFromJNDI("myDataSource");
// Get a connection to the database
Connection con = ds.getConnection();
Some complex applications require multiple connections to one
or more databases. Connection pooling allows applications to
ofoad the high overhead of time and computing resources
involved in creating and maintaining multiple connections to one
or more databases. This is accomplished by using connectionpool
objects. Connection pools (like datasources) are registered with a
JNDI service. For more information on JDBC, refer to the Sun
Java web site link for the JDBC Standard Extension API.
RTR Interfaces 4–17