I'm trying to get a java.sql.Connection from a DSRequest. I've read the javadocs for RPCManager and SQLTransaction, but none of the methods seem to be working for me. Here's a utility method that I have started, but doesn't work:
Am I doing something wrong here? Or is there an easier method for this?
Code:
public static Connection getConnection(final DSRequest dsRequest) throws Exception { if (!dsRequest.getDataSource().getType().equals("sql")) { throw new IllegalStateException("getConnection() only works on SQL data sources"); } Connection connection = SQLTransaction.getConnection(dsRequest.getRPCManager()); if (connection == null) { connection = dsRequest.getRPCManager().startSQLTransaction(dsRequest); } if (connection == null) { connection = SQLTransaction.getConnection(dsRequest.getRPCManager()); } if (connection == null) { connection = (Connection) dsRequest.getDataSource().getTransactionObject(dsRequest); } return connection; }
Comment