struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maarten Roosendaal" <>
Subject DataSource problem
Date Fri, 14 Jun 2002 13:42:26 GMT

I'm trying to create a simple DataBase app. using Struts. Right now i have a problem with
getting the DataSource out of the InitialContext and i'm not sure what i'm doing wrong or
maybe it has something to do with the Struts Servlet.

In configured the server.xml as follows:
 <Resource name="test" auth="CONTAINER"

 <ResourceParams name="test">
       <parameter>      <name>user</name>                   <value>root</value>
       <parameter>      <name>password</name>            <value></value>
       <parameter>      <name>driverClassName</name>  <value></value>
       <parameter>      <name>driverName</name>          <value>jdbc:mysql://localhost/test</value>

and my web.xml includes the following:

In an Action-class i do this:
        Context env = (Context) new InitialContext().lookup("java:comp/env");
        DataSource ds = (DataSource) env.lookup("test");
Here the DataSource keeps ending up as NULL. When i do this:
    Connection con = DriverManager.getConnection(Commands.DB_TEST_URL, Commands.DB_TEST_USERNAME,
    things are working fine but i have no idea where to look. The Context does seem to have
a reference to the 'test' reference but nothing more.
Does this have something to do with Struts or did i forget something? I don't want to use
the struts.xml for a database-connection. One of the reasons is that i keep getting the message
that it can't find the driver, while it is included in the CLASSPATH.

Hope someone can help,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message