Connection serialization

You can have only one connection at a time to a DB2 Everyplace database. On all platforms except Palm, DB2 Everyplace supports connection serialization. With connection serialization, the connection requests to a data source are serialized. Only one active connection can be made to a given data source at a time. The other connection requests are put into a queue. The timeout period can be set using the SQL_ATTR_LOGIN_TIMEOUT attribute of the SQLSetConnectAttr() function. Typical serialization scenarios include:

As an example, the following CLI /JDBC calls will set the connection timeout period to10. That is, the application will receive an error if there is another connection to the same database.

For CLI:

 int i = 10; // 10 seconds timeout
rc = SQLSetConnectAttr(hdbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) i, 0); 

For JDBC:

int waitTime = 10; 
String url = "jdbc:db2e:mysample"; 
Properties prop = new Properties(); 
prop.setProperty("LOGIN_TIMEOUT", Integer.toString(waitTime)); 
Connection con = driver.connect(url,prop); 
 

ΑΦ:

  1. The default timeout period is 0 second.

  2. A multi-thread application may connect to a database using one thread and disconnect from the database using a different thread.

  3. A file named 'DSYLOCK' will be created when an application successfully connects to a database. If the application process terminates abnormally, the file DSYLOCK will be removed automatically.

  4. Limitation: connection serialization may not work for database residing on network drive.

  5. In a JDBC program, The timeout value will be ignored and set to zero if it is passed in a property to the DriverManager.getConnection() method.

Related tasks