This discussion is archived
1 Reply Latest reply: Mar 25, 2012 3:41 PM by 164415 RSS

Poolmanager and datasource

919818 Newbie
Currently Being Moderated
Hi,

I have a question about using datasource in a WebLogic server and Poolmgr.
I would like to create a pool manager which uses a datasource (created in a WebLogic server) , how could I do that?

This is my code example:
....
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, JboContext.JBO_CONTEXT_FACTORY);
props.setProperty(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);

pool = PoolMgr.getInstance().createPool(
className,
packageName,
"mydatasourcename",
conn.getClientInfo()
);
...

The problem is that it can not find the "mydatasourcename"

Best Regards
Key1
  • 1. Re: Poolmanager and datasource
    164415 Oracle ACE
    Currently Being Moderated
    I'm not sure what the PoolMgr class is doing to lookup the datasource or how it's meant to operate.

    Is the PoolMgr a class from ADF/BC4J as the properties allude to? If so, then your question might be better addressed to the JDeveloper/ADF forum.

    In general terms, if you want to use a WebLogic DataSource, you're going to need to get it from the WebLogic Server JNDI tree by connecting and authenticating to the desired WebLogic target.

    There's examples in the documentation of doing this:

    http://docs.oracle.com/cd/E17904_01/web.1111/e13726/programming.htm#i1023868
    Context ctx = null;
      Hashtable ht = new Hashtable();
      ht.put(Context.INITIAL_CONTEXT_FACTORY,
             "weblogic.jndi.WLInitialContextFactory");
      ht.put(Context.PROVIDER_URL,
             "t3://hostname:port");
      Connection conn = null;
      Statement stmt = null;
      ResultSet rs = null;
      try {
        ctx = new InitialContext(ht);
        javax.sql.DataSource ds 
          = (javax.sql.DataSource) ctx.lookup ("myDataSource");
        conn = ds.getConnection();
       // You can now use the conn object to create 
       //  Statements and retrieve result sets:
        stmt = conn.createStatement();
        stmt.execute("select * from someTable");
        rs = stmt.getResultSet(); 
    ...
    //Close JDBC objects as soon as possible
        stmt.close();
        stmt=null;
        conn.close();
        conn=null;
     }
    ...
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points