• Post Reply Bookmark Topic Watch Topic
  • New Topic

Weblogic Pool connection Vs JDBC Connection.  RSS feed

 
Raj Sikka
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a CMP Bean and I called ejbCreate() method of my CMP Bean.
(One record is stored in database as my deployment descriptor has the following line
<delay-updates-until-end-of-tx>False</delay-updates-until-end-of-tx>
So it doesn�t waits for ejbStore() to call )
In the very next line I am opening a weblogic pool connection using getConnection() method .
And I am querying the database for the record that I stored using ejbCreate() method.
I am able to see the record.
After that I have opened a ordinary JDBC Connection using setupConnection() method.
And I am querying the database for the record that I stored using ejbCreate() method.
I am not able to see the record. (which is visible using a weblogic pool connection)
All the above are happening in the same transaction ,but why I am not able to see the record
When I use JDBC Connection instead of Weblogic pool connection ?
Pls help.
Here is the code for getting weblogic pool connections and JDBC Connections.
// for getting a connection from a Weblogic connection pool
public static Connection getConnection() throws SQLException
{
try
{
Context context = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,INITIAL_CONTEXT_FACTORY);
ht.put(Context.PROVIDER_URL,PROVIDER_URL);
context = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource)context.lookup(DATA_SOURCE_JNDI_NAME);
return ds.getConnection();
} catch(Exception exp)
{
return null;
}
}

//for getting JDBC Connection directly ,not from pool
public static Connection setupConnection() throws Exception
{
String database_url = "DATABASE_CONNECT_URL";
String database_username = "DATABASE_USERNAME";
String database_password = "DATABASE_PASSWORD";
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
return DriverManager.getConnection(database_url,database_username,database_password);
}

Thanks,
Srikanth
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!