tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Livanov <sergey.liva...@ukrpost.net>
Subject JNDI
Date Wed, 30 Apr 2003 13:56:25 GMT
The procedure to connect to Oracle db with the help of JNDI does not work.

-   I have read the documents.
-   Based on Tomcat JNDI Datasource example, I did the following:

1. I have renamed classes12.zip to classes12.jar;
and copied to subcatalogue home/common/lib

2. Configurated server.xml и web.xml.
 (I work with driverClassName & url data from java applications)

3.  The following lines are working:
>             Context initCtx = new InitialContext() ;
>             Context envCtx = (Context)initCtx.lookup("java:/comp/env" ) ;
>             DataSource ds = (DataSource)envCtx.lookup("jdbc/OFFICE") ;

   Errors occur when:
>        Connection conn = ds.getConnection() ;

What am I doing not correctly? Your assistance is greatly appreciated.


<web.xml>

<resource-ref>
    <description>Oracle DataSource Example</description>
    <res-ref-name>jdbc/OFFICE</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>
<env-entry>
    <env-entry-name>jndi-datasource-name</env-entry-name>
    <env-entry-value>jdbc/OFFICE</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
</env-entry>


    <server.xml>

          <Resource name="jdbc/OFFICE" auth="Container"
                    type="javax.sql.DataSource"/>
          
          <ResourceParams name="jdbc/OFFICE">
            <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>driverName</name>
                 <value>jdbc:oracle:thin:@127.0.0.1:1521:OFFICE</value>
            </parameter>
            <parameter>
                 <name>username</name>
                 <value>sell</value>
            </parameter>
            <parameter>
                 <name>password</name>
                 <value>sell</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>




--
Укрпост - продвинутая почта. http://www.ukrpost.net/
IMAP POP3 NNTP RSSNews Unicode.


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


Mime
View raw message