THAT was a GOOD example -- thankx a lot .. :)
Mayuresh
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Panayotou, Michael
Sent: Friday, June 15, 2001 2:56 PM
To: [EMAIL PROTECTED]
Subject: Re: Who know how to create a "Connection Pool" in Java?
This is an example
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
/**
* Insert the type's description here.
* Creation date: (28/12/2000 3:05:03 µµ)
* @author: Administrator
*/
public class TestServlet extends HttpServlet {
private static DataSource ds = null;
private static Connection dbConnection1 = null;
private static Connection dbConnection2 = null;
private static boolean connected = false;
private static ConnectionPoolDataSource cpds = null;
private static PooledConnection pdbConnection = null;
/**
* Process incoming HTTP GET requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
}
/**
* Process incoming HTTP POST requests
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
}
/**
* Returns the servlet info string.
*/
public String getServletInfo() {
return super.getServletInfo();
}
/**
* Initializes the servlet.
*/
public void init() {
// insert code to initialize the servlet here
try{
String datasourceName = "jdbc/TestWEBNT";
String username = "test";
String password = "test";
System.out.println("1");
Hashtable parms = new Hashtable();
System.out.println("2");
parms.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
System.out.println("3");
Context ctx = new InitialContext(parms);
System.out.println("4");
// cpds = (DataSource) ctx.lookup(datasourceName);
ds = (DataSource) ctx.lookup(datasourceName);
System.out.println("5");
// pdbConnection = cpds.getPooledConnection(username,
password);
// dbConnection1 = pdbConnection.getConnection();
// dbConnection2 = pdbConnection.getConnection();
dbConnection1 = ds.getConnection(username,password);
dbConnection2 = ds.getConnection(username,password);
System.out.println("6");
connected=true;
System.out.println("7");
} catch(Exception e){
System.out.println("[init 1]:" + e);
}
try{
Statement stmt = dbConnection1.createStatement();
ResultSet rset = stmt.executeQuery("select
userenv('sessionid') from dual");
while(rset.next()){
System.out.println(rset.getString(1));
}
stmt.close();
} catch(Exception e){
System.out.println("[init 2]:" + e);
}
try{
Statement stmt2 = dbConnection2.createStatement();
ResultSet rset2 = stmt2.executeQuery("select
userenv('sessionid') from dual");
while(rset2.next()){
System.out.println(rset2.getString(1));
}
stmt2.close();
} catch(Exception e){
System.out.println("[init 2]:" + e);
}
}
/**
* Process incoming requests for information
*
* @param request Object that encapsulates the request to the servlet
* @param response Object that encapsulates the response from the servlet
*/
public void performTask(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) {
try
{
// Insert user code from here.
}
catch(Throwable theException)
{
// uncomment the following line when unexpected exceptions
// are occuring to aid in debugging the problem.
//theException.printStackTrace();
}
}
}
Regards
Michael Panagiotou
-----Original Message-----
From: Mayuresh Kadu [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 15, 2001 11:14 AM
To: [EMAIL PROTECTED]
Subject: Re: Who know how to create a "Connection Pool" in Java?
has anyone played around with Poolman !? That also seems to be a good
product ~
Mayuresh
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Haseltine, Celeste
Sent: Wednesday, June 13, 2001 9:13 PM
To: [EMAIL PROTECTED]
Subject: Re: Who know how to create a "Connection Pool" in Java?
Rohit, Mayuresh,
There are a number of textbooks out on the market that describe how to
create your own connection pool class bean, or even a servlet. I much
prefer to use a third party driver which already has connection pooling, and
then creating a singleton class surrounding the third party driver to
instantiate connections and hand them off from within the driver's pool to
the JSP, or even another class bean, and then returning that connection back
to the singleton class, which in turn releases the connection back to the
driver's pool. Extending your own java class beans from
PropertyChangeListener, you can fire events from your own beans attached to
the JSP, and have your singleton classes listen for those events relating to
request for a connection from the pool, and releasing a connection to be
returned to the pool.
Take a look at Professional JSP by Wrox Press. This book has some good
examples of connection pooling, and developing a singleton class to manage
your connection pool.
Celeste
-----Original Message-----
From: Mayuresh Kadu [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 4:15 AM
To: [EMAIL PROTECTED]
Subject: Re: Who know how to create a "Connection Pool" in Java?
I am yet to start writing them towards connection pooling .. will keep u
posted :)
Mayuresh
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of kuttappan
Sent: Monday, June 11, 2001 9:22 PM
To: [EMAIL PROTECTED]
Subject: Re: Who know how to create a "Connection Pool" in Java?
I have decided to take the idea of writing my existing beans in such a way
that currently they will use Connection Pooling.
I would like to see your code and learn how to use Connection Pooling with
beans.
Thanks,
Rohit.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
=========================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=P
http://www.jguru.com/jguru/faq/faqpage.jsp?name=rvlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets