A connection cache maintains a pool of available connections that EAServer components use to interact with third-tier data servers. You must configure connection caches for the specific user and database combinations used by your components. A connection cache entry improves performance by eliminating the overhead associated with setting up a connection when one is required. Create as many connection caches as you need.
See Chapter 26, “Using Connection Management,” in the EAServer Programmer’s Guide for additional information.
You must refresh a cache before any changes to the cache properties take effect, and you should test the connection with ping before trying to access it from components.
You cannot define two distinct caches that use identical values for server, user, password, and connectivity library. If two caches are defined with matching values for these settings, and your application requests one, EAServer returns the first match that is found.
Creating
a new connection cache
Highlight the Connection Caches folder.
Select File | New Connection Cache.
Configure the connection cache properties in the wizard.
Configured connection cache entries appear on the right side of the window of EAServer Manager when you highlight the Connection Cache folder on the left side of the window.
Viewing,
modifying, or deleting a connection cache entry
Expand the Connection Caches folder.
Highlight the connection cache you want to modify.
From the File menu, select one of:
Configuration Wizard – a wizard to walk you through the configuration of common properties.
Properties – displays the connection cache’s properties in a single dialog box and allows you to change them.
Delete – deletes the connection cache from the system.
The properties that you configure on the General tab are:
Connection Cache Name The name for this cache configuration. Connection cache names are limited to one word, which can contain letters, numbers, and underscores. Names are case-sensitive. You cannot modify the name of an existing connection cache.
Description A description of the connection cache. The description is a string with a maximum of 255 characters.
Database Type The database type. Required for caches that use the EAServer automatic persistence or stateful failover features, such as EJB CMP entity beans.Several types are predefined, and you can create your own. See “Database type setting” for more information.
Server Name For each of these database driver types, enter:
JDBC – the URL appropriate for use in JDBC calls. For more information, see “About JDBC connection URLs”.
ODBC – the ODBC data source name. See “About ODBC data source names” for more information.
CTLIB – the server name as it would be specified in a ct_connect call. On UNIX platforms, the server must be listed in the EAServer interfaces file. For Windows, it must be listed in the ini\sql.ini file.
OCI 7.X – the Oracle SQL*Net connect string or database alias.
OCI 8.X – the Oracle SQL*Net connect string or database alias.
OCI 9.X – the Oracle SQL*Net connect string or database alias.
For XA connections, enter the name of the XA resource server. For JDBC, enter:
NetworkProtocol=Tds:Server=yourServer:Port=TdsPort
where yourServer is the server that the driver is installed on, and TdsPort is the port number where TDS calls are received.
For ODBC or JDBC connections, see your driver documentation for more information. For OCI connections, see your Oracle documentation.
User Name The user name for this cache. The name used (along with a password) to connect to the database identified by the server entry.
The cache user name and password are always used for the initial connection, but you can configure set-proxy support so that a component’s database work is done using the client identity. See com.sybase.jaguar.conncache.ssa for more information.
Password The password for this cache. The password and user name are used to connect to the database identified by the server entry. Passwords are encrypted in the EAServer configuration file.
EAServer Manager does not display passwords for existing caches. To change a password, enter the new password and click OK.
For JDBC connection caches, the Server Name field is a URL whose syntax depends on the JDBC interface level that the driver class supports.
JDBC level 1 drivers These driver classes implement the java.sql.Driver interface and typically have class names that end in Driver. For example, the Sybase jConnect level 1 driver class is com.sybase.jdbc2.jdbc.SybDriver, which requires syntax like:
jdbc:sybase:Tds:host:2638
The Oracle level 1 driver is class oracle.jdbc.driver.OracleDriver, which requires syntax like this example:
jdbc:oracle:thin:@dbserver:1521:orcl
For details on the jConnect syntax, see the jConnect documentation. For details on drivers from other vendors such as Oracle, see the vendor documentation.
JDBC level 2 connection pool drivers These driver classes implement the javax.sql.ConnectionPoolDataSource interface and typically have class names that end in PoolDataSource. For example, the Sybase jConnect level 2 driver is com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource, which requires syntax like:
NetworkProtocol=Tds:Server=hostname-or-IPaddress:Port=port-number
The Oracle level 2 driver class is oracle.jdbc.pool.OracleConnectionPoolDataSource, which requires syntax like this example:
ServerName=server:Port=1521:DatabaseName=ORC:DriverType=thin
Level 2 drivers support a setter method naming scheme to indicate the connection properties that they support. A setter method named setProperty indicates that the driver supports the property named Property. For example, a method named setServer with a string input parameter indicates that the driver recognizes the Server property. You can set any string-valued property in the server URL. EAServer follows these rules to parse the URL:
A colon (:) acts as a property separator.
Items separated by an equal sign (=) are
a property-value pair, of the form Name=Value
.
You can use the Java javap command to list the property setter methods supported by your level 2 driver (or by the DataSource driver class that it extends). Driver properties that do not take string types can be set in the connection cache property com.sybase.jaguar.conncache.config-property, described in com.sybase.jaguar.conncache.config-property. Use the Advanced tab to set this property. For information on what each property configures, see the driver documentation.
On UNIX platforms, ODBC data source names used in EAServer must be defined in the ODBC driver manager configuration, typically by modifying the odbc.ini file in the driver manager installation that is included with EAServer. For instructions, see the EAServer Installation Guide for your platform.
On Windows platforms, EAServer uses SQLDriverConnect to establish ODBC connections, which allows you to specify driver-specific connection information. You can specify either a data source and one or more optional parameters, or a DSN file that contains the data source and other parameter information.
If you use a DSN file to specify connection information, all the servers in an EAServer cluster can share the information. Use this syntax to specify a DSN file, where file.dsn identifies the file name:
FILEDSN=file.dsn
Minimally, a DSN file must contain the keyword “DRIVER” and the name of the data source in the ODBC section. The following is a sample ODBC section for an ASA 9.0 database:
[ODBC] DRIVER=Adaptive Server Anywhere 9.0 UID=dba Compress=No DisableMultiRowFetch=No Debug=No Integrated=No AutoStop=Yes EngineName=asademo9 DatabaseFile=C:\Sybase\SQL Anywhere 9\asademo.db
See your ODBC driver documentation for information about which parameters can be used with the driver.
To specify a data source, instead of a DSN file, use this syntax, where dataSource is the name of the data source, and param1, value1, param2, and value2 are optional driver-specific connection parameters and their corresponding values:
DSN=dataSource;[param1=value1];[param2=value2];
These
restrictions apply to SQLDriverConnect strings:
Neither keywords nor their values can contain the []{}(),;?*=!@\ characters.
Data source names cannot contain a backslash or a leading blank.
Spaces are not allowed on either side of the equal sign in a keyword/value pair.
For more information about using SQLDriverConnect, see the MSDN Web page.
Configure these properties on the Caching tab:
Enable Cache-by-Name Access Select this option to allow retrieval of a database connection using the connection cache name instead of requiring a user name and password.
Cache-by-name access allows you to use caches in components without requiring access to the database password from the component source code.
Cache-by-name access is required for JDBC caches that are used in EJB or Web application resource references.
Enable Connection Sanity Check Specifies whether connections should be verified.
Components may release a connection that is not ready for use by another component. For example, there may be unretrieved results on the connection. When the option is enabled, EAServer verifies that the connection is open and accepts commands before making it available for reuse. Disabling the option increases performance, but may complicate debugging.
The default query for testing the connection is “select 1”. If this syntax is invalid for the database, you must configure a valid test query by setting the com.sybase.jaguar.conncache.check property on the Advanced tab. For more information, see com.sybase.jaguar.conncache.check.
Maximum Connections The maximum number of connections that can be allocated before the value of Wait for Connection determines whether to wait for a connection. The value of this property should be greater than or equal to the value of Maximum Connection Pool Size. A value of 0 indicates that new connections should be opened whenever they are required. Excess connections are deallocated and not returned to the cache.
Wait for Connection If the number of connections that have been allocated is equal to the value of Maximum Connections, specifies whether to wait for a connection.
Maximum Connection Pool Size The maximum number of connections in the pool.
After a connection is released, it is returned to the pool. The default value is 10. You can increase this number if performance suffers due to an insufficient number of available connections.
Minimum Connection Pool Size The minimum number of connections in the pool. EAServer preallocates and opens the specified number of connections at start-up time. The default is 0.
If no minimum size is specified, connections are opened to fill the pool up to the maximum size, on an as-needed basis.
Pooled Connection Idle Timeout Specifies the number of seconds an idle connection remains in the pool before it is dropped. The default is 300 seconds (5 minutes).
Pooled Connection Refresh Rate The refresh rate for the cache. The default is 600 seconds (10 minutes).
For information on tuning these settings, see “Tuning the cache size” in the EAServer Performance and Tuning Guide.
Configure these properties on the Driver tab:
Database Driver Type Select the connection library type used for this cache. Your choices for library type are:
JDBC – for connections using a Java Database Connectivity driver.
CTLIB_110 – for Sybase Open Client Client-Library connections.
ODBC – for connections using an open database connectivity driver.
OCI_7 – for connections using OCI 7.x.
OCI_8 – for connections using OCI 8.x.
OCI_9 – for connections using OCI 9.x.
OCI_9U – for connections using OCI 9.x.
Connection Library 1PC Enter the class name or library name used to support single-phase commit transactions.
For UNIX platforms, use one of the connection libraries listed in Table 4-1.
Type |
Connection library name |
---|---|
JDBC |
The Java class name for the driver class. For example, if you are using a Sybase ASA or Adaptive Server Enterprise database, set one of these values:
The Oracle connectivity driver requires oracle.jdbc.pool.OracleConnectionPoolDataSource. For EJB CMP entity beans, EAServer supplys JDBC wrapper drivers that can improve performance through the use of deferred updates and stored procedures. For more information, see “Using CMP JDBC wrapper drivers” in the EAServer Performance and Tuning Guide. |
Client Library 12.5 |
You must use the version in the EAServer lib subdirectory, which has been optimized for EAServer threading. |
ODBC |
|
OCI 7.x |
|
OCI 8.x |
|
OCI 9.x |
Library location must be in library path
On Solaris, Digital UNIX, and Linux, the location of the connection
library must be in your LD_LIBRARY_PATH for ODBC,
Client-Library, or OCI caches, and in CLASSPATH for
JDBC caches.
On AIX, the file must be in your LIBPATH for ODBC, Client-Library, or OCI caches, and in CLASSPATH for JDBC caches.
On HP-UX, the file must be in your SHLIB_PATH for ODBC, Client-Library, or OCI caches, and in CLASSPATH for JDBC caches.
For Windows platforms, use one of the connection libraries listed in Table 4-2.
Connection Library XA Enter the class name or library name used to support two-phase commit transactions, and the name of the XA resource library.
Database driver |
Connection library |
XA resource library |
---|---|---|
JDBC |
Same as the JDBC connection library described in Table 4-1 |
com.sybase.jdbc2.jdbc.SybXADataSource |
Sybase Client Library 11.0 |
libjct_r.so |
libjxa.so |
Oracle OCI 7.x |
libclntsh.so |
libclntsh.so |
Oracle OCI 8.x |
libclntsh.so |
libclntsh.so |
Oracle OCI 9.x |
libclntsh.so |
libclntsh.so |
Database driver |
Connection library |
XA resource library |
---|---|---|
JDBC |
Same as the JDBC connection library described in Table 4-2 |
com.sybase.jdbc2.jdbc.SybXADataSource |
Sybase Client Library 11.0 |
libjct.dll |
libjxa.dll |
Oracle OCI 7.x |
ociw32.dll |
xa73.dll |
Oracle OCI 8.x |
oci.dll |
oraclient8.dll |
Oracle OCI 9.x |
oci.dll |
oraclient9.dll |
By default, EAServer uses the XA libraries listed in Table 4-3 and Table 4-4 to obtain an XA resource that is exported from the database connection libraries.
The resource manager determines the connection type based on the configuration and state of the transaction. In most cases, you should not need to modify the resource manager properties. However, to use a shared library or DLL other than the default, you must edit the database property file. For example, for XA resource connections using Oracle OCI 8.x, where 8.x is 8.1.5 or lower, set this property value in the OCI_8.props file:
com.sybase.jaguar.resourcemanager.xalib = xa80.dll
Table 4-5 lists the resource manager database property files for the C/C++ connection caches, which are located in the EAServer Repository/ResourceManager directory.
Database driver |
Database property file |
---|---|
Sybase Client Library 11.0 |
CTLIB_110.props |
Oracle OCI 7.x |
OCI_7.props |
Oracle OCI 8.x |
OCI_8.props |
Oracle OCI 9.x |
OCI_9.props |
To use a shared library or DLL other than the default for a single connection cache, edit the connection cache properties file, <cache_name>.props, located in the EAServer Repository/ConnCache directory, and specify the shared library or DLL name:
com.sybase.jaguar.conncache.xadllname = library_name
If you execute a transaction without an XA resource configured for a database, the EAServer connection manager returns CS_FAIL.
If a configured XA resource is not running or cannot be connected to, EAServer cannot initialize. To solve this problem, perform one of these tasks:
Start the XA resource.
Make the XA resource available to EAServer.
Start the JagRepair server and delete the XA resource. See “Using the JagRepair server” for information about JagRepair.
Use HA Connection When using Client Library 11.0 to connect to an Adaptive Server Enterprise database, this enables the high availability failover feature.
To use this feature, you also need to modify the client connection information and pass CS_HAFAILOVER when calling ct_config or ct_con_props—see “Open Client Client-Library” for more information.
Configure these properties on the XA tab:
Database Name If you select OCI 7.x, 8.x, or 9.x, specify the database name. Other connection cache types do not require a value.
Default Open String The string used to connect to the XA resource. You cannot modify this string, which is automatically built from the information that you entered in the other tabs.
Open String Suffix In this optional field, you can specify any valid open string options. For example, for a Sybase Client-Library 11.0 XA resource, you can specify a log file name by entering:
-L logfile
If you specify a log file, any errors related to Open Client XA operations are written to this file. If you do not specify a log file, or set the open string suffix incorrectly, errors are logged to the xa_syb_<pid>.trc file, where pid is the EAServer process ID.
If the Open String Suffix is set incorrectly, XA operations
are not supported for the connection cache.
Close String In this optional field, you can specify a value used by the resource to close a connection.
Configure these properties on the SQL Tracing tab:
Enable SQL Tracing If you select this option, all SQL connections are traced. Trace statements, which include the method name, input parameters, and output values, are sent to the device specified in Logging Handler.
Log by Connection Select this option to create separate log files for each connection. Log file names are created using the cache name and an integer to represent the connection; for example, if the cache name is JavaCache, the log files are JavaCache1.log, JavaCache2.log, and so on.
Log Parent Handlers If you select this option, trace statements are sent to parent handlers, in addition to the device specified in Logging Handler. If the Logging Handler and its parent handlers point to the same device, trace statements can be duplicated.
Logging Handler Select the device to handle trace statements:
eas_servlet – directs trace statements to the servlet logging handler. To configure where the output is sent, see “Configuring log profiles”.
eas – writes trace statements to the server log file; for example, Jaguar.log.
eas_console – writes trace statements to the console.
To set the cache properties described in this section, use the Advanced tab. You can set any property on this tab, as listed in Connection cache properties. In most cases, the controls on the other tabs provide a more convenient way to set properties.
You can also configure additional driver- or library-specific properties on this tab.
For a JDBC connection cache, you can specify settings beyond those shown in the Connection Cache Properties dialog using the com.sybase.jaguar.conncache.config-property property. For details, see com.sybase.jaguar.conncache.config-property.
For backward compatibility, cache properties that are defined in this form are still supported:
propertyName=value
Any property whose name does not begin with com.sybase.jaguar is passed to the JDBC driver as a connection property. For example:
PACKETSIZE=2048
Different JDBC drivers recognize different sets of properties. See your driver documentation for more information on the properties that can be set.
You can set the following properties for Client-Library connections. See the Client-Library documentation for the ct_con_props routine for more information:
CS_HOSTNAME
CS_APPNAME
CS_TDS_VERSION
CS_PACKETSIZE
This example sets all of these properties:
CS_HOSTNAME=myhostname CS_TDS_VERSION=CS_TDS_46 CS_PACKETSIZE=512 CS_APPNAME=myapp
Any property name not recognized by EAServer is ignored.
The CS_TDS_VERSION property takes one of these values: CS_TDS_50, CS_TDS_495, CS_TDS_46, CS_TDS_42, or CS_TDS_40.
The CS_PACKETSIZE property takes a numeric value within the range of legal packet sizes for the server. If the server does not support the packet size, the cache cannot connect to the server.
Make sure there is no extra white space between the
property name, the equal sign, and the property value, or after
the property value.
In connection caches used to support automatic persistence or stateful failover, you must configure the Database Type connection cache property. This property defines database-specific information required by the storage component, for example, the commands to verify a table exists and create new tables. Several types are predefined, as described in Table 4-6.
You can create your own database type definitions as described in Database type properties.
If you have just modified connection cache properties, refresh the cache before you test it.
To refresh the cache:
Highlight the Connection Caches folder.
Highlight the cache’s icon and choose File | Refresh.
Refreshing a cache may affect running components that are using the cache, specifically:
If you change the connectivity library setting, cache references held by components become invalid. Attempts to retrieve connections or query cache properties will cause errors. In this case, the component must retrieve a new cache handle.
If you change other properties, such as user name, password, server name, or the number of connections in a cache, cache references remain valid, but components may be affected by the changed settings. For example, if you change the server name, connections retrieved after the cache has been refreshed will go to the server indicated by the new name.
This feature allows you to test the cache configuration to verify that connections can be made using the supplied parameters. If you have just changed any settings, refresh the cache before testing it.
To test the cache with ping:
Highlight the Connection Caches folder.
Highlight the cache’s icon and choose File | Ping.
EAServer Manager reports whether the connection attempt succeeded.
If ping fails, check the message text for a description of the problem. The server log file may contain additional information about the cause of the error.
If you change the cache properties to correct the problem, you must refresh the cache before testing again.
To use XA resources with an Adaptive Server Enterprise 12.0 or later database running on UNIX or Windows, perform these tasks:
(Windows only.) Verify that you have the correct license file, which is located in %SYBASE%\SYSAM-1_0\licenses\license.dat. To run XA transactions, you must have the ASE_DTM license.
Configure the database to use XA transactions. For more information, see Using the Adaptive Server Distributed Transaction Management Features, available on the Sybase Product Manuals Web page.
Create a database to use for XA transactions.
Configure the database tables and stored procedures required for JDBC connection caches, which are available in $JAGUAR/html/classes/sp/sql_server12.sql.
Configure the database tables required for C/C++ connection caches. You can install these tables by running xa_load.sh (UNIX) or xa_load.bat (Windows), which is located in the EAServer html/classes/sp directory.
Create a login, other than sa, for connecting to the database. You cannot use the sa login to connect to an Adaptive Server Enterprise databases for XA transactions.
When you configure an XA resource for C/C++ connection caches, you need to modify two configuration files.
On UNIX:
$JAGUAR/interfaces
$JAGUAR/xa_config
On Windows:
%JAGUAR%\ini\sql.ini
%JAGUAR%\ini\xa_config
On UNIX, add these lines to the interfaces file:
DbServer master tcp ether host 5300 query tcp ether host 5300
On Windows, add these lines to the sql.ini file:
[DbServer] master=NLWNSCK,host,5200 query=NLWNSCK,host,5200
where DbServer is the name of the database server and host is the name of the machine on which the database server runs. DbServer should have the same value that you entered in the Server Name field when you configured the XA resource.
For both operating systems, add these lines to the xa_config file:
[xa] lrm=serverName server=DbServer
where:
serverName is the name you entered in the Server Name field when you configured the XA resource.
DbServer is the name of the server you entered in either the interfaces file or the sql.ini file.
serverName and DbServer represent
the same server and should have the same value.
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |