Connection serializationAdded by IBM on October 4, 2010 | Version 1 (Original)
|A DB2® Everyplace® data source accepts connections from one process at a time. When more than one process tries to connect to the same data source at the same time, the requests are put into a queue through a mechanism called connection serialization.
A DB2® Everyplace® data source accepts connections from one process at a time. When more than one process tries to connect to the same data source at the same time, the requests are put into a queue through a mechanism called connection serialization
Connection serialization requires developers to decide how long an application should wait to get a connection. This interval, called the timeout period
, can be set using the SQL_ATTR_LOGIN_TIMEOUT attribute of the SQLSetConnectAttr() function. The following CLI and JDBC examples set the connection timeout period to 10. If the application cannot connect to the database within 10 seconds, it returns an error code.
The timeout period
int i = 10; // 10 seconds timeout
rc = SQLSetConnectAttr(hdbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) i, 0);
int waitTime = 10;
String url = "jdbc:db2e:mysample";
Properties prop = new Properties();
Connection con = driver.connect(url,prop);
- The default timeout period is 0 seconds.
- The default LOCK_TIMEOUT period is 20 seconds.
- A multi-thread application can connect to a database using one thread and disconnect from the database using a different thread.
- Connection serialization might not work with a database on a network drive.
- In a JDBC program, the timeout value is ignored and set to zero if it is passed in a property to the DriverManager.getConnection() method.
- DB2 Everyplace allows concurrent database access within the same process (or address space). For example, the connect method in the java.sql.Driver interface supports ENABLE_SHARED_DATABASE_ACCESS, a Boolean property that you can set to true to enable concurrent access. DB2 Everyplace supports similar properties and methods for other languages, such as SHARED_DB_ACCESS for ADO.NET applications, and SQL_DB_SHARED for CLI applications.
Parent topic: Guidelines for locking: XPD621