connection pooling
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marika_Ludmann
Posted On:   Saturday, November 22, 2003 03:53 PM

I am using Tomcat 4.1 to develop a web application. The application currently uses standard Database connection, but I need to improve this and switch to connection pooling. Presently the Connection is created in the beans, like Class.forName .... con = DriverManager.getConnection .... I read up a bit on Tomcat 4.1, which says that it provides the Commons DBCP for connection pooling. However before I can use this I need to set some staff in the server.xml and web.xml files. So far I understand. If after modifying the above mentioned files, can I just modify each bean by replacing the Class.forName etc code with ? Context ctx = new InitialContext(); ... DataSource ds = (DataSourc   More>>

I am using Tomcat 4.1 to develop a web application. The application currently uses standard Database connection, but I need to improve this and switch to connection pooling. Presently the Connection is created in the beans, like

			Class.forName ....
			
con = DriverManager.getConnection ....


I read up a bit on Tomcat 4.1, which says that it provides the Commons DBCP for connection pooling. However before I can use this I need to set some staff in the server.xml and web.xml files.



So far I understand. If after modifying the above mentioned files, can I just modify each bean by replacing the Class.forName etc code with ?
			
Context ctx = new InitialContext();
...
DataSource ds = (DataSource)ctx.lookup(...)
...
Connection con = ds.getConnection();

If I replace the code with the above code in each bean would this not mean that I open and close the connection each time?




Another question I have is that if I want to use the BasicDataSource class of the DBCP do I still have to configure the server.xml and web.xml files? Why do I have to do these steps and not just use the .jar files?



Can anyone help?

Thank you, Marika Ludmann    <<Less
About | Sitemap | Contact