struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rainer juenger" <jakarta_rai...@projektinter.net>
Subject Re: DataSource problem
Date Fri, 14 Jun 2002 14:07:20 GMT
Hi Maarten,

join the club! There are some more guys having exactliy the same problem as
you.
To me your configuration looks all right. I saw some samples :

<parameter>      <name>driverName</name>
<value>jdbc:mysql://localhost/test</value> </parameter>

where the parameter name is not driverName but url. I tried both without
luck.

Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the
JNDI DB Connection?

Please follow the thread "Connection pooling dowsn't work for me ... Help
!!"
Hopefully there is someone arround giving us a tip how to get it run

Good luck to all of us ;)
Rainer

----- Original Message -----
From: "Maarten Roosendaal" <mroosendaal@sogyo.nl>
To: <struts-user@jakarta.apache.org>
Sent: Friday, June 14, 2002 3:42 PM
Subject: DataSource problem


Hi,

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"
      type="javax.sql.DataSource"/>

 <ResourceParams name="test">
       <parameter>      <name>user</name>
<value>root</value>                                  </parameter>
       <parameter>      <name>password</name>            <value></value>
</parameter>
       <parameter>      <name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>     </parameter>
       <parameter>      <name>driverName</name>
<value>jdbc:mysql://localhost/test</value> </parameter>
      </ResourceParams>

and my web.xml includes the following:
    <resource-ref>
        <res-ref-name>test</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>CONTAINER</res-auth>
    </resource-ref>

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




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


Mime
View raw message