tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <dan...@etrak-plus.com>
Subject Re: Configuring DataSources
Date Thu, 05 Feb 2004 13:52:40 GMT
hey stephan,

I would suggest going thru the faq on setting up a jndi datasorce.

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

start from something that works and work out to what u really want :) thats
what i did.

Daniel Schulken


----- Original Message ----- 
From: "Stefan Maric" <stefan.maric@eaac.co.uk>
To: <tomcat-user@jakarta.apache.org>
Sent: Thursday, February 05, 2004 5:35 AM
Subject: Configuring DataSources


> Don't understand why this seems to be so difficult to resolve
>
> Am using JWSDP1.3 - ie Tomcat 5 (Beta ???)  + J2SDK1.4.2
>
> from my initialization Code
>        System.out.println("Getting Context info");
> Context initCtx = new InitialContext();
> System.out.println("Got Initial Context");
> Context envCtx = (Context)initCtx.lookup("java:comp/env");
> System.out.println("Got JWSDP Environment Context");
> System.out.println("Getting AIMS DataSource");
> DataSource ds = (DataSource)envCtx.lookup("jdbc/AIMS_DB");
> if(ds != null)
> {
> System.out.println("Got AIMS DataSource");
> try{
> Connection conn = ds.getConnection();
> System.out.println("Got AIMS DB Connection from
> Pool");
> }catch(Exception eX){
> eX.printStackTrace();
> }
> }
> from my Web.xml
>     <!--    JNDI Resources   -->
>     <resource-ref>
> <description>AIMS DB Connection</description>
> <res-ref-name>jdbc/AIMS_DB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
>     </resource-ref>
> from my <xyzContext>.xml
>   <ResourceLink name="jdbc/AIMS_DB" global="AIMS_DB"
> type="javax.sql.DataSource"/>
>         </Context>
> from my server.xml
>        <GlobalNamingResources>
>        ....
>        <Resource auth="Container" description="AIMS DB" name="AIMS_DB"
> scope="Shareable" type="javax.sql.DataSource"/>
>        ....
>        <ResourceParams name="AIMS_DB">
>              <parameter>
>                <name>factory</name>
>                <value>com.pervasive.jdbc.v2.DataSourceFactory</value>
>              </parameter>
>              <parameter>
>                <name>url</name>
>                <value>jdbc:pervasive://<Host>:<Port>/<DBName></value>
>              </parameter>
>              <parameter>
>                <name>password</name>
>                <value><Passwrod></value>
>              </parameter>
>              <parameter>
>                <name>maxWait</name>
>                <value>5000</value>
>              </parameter>
>              <parameter>
>                <name>maxActive</name>
>                <value>3</value>
>              </parameter>
>              <parameter>
>                <name>driverClassName</name>
>                <value>com.pervasive.jdbc.v2.Driver</value>
>              </parameter>
>              <parameter>
>                <name>username</name>
>                <value><Username></value>
>              </parameter>
>              <parameter>
>                <name>maxIdle</name>
>                <value>2</value>
>              </parameter>
>            </ResourceParams>
>          </GlobalNamingResources>
> Deplyment
> <xyzContext>.xml is in ...<Catalina>/conf/Catalina/localhost
> & I drop my WAR file in ...<Catalina>/myWebApps as referenced by docbase
in
> <xyzContext>.xml
>
> If I stop/start Tomcat the webApp is picked up
> Have checked this with Tomcat WebApp Manager & Tomcat Web Server Admin
>
> Have used these tools to check env/resource settings - all look OK
>
> WHEN I invoke my webApp
> I get the following code trace in the log files
> Getting Context info
> Got Initial Context
> javax.naming.NameNotFoundException: Name java:comp is not bound in
> this Context
> at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:197)
> at javax.naming.InitialContext.lookup(InitialContext.java:347)
> at FDPCalculator.<clinit>(Unknown Source)
>
>
> ie this line of code fails
> Context envCtx = (Context)initCtx.lookup("java:comp/env");
>
>
>
> NOTE I have had the code working fine BEFORE I tried using DataSources
>
> WHAT I am trying to achieve is the REMOVAL of env variables from my
web.xml
> (that provide DB setting)
> So that I can start using DB Connection pools
> (I have other WebApps in a similar state & want to start making use of
some
> Container managed global DB resources)
>
>
>
> Hope someone can help
>
>
> Sorry this has been a bit long-winded
> But I've been going round in circles on this
>
> Regards
> Stefan Maric
> European Aviation Air Charter
> 01202 581111 x184
>
>
>


----------------------------------------------------------------------------
----


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


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.577 / Virus Database: 366 - Release Date: 2/3/2004


---------------------------------------------------------------------
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