Thanks Bryan,
I tried using the IBM JCC driver but it seems that the feature is not
implemented there. I used setDriverType method of DB2XADataSource to
specify the driver type 4 which only seems to work to connect to derby.
Is it possible that I am doing something wrong?
I used the following code to query the functionality
(setTransactionTimeout should return false if the feature is not supported):
try {
XAConnection xaConn =
createXAConnection("jdbc:derby:net://localhost:1527/TestDB;create=true",
"julo", "julo");
XAResource xaRes = xaConn.getXAResource();
if (xaRes.setTransactionTimeout(10)) {
System.out.println("Supports XA transaction timeout.");
} else {
System.out.println("Does not support XA transaction
timeout.");
}
System.out.println("XA transaction timeout: " +
xaRes.getTransactionTimeout());
} catch (Throwable t) {
t.printStackTrace();
}
and the following code to create an XAConnection object:
public static XAConnection createXAConnection(String dbUrl, String
username, String password) throws Exception {
Class dataSourceClass =
Class.forName("com.ibm.db2.jcc.DB2XADataSource");
XADataSource dataSourceInstance = (XADataSource)
dataSourceClass.newInstance();
Class [] stringParam = new Class [] {String.class};
dbUrl = dbUrl.substring("jdbc:derby:net://".length(),
dbUrl.length());
String [] array1 = dbUrl.split("/");
String [] array2 = array1[0].split(":");
String serverName = array2[0];
int portNumber = Integer.valueOf(array2[1]).intValue();
String databaseOrSchemaName = array1[1];
dataSourceClass.getMethod("setServerName",
stringParam).invoke(dataSourceInstance, new Object [] {serverName});
dataSourceClass.getMethod("setPortNumber", new Class []
{int.class}).invoke(dataSourceInstance, new Object [] {portNumber});
dataSourceClass.getMethod("setDatabaseName",
stringParam).invoke(dataSourceInstance, new Object []
{databaseOrSchemaName});
dataSourceClass.getMethod("setDriverType", new Class []
{int.class}).invoke(dataSourceInstance, new Object [] {4});
if (username.length() > 0)
dataSourceClass.getMethod("setUser",
stringParam).invoke(dataSourceInstance, new Object [] {username});
if (password.length() > 0)
dataSourceClass.getMethod("setPassword",
stringParam).invoke(dataSourceInstance, new Object [] {password});
return dataSourceInstance.getXAConnection();
}
Thanks,
Julo
Bryan Pendleton wrote:
requires that when the function is called before any call to
setTransactionTimeout it should return the default value of the
resource manager. I have not found any DRDA term which can be
directly used to obtain the default value from the server.
Is this functionality implemented in the IBM JCC driver?
If so, you could run a test program using the JCC driver against Derby,
and instrument your Derby server to see what DRDA traffic the JCC
driver sends to Derby.
thanks,
bryan