
Chapter 4 Database Access
Configuring connectors
A connector is a specialized connection factory that provides
connections for EJBs, Java servlets, JSPs, and CORBA-Java components.
Each connector has one managed connection factory with its
own property file. The Java Connection Manager (JCM) classes create
the connection factories and manage a pool of connections for a
connector.
For information on importing and exporting connectors, see "Deploying connectors".
Configuring
a connector
- Expand the Connectors folder, then highlight
the connector you want to configure.
- Choose File | Connector Properties.
- The Connector Properties dialog box has four tabs.
- On the General tab:
- Enter a description for the connector.
- Set
the Configured Queue Size; the default size is 10. This defines
the maximum number of connections that can be pooled. When a component
requests a connection, EAServer attempts to get it from the connection
pool. If none exists, it opens a new connection.
- Set
the Idle Connection Timeout, in seconds. Connections are dropped
from the pool when they have been idle for this amount of time.
The default is 0, which means the connection never times out.
- On the Config Properties tab, add environment entries:
- Click Add. This adds a new row
to the Environment Entries Referenced in Code list.
- In the Entry column, enter
ConnectionURL
.
- In the Type column, choose String.
- In the Value column, enter the JNDI name for the resource;
for example,
jdbc:sybase:Tds:myhost:2638
.
- In the Description field, enter a brief description
of the connector.
- In the Java Classes tab:
- Click Add. This adds a new row
to the Java Classes list.
- Enter the name of a Java class file or JAR file that
implements the connector.
- The All Properties tab lists all the properties associated
with the connector.
Currently, you cannot test the connections obtained
from a connector using ping.
Adding a managed connection factory
For each connector, add one managed connection
factory.
- Expand the Connectors folder, then highlight
the connector to which you want to add a managed connection factory.
- Choose File | New Managed Connection Factory.
- In the Create Managed Connection Factory dialog box,
enter a name for the connection factory and click OK. This displays
the Connection Factory Properties dialog box, which has four tabs:
- On the General tab:
- Enter a description for the managed
connection factory.
- Set the Configured Queue Size.
- Set the Idle Connection Timeout, in seconds.
- On the Config Properties tab, add environment entries.
- Click Add. This adds a new row
to the Environment Entries Referenced in Code list.
- In the Entry column, enter "ConnectionURL".
- In the Type column, choose String.
- In the Value column, enter the JNDI name for the resource;
for example,
jdbc:sybase:Tds:myhost:2638
.
- In the Description field, enter a brief description
of the managed connection factory.
- On the Security Properties tab, enter a user name and
password that are valid to access the resource.
- The All Properties tab lists all the properties associated
with the managed connection factory.
Synchronizing
a connector
You can synchronize a connector within a cluster
of servers by using Jaguar Manager to copy standalone connectors
and their property files to other servers.
- Expand the Connectors folder, then highlight
the connector you want to synchronize.
- Choose File | Synchronize. This displays the
Synchronize Connectors dialog box.
- See Table 6-1 for a description of the
synchronization properties.
- Click Start Sync. The Synchronization message box displays
the status of the process.
Refreshing a connector
- Expand the Connectors folder, then highlight
the connector you want to refresh.
- Choose File | Refresh.
Refreshing a connector view
- Expand the Connectors folder, then highlight
the connector whose view you want to refresh.
- Choose File | Refresh View.
Deleting a connector
- Expand the Connectors folder, then highlight
the connector you want to delete.
- Choose File | Delete Connector.
Transaction modes
EAServer connectors support these transaction modes:
Transaction support attribute
|
Description
|
NO_TRANSACTION
|
The connector is nontransactional; it
does not support local transactions or XA resources.
|
LOCAL_TRANSACTION
|
The connector implements only the LocalTransaction interface,
therefore, EAServer must manage all transactions.
|
XA_TRANSACTION
|
The connector supports both local transactions and
XA resources.
|
Looking up a managed connection factory with JNDI
Within
an application, use JNDI to look up a connector's managed
connection factory instance and get a connection to an enterprise
information system, as this code sample illustrates:
// Get the initial JNDI context
Context initContext = new InitialContext();
// Look up a connection factory instance
javax.resource.cci.ConnectionFactory cf = (javax.resource.cci.ConnectionFactory)
initCtxt.lookup("java:comp/env/eis/MyEIS);
javax.resource.ci.Connection conn = cf.getConnection();
For more information on managing connections, see Chapter
24, "Using Connection Management," in the EAServer
Programmer's Guide.
Copyright © 2002 Sybase, Inc. All rights reserved.
|
|