Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection Pool 1

Status
Not open for further replies.

Hattusas

Programmer
Nov 11, 2001
344
TR
I want to create my connection pool I weblogic gives me error.My database is DB2.
Here are the steps I followed.First I obtained all of the db2 classes and turned them into db2.jar file.I added tihs file as a classpath.Then started BEA weblogic.After that I opened the Bea console.I gave a name to my connection pool.
Ýn URL section I wrote :jdbc:db2://ssipahi:50006/FAQ
where ssipahi is my computer's name.FAQ is my database name.
in driver class I wrote COM.ibm.db2.jdbc.net.DB2Driver.
the password of my database is db2admin with the same user name.When I hit the targets screen and select the server.It gave an error stating that my driver class not loaded.What must I do to overcome this problem? Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Thank you for responses.I solved the problem.The db2.jar file of mine was corrupt then it worked.My connections are now open.
But in fact I don't know the exact syntax how to get my connection into my application.I konw I ought to use getContext method.If you send me syntax of it I will be very pleased. Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
The best way (most standards based) is to wrap the Connection Pool in a JDBC DataSource and then lookup the DataSoure.

To simply answer your question, if you want to directly use the Connection Pool try this code:
Code:
public Connection getConnection(String poolName) throws SQLException, ClassNotFoundException {
  try {
    Class.forName("weblogic.jdbc.jts.Driver").newInstance();
    return DriverManager.getConnection("jdbc:weblogic:jts:"+poolName, null);
  }
  catch(InstantiationException ie) {
    // Error Handling
  }
  catch(IllegalAccessException iae) {
    // Error Handling
  }
}

In case it is not obvious you would then call getConnection and pass as an argument the name of your WebLogic Connection Pool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top