You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jack Lauman <jl...@nwcascades.com> on 2004/08/29 23:29:22 UTC

DataSource Question

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, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: DataSource Question

Posted by Big Chiz <bi...@gmail.com>.
there can be two things to change: if ur using tc5 you can change your
dbcp resource via yourcustomapp.xml (conf/catalina/localhost/)

  <Resource name="jdbc/yourcustomname" auth="Container"
type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/yourcustomname">
    <parameter>

and then in your web.xml

<param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
            <param-value>jdbc/yourcustomname</param-value>
 

On Sun, 29 Aug 2004 14:29:22 -0700, Jack Lauman <jl...@nwcascades.com> wrote:
> 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, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

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