3 Replies Latest reply: Jun 17, 2010 12:21 PM by 757905 RSS

    My problem in using weblogic Datasource and proxy user

    TakhteJamshid
      Hello

      I create a DataSource in Weblogic that connect to the database by a proxy user and I have a client application that use this DataSource and create a proxy session , I've written my client application (it's a stand alone client application) code below :

      -----------------------------------------------------------
      public static void main(String [] args) {
      OracleConnection conn=null;
      javax.sql.DataSource ds=null;
      Hashtable env = new Hashtable();
      env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
      env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");


      try{
      Context context=new InitialContext( env );
      ds=(javax.sql.DataSource) context.lookup ("OracleConnection2");
      conn=(OracleConnection) ds.getConnection();
      java.util.Properties prop = new java.util.Properties();
      prop.put(OracleConnection.PROXY_USER_NAME, "web_user1");
      prop.put(OracleConnection.PROXY_USER_PASSWORD,"web_user1");
      conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);

      if (conn.isClosed()){
      System.out.println("Connection closed");
      return;
      }
      testJDBC(conn,true);
      for(int k=0;k<10;k++){
      testJDBC(conn,false);
      }
      conn.close(OracleConnection.PROXY_SESSION);
      conn.close();
      }catch(Exception ex){
      ex.printStackTrace();
      }

      -----------------------------------------------------------

      It works but my problem is that in line "prop.put(OracleConnection.PROXY_USER_PASSWORD,"web_user1")" or line "prop.put(OracleConnection.PROXY_USER_NAME, "web_user1");"
      Let me to mention a scenario :

      *1- I type a wrong username or password in my client application and I run the client application it shows me this error : invalid username/password*
      *this error is acceptable*

      *2- then I correct the wrong username or password immediately and run the application again , it shows me this error (at line conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop)) :*

      java.sql.SQLException: Closed Connection
           at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
           at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
           at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.openProxySession(Unknown Source)
           at weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.openProxySession(Unknown Source)
           at oracle.HRFacadeClient.main(HRFacadeClient.java:38)

      *3- I run the application again (by correct username and password) but this time it shows me this error :*

      java.sql.SQLException: Unsupported feature
           at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
           at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
           at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.openProxySession(Unknown Source)
           at weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.openProxySession(Unknown Source)
           at oracle.HRFacadeClient.main(HRFacadeClient.java:38)


      *4 - if I repeat running the application for multi times every time it shows me the previous error*

      *5- I wait about one minute the problem solved and my application can create proxy session *


      the result is that if I wanna create proxy session by wrong username or password and I get "Invalid username/password" error message , then after correcting username or password I have to wait about one minute and then run the application again_

      Do you know how I can overcome this problem ?

      Thank you