3 Replies Latest reply: Mar 6, 2013 10:06 AM by Joe Weinstein-Oracle RSS

    Weblogic & JNDI Data Source with proxy user.

      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>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      env.put(Context.PROVIDER_URL, "t3://");
      env.put(Context.SECURITY_PRINCIPAL, "weblogic");
      env.put(Context.SECURITY_CREDENTIALS, "weblogic");

      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