tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dori <dorian.cus...@googlemail.com>
Subject Using DBCP DataSource w/ Tomcat 6
Date Fri, 17 Jul 2009 15:23:25 GMT

Hello again. Ive managed to get this working, which took a bit of time, but
im a little confused on how to do it more efficently. I currenty access my
mysql db through a servlet with the follwing code

InitialContext initCtx = new InitialContext();
    			Context envCtx = (Context) initCtx.lookup("java:comp/env");
    			DataSource ds = (DataSource)envCtx.lookup("jdbc/mainDB");
    			con = ds.getConnection();

ive seen bits of code of the web which use factorys and /or singleton
classes for this. Im sure 3 or 4 lines can be cut out of the code that
should be called everytime the servlet is called. Any advice would be
helpful!
-- 
View this message in context: http://www.nabble.com/Using-DBCP-DataSource-w--Tomcat-6-tp24536575p24536575.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message