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);
Poznámky:
Související úlohy