Hi There, I'm running Tomcat 4.1.30.  When I put the Resource and ResourceParams 
elements in the Context element of my webapp, it seems to work fine, but when I move 
it to the GlobalNamingResources element and point to it using a ResourceLink, it 
doesn't seem to work giving me an exception saying that the driver class is null. 
Here's my Resource in the GlobalNamingResources:  <Resource name="jdbc/myoracle" 
auth="Container" scope="Shareable"              type="javax.sql.DataSource" />  
<ResourceParams name="jdbc/myoracle">   <parameter>     <name>factory</name>     
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>   </parameter>   
<parameter>     <name>driverClassName</name>     
<value>oracle.jdbc.driver.OracleDriver</value>   </parameter>   <parameter>     
<name>url</name>     <value>jdbc:oracle:thin:@MY_DB_URL</value>   </parameter>   
<parameter>     <name>username</name>     <value>MY_USER_NAME</value>   </parameter>   
<parameter>     <name>password</name>    
 <value>MY_PASSWORD</value>   </parameter>   <parameter>     <name>maxActive</name>    
 <value>30</value>   </parameter>   <parameter>     <name>maxIdle</name>     
<value>10</value>   </parameter>   <parameter>     <name>maxWait</name>     
<value>60000</value>   </parameter>   <parameter>     
<name>removeAbandonedTimeout</name>     <value>60</value>   </parameter>   <parameter> 
    <name>logAbandoned</name>     <value>true</value>   </parameter> </ResourceParams> 
 And here's my ResourceLink nested in my Context:           <ResourceLink 
name="jdbc/myoracle" global="jdbc/myoracle"                        
type="javax.sql.DataSource"/> 

Here's my entry in my web.xml

  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/myoracle</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>

and here's my java code to get a connection


Context ctx = new InitialContext();





Object obj = ctx.lookup("java:comp/env/jdbc/myoracle");

DataSource ds = (DataSource)obj;



return ds.getConnection();


Like I mentioned, the code works when the resource is nested inside

the context, but when I replace it with the resource link like above

and move it up to the global naming resources, it doesn't work. 

Any suggestions?


                
---------------------------------
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

Reply via email to