This content has been marked as final. Show 14 replies
Actually a new constructor of Oracle.java that accepts Connection object has already been implemented. It will be part of next release.
Any idea when the next release will be made available? Thanks,
Should be soon. We will post a message once a new version is put on OTN.
In the Oracle Jena Adaptor 2 Javadoc API, I see there is an Oracle ctor: Oracle(OracleConnection connection), but no ctor for java.sql.Connection. I'm using Apache DBCP to get a data source. The Connection I get back from the data source is actually a pooled connection wrapper (org.apache.commons.dbcp.cpdsadapter.ConnectionImpl). The connection wraps the Oracle connection (in this case oracle.jdbc.driver.T4CConnection). Any suggestions?
What application server are you using?
If you are using Tomcat, you should configure the datasource using the parameters:
driverClassName="oracle.jdbc.OracleDriver" (is important, you must use this and not oracle.jdbc.driver.OracleDriver)
then in your code
org.apache.tomcat.dbcp.dbcp.DelegatingConnection delegatedConnection = (org.apache.tomcat.dbcp.dbcp.DelegatingConnection) conn;
OracleConnection connection=(OracleConnection) delegatedConnection.getInnermostDelegate();
hope it works
If the above suggestion works, then great. I don't have a Tomcat to try it out.
If not or you have some other concerns, then I can certainly try to use Connection class directly
in Jena Adaptor code.
Zhe Wu (Aka. Alan Wu)
Sorry for duplicate message. See next in thread. -Scott
Edited by: skagelsM3t4 on Nov 20, 2008 5:29 PM
Thanks for suggestion. Unfortunately, I'm not using Tomcat. Or more specifically, I cannot guarantee that the code will be running under Tomcat. There should be a way to do this with
Apache DBCP API only, right (I want to stay away from app server specific solutions)? But I can't figure it out. Unfortunately, I'm not an Apache DBCP guru either. Here is what I've tried but I can't get a org.apache.commons.dbcp.DelegatingConnection back. It is probably more appropriate to post this to the DBCP mailing list. I will try them as well but figured perhaps someone here might know.
Registering data source in JNDI:
String bindName = "myOracleDS";
// ConstructOracle Connection Pool DataSource reference
Reference ocpdsRef = new Reference(
ocpdsRef.add(new StringRefAddr("driver", "oracle.jdbc.OracleDriver"));
ocpdsRef.add(new StringRefAddr("url", url));
ocpdsRef.add(new StringRefAddr("user", user));
ocpdsRef.add(new StringRefAddr("password", password));
// Construct SharedPoolDataSource reference
Reference ref = new Reference(
ref.add(new StringRefAddr("dataSourceName", bindName));
// Set remaining properties
ref.add(new StringRefAddr("maxActive", maxIdle));
ref.add(new StringRefAddr("maxIdle", maxIdle));
ref.add(new StringRefAddr("maxWait", maxWait));
ref.add(new StringRefAddr("testOnBorrow", testOnBorrow));
ref.add(new StringRefAddr("validationQuery", validationQuery));
ref.add(new StringRefAddr("testOnReturn", testOnReturn));
Lookup/Retrieving data source:
InitialContext ic = new InitialContext();
Object obj = ic.lookup(config.dataSourceName);
SharedPoolDataSource ds = (SharedPoolDataSource) obj;
Connection conn = ds.getConnection();
// conn is type oracle.jdbc.driver.LogicalConnection - doesn't look like I can get OracleConnection from this.
// Can't cast conn to DelegatingConnection - missing link to do the following:
// DelegatingConnection delConn = (org.apache.dbcp.DelegatingConnection)conn;
// OracleConnection oraConn = (OracleConnection) delConn.getInnermostDelegate();
// return new Oracle(oraConn);
I am looking into this issue right now and will keep you posted. Behind the scene, the Jena Adaptor uses Oracle's JDBC batching and ClOB API.
It is a bit involved to change the logic ... We will see how it goes.
Please email alan dot wu at oracle dot com. I will need you to verify the new logic because I don't have similar setup on my machine.
Zhe Wu (Aka. Alan Wu)
I should explain that my main goal is to use a pooled connection with the Jena Adaptor and I am having a hard time figuring out how to do so. I need an OracleConnection object that is really a pooled connection or Oracle should support a constructor Oracle(java.sql.Connection). Part of the challenge is also figuring out how to correctly create/configure the pooled DataSource object (data source that gets a pooled connection).
If you can get oracle.jdbc.driver.LogicalConnection consistently (or app server independently), then it seems that it is possible to get OracleConnection from it.
So that LogicalConnection object you get is of type oracle.jdbc.OracleConnection. You should not have problem
The above is a fyi only. I understand that having a constructor that takes a java.sql.Connection is more universal.
Sorry, this was a class loader issue. I can cast the inner most connection delegate to oracle.jdbc.OracleConnection now.
Edited by: skagelsM3t4 on Nov 21, 2008 2:37 PM
:) to know it is working out for you. Cheers.