tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Williamson" <ja...@nameonthe.net>
Subject Re: JNDI: datasource is null
Date Fri, 03 May 2002 22:20:45 GMT
Are you using the warp connector?

Regards,

James Williamson
www.nameonthe.net
UK Tomcat Hosting

----- Original Message -----
From: Cindy Ballreich <cindy@ballreich.net>
To: <tomcat-user@jakarta.apache.org>
Sent: Friday, May 03, 2002 10:22 PM
Subject: JNDI: datasource is null


> I know there's been a lot of JNDI/database type questions lately, but I
hope you guys won't mind one more.
>
> I'm trying to set up a configuration similar to the one in the How-To. In
my servlet I have the following lines...
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> DataSource ds = (DataSource) envCtx.lookup("jdbc/Support");
> Connection conn = ds.getConnection();
>
> The problem is that the envCtx.lookup is returning null so
ds.getConnection() throws a NullPointerException every time. I'm not getting
any other errors. I have been able to access this database with these
parameters from a servlet (without JNDI) so I know that it *can* work. I'm
sure I'm missing something simple, but I can't figure out what it is. I've
searched the archives and have seen this problem described, but no solution.
I've tried changing "driverName" to "url" as has been suggested, but that
made no difference. I'd appreciate any help in getting this working. Please
let me know if more info is needed. (Config info is below.)
>
> Cindy
>
> Here's the Resource from my server.xml. This is inside my applications
context...
> <Resource name="jdbc/Support"
>     auth="Container"
>     type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/Support">
>   <parameter>
>     <name>user</name>
>     <value>devuser</value>
>   </parameter>
>   <parameter>
>     <name>password</name>
>     <value>devpass</value>
>   </parameter>
>   <parameter>
>     <name>driverClassName</name>
>     <value>org.gjt.mm.mysql.Driver</value>
>   </parameter>
>   <parameter>
>     <name>driverName</name>
>     <value>jdbc:mysql://localhost/Support</value>
>   </parameter>
> </ResourceParams>
>
> And here's the resource-ref from my application's web.xml...
> <resource-ref>
>   <res-ref-name>jdbc/Support</res-ref-name>
>   <res-type>javax.sql.DataSource</res-type>
>   <res-auth>Container</res-auth>
> </resource-ref>
>
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message