wood burning stoves
The moose likes Servlets and the fly likes Differences between Connection Pool managers in Weblogic 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Differences between Connection Pool managers in Weblogic 6.0" Watch "Differences between Connection Pool managers in Weblogic 6.0" New topic

Differences between Connection Pool managers in Weblogic 6.0

Owen Nishimura

Joined: Aug 01, 2001
Posts: 2
I'm trying to understand the difference between two ways to get a connection from a Weblogic 6.0 connection pool. I've come across two different ways that we can get a connection from a pool (after it's been created thru the console).
1. Have a connection pool manager with a getConnection method that uses the following code:
Connection conn = null;
Driver myDriver =(Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
Properties props = new Properties();
conn = myDriver.connect("jdbc:weblogic :pool", props);

2. Using JNDI and providing a URL (such as PROVIDER_URL below) for the machine the connection pool is on. The following code could be used in a connection pool manager class too:
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.PROVIDER_URL,"t3://hostname :port");
try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds =(javax.sql.DataSource) ctx.lookup("myJtsDataSource");
java.sql.Connection conn = ds.getConnection();
} catch (Exception ex) {}

Is either method preferable to the other? Or does it not matter?
Are there better methods?
Thanks for your time

[This message has been edited by Owen Nishimura (edited August 01, 2001).]
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
just sharing some thoughts.
Let�s suppose that some day you want to use your ejb�s with some different DB from different vendor, if you got the connection from the first way you post you�re gonna have to change the code from your EJB ok, now if you use DataSource all you need is binding the dataSource environment with the new connection pool you�ve just created and dont need to change anything in your code.
And if you have CMP you don�t even need to use code inside your EJB to get a connection all you have do to is bind your dataSource with your ejb at the weblogic-cmp-rdbms.jar
as I said just my considerations I�d love to hear more opinions about that.
I agree. Here's the link: http://aspose.com/file-tools
subject: Differences between Connection Pool managers in Weblogic 6.0
It's not a secret anymore!