jsp connectivity thru connection pooling

some body has idea how to connect jsp page to mysql using connection pooling.
it will be great favor if somebody has code
LTIndiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adrpoCommented:

Hi,

There is come code and explanation here:
http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html

You didn't tell us what application server are you using: Tomcat, etc?
There might be a package in the server that already has this capability.

Cheers,
za-k/
0
Ajay-SinghCommented:
0
mohammedfCommented:
first u need to make a JNDI  resource in ur tomcat server ,, the following XML code will be in server.xml file inside ur server.

then u u can lookup for ur JNDI resource and make ur ordinary work with ur database
here a helpfull website:
http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html
http://www.crazysquirrel.com/computing/java/connection-pooling.jspx
<Context path="/DBTest" docBase="DBTest"
        debug="5" reloadable="true" crossContext="true">
 
  <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="localhost_DBTest_log." suffix=".txt"
             timestamp="true"/>
 
  <Resource 
type="javax.sql.DataSource"
auth="Container"
name="jdbc/TestDB"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
maxActive="100"
maxIdle="30"
maxWait="10000"
username=""
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/oss?autoReconnect=true"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
/>
 
</Context>
 
////////////////////////////
///connection code
///////////////////////////
  private java.sql.Connection connection;
   private Statement statement;
	try{
   
		javax.naming.Context ctx = new javax.naming.InitialContext();
		javax.sql.DataSource ds = (javax.sql.DataSource )ctx.lookup("java:comp/env/jdbc/TestDB"); 
		connection = ds.getConnection();
 
 
         statement = connection.createStatement();
         	}
         	catch (Exception err) {
        FileWriter file=new FileWriter("c:/error.txt");
        file.write(err.toString());
        file.close();
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.