I have got this working recently with an Oracle database.

Here's what I have in server.xml:

...
<GlobalNamingResources>
    <Resource name="my-database" scope="Shareable"
        type="javax.sql.DataSource"/>
    <ResourceParams name="my-database">
      <parameter>
        <name>validationQuery</name>
        <value>select sysdate from dual</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>oracle-password</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:oracle:thin:@server:1521:sid</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>oracle.jdbc.driver.OracleDriver</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>oracle-user</value>
      </parameter>
    </ResourceParams>
</GlobalNamingResources>
...

I then deploy my web app ensuring it has a META-INF/context.xml file as
follows:

<Context path="/demo" debug="0" privileged="true">
    <ResourceLink name="jdbc/mydatabase" global="my-database" 
        type="javax.sql.DataSource"/>    
</Context>

My web app can then use the data source with a JNDI name of
"jdbc/mydatabase". 

I deploy my web app through via Ant (using the deploy task found in
catalina-ant.jar). I don't think the context.xml gets picked up if you
were to just drop the WAR file in webapps.

Cheers,
Jon


On Tue, 2003-03-11 at 06:39, Fredrik Larsson wrote:
> Hi all.
> 
> I'm trying to set up a global DataSource on my Tomcat 4.1.18 standalone to
> be available to all of my applications installed on the server.
> 
> But... I just can't get this to work. I've been following the instructions
> in the tomcat documentation but it doesn't help.
> 
> I can start the server without any problems and view the global datasource
> in the Administration Tool but as soon as I'm trying to access the
> datasource from a servlet i get the following exception:
> java.sql.SQLException: Cannot load JDBC driver class 'null'.
> 
> I've tried to set up the datasource for just one application context and
> that works... but that's not what I want.
> 
> Another thing is that when I'm trying to view the datasources for one
> specific application-context that should use this global datasource I get
> this exception:
> org.apache.jasper.JasperException: Exception retrieving attribute
> 'driverClassName'
> 
> Has anyone got a clue?
> 
> Thanks!
> /Fredrik
> 
> 
> This is what my conf-files look like:
> 
> SERVER.XML
>   <GlobalNamingResources>
> 
>     <Resource   name="jdbc/MyDB"
>                 auth="Container"
>                 type="javax.sql.DataSource"/>
> 
>     <ResourceParams name="jdbc/MyDB">
>         <parameter>
>             <name>factory</name>
>             <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>         </parameter>
> 
>         <parameter>
>             <name>maxActive</name>
>             <value>100</value>
>         </parameter>
> 
>         <parameter>
>             <name>maxIdle</name>
>             <value>30</value>
>         </parameter>
> 
>         <parameter>
>             <name>maxWait</name>
>             <value>10000</value>
>         </parameter>
> 
>         <parameter>
>             <name>username</name>
>             <value>myusername</value>
>         </parameter>
>         <parameter>
>             <name>password</name>
>             <value></value>
>         </parameter>
> 
>         <parameter>
>             <name>driverClassName</name>
>             <value>org.gjt.mm.mysql.Driver</value>
>         </parameter>
> 
>         <parameter>
>             <name>url</name>
>             <value>jdbc:mysql://localhost:3306/mydb</value>
>         </parameter>
>     </ResourceParams>
> 
>   </GlobalNamingResources>
> 
> WEB.XML
>     <resource-ref>
>         <description>DB Connection</description>
>         <res-ref-name>jdbc/MyDB</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
> 
> 
> ---------------------------------------------------------------------
> 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