You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Isabel Lameda <IL...@bancofederal.com> on 2002/09/02 18:34:31 UTC

Data Base Connection

Hi all!

I have 2 web applications that runs in my Tomcat 4.1.8 server.
Every thing works fine if i run only one of the two applications.
If i run one application and then the other i get this exception

org.apache.jasper.JasperException: Native Library
C:\oracle\ora81\bin\ocijdbc8.dll already loaded in another classloader

I´m trying to create a data source to solve this problem,
i´ve done all i found in tomcat-docs:

1. Create the data source 

<Resource name="jdbc/myoracle" auth="Container"
              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:oci8:myschema@127.0.0.1:1521:mysid</value>
  </parameter>
  <parameter>
    <name>username</name>
    <value>scott</value>
  </parameter>
  <parameter>
    <name>password</name>
    <value>tiger</value>
  </parameter>
  <parameter>
    <name>maxActive</name>
    <value>20</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>10</value>
  </parameter>
  <parameter>
    <name>maxWait</name>
    <value>-1</value>
  </parameter>
</ResourceParams>

2. Configure web.xml (i added this line)
<resource-ref>
 <description>Oracle Datasource example</description>
 <res-ref-name>jdbc/myoracle</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

3. I have a bean that creates a connection like this

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

The problem is that the connection whit my oracle data base
cannot be creates because i get this execption:

java.sql.SQLException: Cannot load JDBC driver class 'null'

I don´t know if the problem is with the bean or with the server.xml or with
both

How can i check if the Data source is working fine since i found nothing
in the log files.

Thanks in advance

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Data Base Connection

Posted by Rosdi bin Kasim <ro...@epantai.com.my>.
Search the archives.
I posted an example how to setup a datasource for oracle database (but it
was using tomcat 4.1.9).
Btw, try to upgrade to tomcat 4.1.9, it has some bug fixes regarding JNDI
and datasource.


----- Original Message -----
From: "Isabel Lameda" <IL...@bancofederal.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, September 03, 2002 12:34 AM
Subject: Data Base Connection


Hi all!

I have 2 web applications that runs in my Tomcat 4.1.8 server.
Every thing works fine if i run only one of the two applications.
If i run one application and then the other i get this exception

org.apache.jasper.JasperException: Native Library
C:\oracle\ora81\bin\ocijdbc8.dll already loaded in another classloader

I´m trying to create a data source to solve this problem,
i´ve done all i found in tomcat-docs:

1. Create the data source

<Resource name="jdbc/myoracle" auth="Container"
              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:oci8:myschema@127.0.0.1:1521:mysid</value>
  </parameter>
  <parameter>
    <name>username</name>
    <value>scott</value>
  </parameter>
  <parameter>
    <name>password</name>
    <value>tiger</value>
  </parameter>
  <parameter>
    <name>maxActive</name>
    <value>20</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>10</value>
  </parameter>
  <parameter>
    <name>maxWait</name>
    <value>-1</value>
  </parameter>
</ResourceParams>

2. Configure web.xml (i added this line)
<resource-ref>
 <description>Oracle Datasource example</description>
 <res-ref-name>jdbc/myoracle</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

3. I have a bean that creates a connection like this

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

The problem is that the connection whit my oracle data base
cannot be creates because i get this execption:

java.sql.SQLException: Cannot load JDBC driver class 'null'

I don´t know if the problem is with the bean or with the server.xml or with
both

How can i check if the Data source is working fine since i found nothing
in the log files.

Thanks in advance

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>