I am writing a web application using servlets and JSP's.I am using IBM's
Websphere application server, and VisualAge for Java.I need some help with
connection pooling.The servlet accesses an Oracle database using JDBC 2.0.I
found the following code on the IBM website.
Could I use this form of connection pooling with Oracle?

The datasource object is initailised once in the init method, and reused
when needed ( the datasource object is a global variable):

private javax.sql.DataSource ds = null;

public void init(ServletConfig config) throws ServletException
{
 super.init(config);
 Context ctx = null;
 try {
      java.util.Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
      ctx = new InitialContext(env);
      ds =(javax.sql.DataSource)ctx.lookup("jdbc/sample");
      ctx.close();
     } catch (Exception es)
      {
      }
}


In the doPost method the connection is obtained and used:

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
 Connection conn = null;
 ResultSet rs = null;
 PreparedStatement pStmt = null;

try{
     String info = null;
     conn = ds.getConnection("db2admin","db2admin");
     pStmt = conn.prepareStatement("select * from db2admin.employee");
     rs = pStmt.executeQuery();
..
..
...
..

Any help would be greatly appreciated.




********************************************************************

This message may contain information which is confidential and subject to legal 
privilege. If you are not the intended recipient, you may not peruse, use, 
disseminate, distribute or copy this message. If you have received this message in 
error, please notify the sender immediately by email, facsimile or telephone and 
return and/or destroy the original message.

*******************************************************************

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to