Is the Resource outside or inside your Context ?
It should be inside. 
 

> -----Original Message-----
> From: Cooper, Vickie [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 3:04 PM
> To: [EMAIL PROTECTED]
> Subject: Trying to connect to DB2 usning JNDI
> 
> 
> I have been trying to connect to DB2 but I keep getting the error:
> javax.naming.NameNotFoundException: Name jdbc is not bound in 
> this Context at org.apache.naming.NamingContext.lookup
> My code has:
>   Context initCtx =3D new InitialContext();
>   Context envCtx =3D (Context)initCtx.lookup("java:comp/env");
>   DataSource ds =3D (DataSource)envCtx.lookup("jdbc/DB2");
> 
> My server.xml has:
> <Resource name=3D"jdbc/DB2" auth=3D"Container" = 
> type=3D"javax.sql.DataSource"/> <ResourceParams name=3D"jdbc/DB2">
>      <parameter>
>        <name>factory</name>
>        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>       </parameter>
>       <parameter>
>         <name>maxWait</name>
>         <value>5000</value>
>       </parameter>
>       <parameter>
>         <name>maxActive</name>
>         <value>4</value>
>       </parameter>
>       <parameter>
>         <name>password</name>
>         <value>mypass</value>
>       </parameter>
>       <parameter>
>         <name>url</name>
>         <value>jdbc:db2:DB2</value>
>       </parameter>
>       <parameter>
>         <name>driverClassName</name>
>         <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
>       </parameter>
>       <parameter>
>         <name>maxIdle</name>
>         <value>2</value>
>       </parameter>
>       <parameter>
>         <name>username</name>
>         <value>myuser</value>
>       </parameter>
>     </ResourceParams>
>        <Context className=3D"org.apache.catalina.core.StandardContext"
> cachingAllowed=3D"true" 
> charsetMapperClass=3D"org.apache.catalina.util.CharsetMapper"
> cookies=3D"true" crossContext=3D"false" debug=3D"0" = 
> docBase=3D"C:/Program Files/Apache Group/Tomcat 
> 4.1/webapps/vickie.war" 
> mapperClass=3D"org.apache.catalina.core.StandardContextMapper"
> path=3D"/vickie" privileged=3D"false" reloadable=3D"false" 
> swallowOutput=3D"false" useNaming=3D"true" 
> wrapperClass=3D"org.apache.catalina.core.StandardWrapper">
>         </Context>
> 
> I added this to my web.xml:
> <web-app>
>    <resource-ref>
>       <res-ref-name>jdbc/DB2</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>    </resource-ref>
> 
> I can't find anything wrong...but it won't connect.  I'm 
> using the DB2Client on my pc to connect to the db2 data.  
> This works when I connect with Jrun, so it should be able to 
> find it.  It also works if I
> use:
> Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
> String url=3D  "jdbc:db2:DB2";
> 
> I have copied the db2java.zip to /tomcat/common/lib and 
> renamed it to db2java.jar
> 
> Any ideas why this won't connect?  Is there any way to test 
> the connection for TomCat outside of a servlet...just to 
> verify it can get there?
> 
> Thanks,
> 
> Vickie 
> 
> 
> Vickie Cooper
> OS/390 Web Services & FOCUS/EDA Technical Support
> Phone:  (425) 957-5502
> Email:   [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to