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".

Steps Configuring a connector

  1. Expand the Connectors folder, then highlight the connector you want to configure.
  2. Choose File | Connector Properties.
  3. The Connector Properties dialog box has four tabs.
    1. On the General tab:
      1. Enter a description for the connector.
      2. 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.
      3. 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.

    2. On the Config Properties tab, add environment entries:
      1. Click Add. This adds a new row to the Environment Entries Referenced in Code list.
      2. In the Entry column, enter ConnectionURL .
      3. In the Type column, choose String.
      4. In the Value column, enter the JNDI name for the resource; for example, jdbc:sybase:Tds:myhost:2638 .
      5. In the Description field, enter a brief description of the connector.

    3. In the Java Classes tab:
      1. Click Add. This adds a new row to the Java Classes list.
      2. Enter the name of a Java class file or JAR file that implements the connector.

    4. The All Properties tab lists all the properties associated with the connector.


Note   Currently, you cannot test the connections obtained from a connector using ping.

Steps Adding a managed connection factory

For each connector, add one managed connection factory.

  1. Expand the Connectors folder, then highlight the connector to which you want to add a managed connection factory.
  2. Choose File | New Managed Connection Factory.
  3. 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:
    1. On the General tab:
      1. Enter a description for the managed connection factory.
      2. Set the Configured Queue Size.
      3. Set the Idle Connection Timeout, in seconds.

    2. On the Config Properties tab, add environment entries.
      1. Click Add. This adds a new row to the Environment Entries Referenced in Code list.
      2. In the Entry column, enter "ConnectionURL".
      3. In the Type column, choose String.
      4. In the Value column, enter the JNDI name for the resource; for example, jdbc:sybase:Tds:myhost:2638 .
      5. In the Description field, enter a brief description of the managed connection factory.

    3. On the Security Properties tab, enter a user name and password that are valid to access the resource.
    4. The All Properties tab lists all the properties associated with the managed connection factory.


Steps 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.

  1. Expand the Connectors folder, then highlight the connector you want to synchronize.
  2. Choose File | Synchronize. This displays the Synchronize Connectors dialog box.
  3. See Table 6-1 for a description of the synchronization properties.
  4. Click Start Sync. The Synchronization message box displays the status of the process.

Steps Refreshing a connector

  1. Expand the Connectors folder, then highlight the connector you want to refresh.
  2. Choose File | Refresh.

Steps Refreshing a connector view

  1. Expand the Connectors folder, then highlight the connector whose view you want to refresh.
  2. Choose File | Refresh View.

Steps Deleting a connector

  1. Expand the Connectors folder, then highlight the connector you want to delete.
  2. 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.