![]() ![]() ![]() ![]() ![]() ![]() ![]() |
The following sections describe how to configure and use the BEA WebLogic Type 4 JDBC Sybase driver:
The BEA WebLogic Type 4 JDBC driver for Sybase (the "Sybase driver") supports the following database versions:
Note: | XA connections are supported with the Sybase Adaptive Server Enterprise 12.0 and later versions only. XA connections are not supported on Sybase Adaptive Server 11.5 and 11.9. |
The driver class for the BEA WebLogic Type 4 JDBC Sybase driver is:
Use these driver classes when configuring a JDBC data source in your WebLogic Server domain.
To connect to a Sybase database, use the following URL format:
jdbc:bea:sybase://
dbserver
:
port
Table 7-1 lists the JDBC connection properties supported by the Sybase driver, and describes each property. You can use these connection properties in a JDBC data source configuration in your WebLogic Server domain. To specify a property, use the following form in the JDBC data source configuration:
property=value
Note: | All connection string property names are case-insensitive. For example, Password is the same as password. The data type listed for each connection property is the Java data type used for the property value in a JDBC data source. |
Setting the following connection properties for the Sybase driver as described in the following list can improve performance for your applications:
The driver can use a JDBC 3.0-compliant batch mechanism or the native Sybase batch mechanism to execute batch operations. Performance can be improved by using the native Sybase batch environment, especially when performance-expensive network roundtrips are an issue. When using the native mechanism, be aware that if the execution of the batch results in an error, the driver cannot determine which statement in the batch caused the error. In addition, if the batch contained a statement that called a stored procedure or executed a trigger, multiple update counts for each batch statement or parameter set are generated. The JDBC 3.0-compliant mechanism returns individual update counts for each statement or parameter set in the batch as required by the JDBC 3.0 specification. To use the Sybase native batch mechanism, this property should be set to true.
To improve performance when using scroll-insensitive result sets, the driver can cache the result set data in memory instead of writing it to disk. By default, the driver caches 2 MB of insensitive result set data in memory and writes any remaining result set data to disk. Performance can be improved by increasing the amount of memory used by the driver before writing data to disk or by forcing the driver to never write insensitive result set data to disk. The maximum cache size setting is 2 GB.
To improve performance, the driver's own internal prepared statement pooling should be enabled when the driver does not run from within an application server or from within another application that does not provide its own prepared statement pooling. When the driver's internal prepared statement pooling is enabled, the driver caches a certain number of prepared statements created by an application. For example, if the MaxPooledStatements property
is set to 20, the driver caches the last 20 prepared statements created by the application. If the value set for this property is greater than the number of prepared statements used by the application, all prepared statements are cached.
If your application executes prepared statements multiple times, this property should be set to StoredProc
to improve performance because, once created, executing a stored procedure is faster than executing a single SQL Statement. If your application does not execute prepared statements multiple times, this property should be set to Direct
. In this case, performance decreases if a stored procedure is created because a stored procedure incurs more overhead on the server than executing a single SQL statement.
By default, the Sybase driver skips the additional processing required to return the correct table name for each column in the result set when the ResultSetMetaData.getTableName()
method is called. Because of this, the getTableName()
method may return an empty string for each column in the result set. If you know that your application does not require table name information, this setting provides the best performance. See ResultSet MetaData Support for more information about returning ResultSet metadata.
Table 7-2 lists the data types supported by the Sybase driver and how they are mapped to JDBC data types.
Note: | FOR USERS OF SYBASE ADAPTIVE SERVER 12.5 AND HIGHER: The Sybase driver supports extended new limits (XNL) for character and binary columns—columns with lengths greater than 255. Refer to your Sybase documentation for more information about XNL for character and binary columns. |
See GetTypeInfo for more information about data types.
See SQL Escape Sequences for JDBC for information about the SQL escape sequences supported by the Sybase driver.
The Sybase driver supports the Read Committed
, Read Uncommitted
, Repeatable Read
, and Serializable
isolation levels. The default is Read Committed
.
The Sybase driver supports scroll-sensitive result sets only on result sets returned from tables created with an identity column. The Sybase driver also supports scroll-insensitive result sets and updatable result sets.
Note: | When the Sybase driver cannot support the requested result set type or concurrency, it automatically downgrades the cursor and generates one or more SQLWarnings with detailed information. |
Although Sybase does not define a Blob
or Clob
data type, the Sybase driver allows you to retrieve and update long data, specifically LONGVARBINARY
and LONGVARCHAR
data, using JDBC methods designed for Blobs and Clobs. When using these methods to update long data as Blobs or Clobs, the updates are made to the local copy of the data contained in the Blob
or Clob
object.
Retrieving and updating long data using JDBC methods designed for Blobs and Clobs provides some of the same advantages as retrieving and updating Blobs and Clobs. For example, using Blobs and Clobs:
To provide these advantages of Blobs and Clobs, data must be cached. Because data is cached, you will incur a performance penalty, particularly if the data is read once sequentially. This performance penalty can be severe if the size of the long data is larger than available memory.
The Sybase driver provides the following batch mechanisms:
To use the Sybase native batch mechanism, set the BatchPerformanceWorkaround
connection property to true. For more information about specifying connection properties, see Sybase Connection Properties.
The Sybase driver supports returning parameter metadata for all types of SQL statements.
If your application requires table name information, the Sybase driver can return table name information in ResultSet metadata for Select statements. By setting the ResultSetMetaDataOptions
property to 1, the Sybase driver performs additional processing to determine the correct table name for each column in the result set when the ResultSetMetaData.getTableName()
method is called. Otherwise, the getTableName()
method may return an empty string for each column in the result set.
When the ResultSetMetaDataOptions
property is set to 1 and the ResultSetMetaData.getTableName()
method is called, the table name information that is returned by the Sybase driver depends on whether the column in a result set maps to a column in a table in the database. For each column in a result set that maps to a column in a table in the database, the Sybase driver returns the table name associated with that column. For columns in a result set that do not map to a column in a table (for example, aggregates and literals), the Sybase driver returns an empty string.
The Select statements for which ResultSet metadata is returned may contain aliases, joins, and fully qualified names. The following queries are examples of Select
statements for which the ResultSetMetaData.getTableName()
method returns the correct table name for columns in the Select list:
SELECT id, name FROM Employee
SELECT E.id, E.name FROM Employee E
SELECT E.id, E.name AS EmployeeName FROM Employee E
SELECT E.id, E.name, I.location, I.phone FROM Employee E,
EmployeeInfo I WHERE E.id = I.id
SELECT id, name, location, phone FROM Employee,
EmployeeInfo WHERE id = empId
SELECT Employee.id, Employee.name, EmployeeInfo.location,
EmployeeInfo.phone FROM Employee, EmployeeInfo
WHERE Employee.id = EmployeeInfo.id
The table name returned by the driver for generated columns is an empty string. The following query is an example of a Select statement that returns a result set that contains a generated column (the column named "upper").
SELECT E.id, E.name as EmployeeName, {fn UCASE(E.name)}
AS upper FROM Employee E
The Sybase driver also can return schema name and catalog name information when the ResultSetMetaData.getSchemaName()
and ResultSetMetaData.getCatalogName()
methods are called if the driver can determine that information. For example, for the following statement, the Sybase driver returns "test" for the catalog name, "test1" for the schema name, and "foo" for the table name:
SELECT * FROM test.test1.foo
The additional processing required to return table name, schema name, and catalog name information is only performed if the ResultSetMetaData.getTableName()
, ResultSetMetaData.getSchemaName()
, or ResultSetMetaData.getCatalogName()
methods are called.
The Sybase driver supports any JSR 114 implementation of the RowSet interface, including:
See http://www.jcp.org/en/jsr/detail?id=114 for more information about JSR 114.
The Sybase driver supports retrieving the values of auto-generated keys. An auto-generated key returned by the Sybase driver is the value of an identity column
How you retrieve the values of auto-generated keys depends on whether the Insert statement you are using contains parameters:
Insert
statement that contains no parameters, the Sybase driver supports the following form of the Statement.execute
and Statement.executeUpdate
methods to inform the driver to return the values of auto-generated keys: Insert
statement that contains parameters, the Sybase driver supports the following form of the Connection.prepareStatement
method to inform the driver to return the values of auto-generated keys:
The application fetches the values of generated keys from the driver using the Statement.getGeneratedKeys method
.
When the Sybase driver establishes a connection, the driver sets the Sybase database option ansinull to on. Setting ansinull to on ensures that the driver is compliant with the ANSI SQL standard and is consistent with the behavior of other DataDirect Connect for JDBC drivers, which simplifies developing cross-database applications.
By default, Sybase does not evaluate NULL
values in SQL equality (=) comparisons in an ANSI SQL-compliant manner. For example, the ANSI SQL specification defines that col1=null
always evaluates to false. Using the default database setting (ansinull=off
), if the value of col1
in the following statement is NULL
, the comparison evaluates to true instead of false:
SELECT * FROM table WHERE col1 = NULL
Setting ansinull
to on changes the default database behavior so that SQL statements must use IS NULL
instead of =NULL
. For example, using the Sybase driver, if the value of col1
in the following statement is NULL
, the comparison evaluates to true:
SELECT * FROM table WHERE col1 IS NULL
To restore the default Sybase behavior for a connection, your application can execute the following statement after the connection is established:
SET ANSINULL OFF
Before you can use the Sybase XA driver in a global transaction, you must first set up your Sybase server to support global transactions. See " Set Up the Sybase Server for XA Support" in Programming WebLogic JTA.
![]() ![]() ![]() |