Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Servlet Interest »

DataSource Question

Jack Lauman

2004-08-29

Replies:

I'm using the following code in a servlet to get a JDBC connection:

Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DBNameDS");
Connection conn = ds.getConnection();

It works fine... but I would like to be able to substitute "DBNameDS"
with the actual name of the ds as defined in the web.xml file.

How can this be done?

Jack

___________________________________________________________________________
To unsubscribe, send email to listserv@(protected)
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
©2008 junlu.com - Jax Systems, LLC, U.S.A.