Ok, now I feel really silly. It has been pointed out to me that I have "java.sql.DataSource" as opposed to "javax.sql.DataSource" in my Resource definition in server.xml
It all works now! Silly mistake, although I wish there had been a stack trace somewhere to tell me this. Thanks for your responses. J -----Original Message----- From: Raj Saini [mailto:[EMAIL PROTECTED]] Sent: 15 October 2002 10:23 To: Tomcat Users List Subject: Re: JNDI Datasource is *still* null Please post the Context defination part of your server.xml. Can you also post the stacktrace? BTW, do you have the latest oracle driver? Did you rename your classes.zip to classes.jar? Raj James hughes wrote: > Made the changes, still no DataSource. > > -----Original Message----- > From: Raj Saini [mailto:[EMAIL PROTECTED]] > Sent: 14 October 2002 19:42 > To: Tomcat Users List > Subject: Re: JNDI Datasource is null > > > Hi, > > Do you really need the CharacterSetMappers in your context defination? > Try using the vanila configuration for testing. > > Try moving up the DriverClassName element just about the url. > > Raj Saini > > James hughes wrote: > >>Surely there must be somebody out there who has connection pooling working >>with DBCP and Oracle..... >> >>Please! :) >> >>-----Original Message----- >>From: James hughes [mailto:[EMAIL PROTECTED]] >>Sent: 14 October 2002 14:55 >>To: Tomcat Users List >>Subject: RE: JNDI Datasource is null >> >> >>I changed the values, but still the Datasource is null :( >> >>I find it strange that the JNDI name exists with no object - that is, I > > dont > >>get a NameNotFoundException. >> >> >>-----Original Message----- >>From: Jacob Kjome [mailto:[EMAIL PROTECTED]] >>Sent: 14 October 2002 14:53 >>To: Tomcat Users List >>Subject: Re: JNDI Datasource is null >> >> >> >>2 things are possible culprits.... >> >>The syntax for JNDI datasources changed slightly after moving from Tyrex > > as > >>the default provider to DBCP. Specifically, "user" should be >>"username". The other thing is the <Resource scope="Sharable">. That >>might be right, but I've never used it. I use "Container" for that value. >> >>Jake >> >>At 02:07 PM 10/14/2002 +0100, you wrote: >> >> >>>Hi there, >>> >>>I am using Oracle 9i, DBCP and Tomcat 4.1.12. I am trying to configure a >>>JNDI datasource that implements connection pooling. I have been following >>>the instructions in the JNDI how to, specifically the section for Oracle. >>> >>>My problem is that the JNDI Datasource is null when I try to get it from >> >>the >> >> >>>context. I cant see any exceptions being thrown anywhere. >>> >>>Can anyone tell me what I have missed? >>> >>>My server.xml is as follows (this entry is in the HOST tag, after the >>>/examples context): >>> >>> <Context className="org.apache.catalina.core.StandardContext" >>> cachingAllowed="true" >>> >> >>charsetMapperClass="org.apache.catalina.util.CharsetMapper" >> >> >>> cookies="true" >>> crossContext="true" >>> debug="5" docBase="TestDB" >>> >>>mapperClass="org.apache.catalina.core.StandardContextMapper" >>> path="/TestDB" privileged="false" >>> reloadable="true" swallowOutput="false" >>> useNaming="true" >>> wrapperClass="org.apache.catalina.core.StandardWrapper"> >>> <Logger className="org.apache.catalina.logger.FileLogger" >>> debug="0" directory="logs" >>> prefix="localhost_DBTest_log." >>> suffix=".txt" timestamp="true" verbosity="1"/> >>> <Resource auth="container" name="jdbc/myoracle" >> >>scope="Shareable" >> >> >>>type="java.sql.DataSource"/> >>> <ResourceParams name="jdbc/myoracle"> >>> <parameter> >>> <name>factory</name> >>> >><value>org.apache.commons.dbcp.BasicDataSourceFactory</value> >> >>> </parameter> >>> <parameter> >>> <name>url</name> >>> <value>jdbc:oracle:thin:@127.0.0.1:1521:RHODES</value> >>> </parameter> >>> <parameter> >>> <name>password</name> >>> <value>tiger</value> >>> </parameter> >>> <parameter> >>> <name>maxActive</name> >>> <value>20</value> >>> </parameter> >>> <parameter> >>> <name>maxWait</name> >>> <value>10</value> >>> </parameter> >>> <parameter> >>> <name>driverClassName</name> >>> <value>oracle.jdbc.driver.OracleDriver</value> >>> </parameter> >>> <parameter> >>> <name>user</name> >>> <value>scott</value> >>> </parameter> >>> <parameter> >>> <name>maxIdle</name> >>> <value>10</value> >>> </parameter> >>> </ResourceParams> >>> </Context> >>> >>> >>>And web.xml is as follows: >>> >>> <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> >>> >>> >>> >>>I have a class as follows: >>> >>>package foo; >>> >>>import javax.naming.*; >>>import javax.sql.*; >>>import java.sql.*; >>> >>>public class DBTest >>>{ >>> String foo = "Not Connected"; >>> int bar = -1; >>> >>> public void init() >>> { >>> try >>> { >>> Context ctx = new InitialContext(); >>> if(ctx == null ) >>> { >>> throw new Exception("Boom - No Context"); >>> } >>> >>> Context envContext = >>>(Context)ctx.lookup("java:/comp/env"); >>> DataSource ds = >>>(DataSource)envContext.lookup("jdbc/myoracle"); >>> >>> if (ds != null) >>> { >>> Connection conn = ds.getConnection(); >>> >>> if(conn != null) >>> { >>> foo = "Got Connection >>>"+conn.toString(); >>> Statement stmt = >>>conn.createStatement(); >>> ResultSet rst = >>>stmt.executeQuery("select id, foo, bar from testdata"); >>> >>> if(rst.next()) >>> { >>> foo = rst.getString(2); >>> bar = rst.getInt(3); >>> } >>> >>> conn.close(); >>> } >>> } >>> else >>> { >>> System.out.println("DS was null!"); >>> } >>> } >>> catch(Exception e) >>> { >>> e.printStackTrace(); >>> } >>> } >>> >>> public String getFoo() { return foo; } >>> public int getBar() { return bar;} >>>} >>> >>> >>> >>>And finally, a JSP as follows: >>> >>><% foo.DBTest tst = new foo.DBTest(); tst.init(); %> >>> >>>Results >>> >>> >>> >>>Foo <%= tst.getFoo() %> Bar <%= tst.getBar() %> >>> >>>-- >>>To unsubscribe, e-mail: >> >><mailto:[EMAIL PROTECTED]> >> >>>For additional commands, e-mail: >> >><mailto:[EMAIL PROTECTED]> >> >>-- >>To unsubscribe, e-mail: >><mailto:[EMAIL PROTECTED]> >>For additional commands, e-mail: >><mailto:[EMAIL PROTECTED]> >> >>-- >>To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > >>For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>