tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dori <>
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
View this message in context:
Sent from the Tomcat - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message