aspose file tools*
The moose likes Servlets and the fly likes Connection Pool/App Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Connection Pool/App Server" Watch "Connection Pool/App Server" New topic
Author

Connection Pool/App Server

Pamela Heaton
Greenhorn

Joined: Nov 25, 2002
Posts: 2
Hi, I am developing an internal company system for entering and tracking orders. I am using JSP and Servlets using Tomcat. There will be about 30 users using this software constantly - do I need a connection pool and if so do you know where I can get this for free.
Is is realistic to write this kind of software and run on Tomcat or should I try to get my company to invest in an Application Server?
Any advice would be appreciated
Thank you
Pamela
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I believe that Tomcat has basic connection pooling functionality built in, but if it doesn't DBConnectionBroker is free.


Matthew Phillips
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Which is better? Tomcat's connectionpool or the free ones on net (book)?
Anyway, I can't find anywhere which teaches us how to implement connectionpool in tomcat.


Thanks everyone who helped me
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

The connection pool included with newer versions of Tomcat would be jakarta's "commons" project's "DBCP"

http://jakarta.apache.org/commons/dbcp.html

I've used this and it worked fine. Mind you the app was never under a lot of stress. But I'd give this one a try before anything else. And my own opinion would be to use what others have worked on (why re-invent the wheel?)
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
There is an example of using it in Tomcat here.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Seems quite complex than just adopting a connectionPool.java on the net huh?
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
you could also try connection pooling in apache jakarta turbine.
Narsimha Manekar
Ranch Hand

Joined: Mar 05, 2001
Posts: 35
Originally posted by Matthew Phillips:
There is an example of using it in Tomcat here.

Hi Mr.Phillips
Here is my Working Environment:
Windows 2000 Professional
J2SDK 1.4
Tomcat 4.0.6
mysql server version: 4.1.0-alpha ( on linux server)
JDBCdriver mysql-connector-java-3.0.8-stable-bin.jar
I am trying to implement connection pooling as described in
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/printer/jndi-datasource-examples-howto.html#MySQL%20DBCP%20Example
After modifying server.xml, web.xml and creating connection class and jsp, I start Tomcat through the short-cut which executes startup.bat file. This pops-up tomcat console with all error messages and when I execute shutdown.bat file this window doesn't even close.
Could you successfully implement connection pooling as described in above link, if so I would like to know what I am missing?
Thank you in advance.
Rao Manekar
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Whichever way you go, realize the following.
When desiging a web app as you have described, it is ALWAYS better to use a pool. I suggest that you ALWAYS get that pool from JNDI as a javax.sql.DataSource object. Many, many other APIs, tools and products are designed to work with either a java.sql.Connection or a javax.sql.DataSource. You use web.xml to define the name of the DataSource you want (via a <resource-ref> tag) and your code is good to go.
All that gives you is a .war file that fits the standard. Your code will use an existing DataSource, but not configure one. The configuration of the DataSource is done one of two ways. In a server specific way, you define a DataSource. With tomcat this is done in the server.xml file (last I checked anyway). With many other J2EE servers, there is a GUI to do this (there may be one with Tomcat now). Tomcat does use the Jakarta Commons classes to do this. The other way is to have your app create the connection. This is not recommneded, but once the DataSource is up and running, it works the same way.
Narsimha Manekar
Ranch Hand

Joined: Mar 05, 2001
Posts: 35
Dear Kenneth Robinson
Thanks for your reply. I still did not get answer to my problem.
I gave up working using JNDI.
Anyway, I was able to implement connection pooling using coreservlets utility very easily. It is very simple and straigth forward.
http://archive.coreservlets.com/Chapter18.html
Rao
 
Consider Paul's rocket mass heater.
 
subject: Connection Pool/App Server