We're trying to use Oracle proxy user authentication on a data source configured in WebLogic 10.3.6, however, we want to approach it in a programatic way. So we want to obtain the DataSource, and set the proxy related properties inside the application.
We came up with the following snippet:
Hashtable<String, Object> env = new Hashtable<String, Object>();
Context context = new InitialContext(env);
javax.sql.DataSource ds = (javax.sql.DataSource) context.lookup("ds_puser");
OracleConnection oconn = (OracleConnection) ds.getConnection();
The problem comes up when we try to cast the connection to OracleConnection, the thing is that the returned type is actually a 1036_WLStub.
How can we avoid that type or cast to it to something useful? I found this reference on Oracle forums and he's being able to cast it directly: Re: My problem in using weblogic Datasource and proxy user
Can someone help us out?
Thanks a lot in advance!
Edited by: 990800 on 27-feb-2013 13:26
Hi. An external client to WebLogic will never get a concrete driver class. It can
only get a proxy for the real connection that is back in the WLS engine. You
should be able to cast the proxy to any public Interface the original connection
implements, or any documented WebLogic.jdbc extension, but again, it can
never be the actual object.
A DataSource is an Interface. What the code gets from the jndi tree is some concrete object that
the code doesn't need to know the name of, or anything specific about it, as long as it implements
the DataSource Interface, which it successfully casts to, to allow calling the methods defined in the
DataSource Interface. If you call for a plumber, you don't need to know his name as long as you
can get a plumber, and can call the "Fix this leak" method, defined in the Plumber Interface.