Hi Wade,
Yes, I have been able to connect with a plain java class and I have been
able to connect from within Struts2 directly. It is when I try to get a
DataSource object from Tomcat's JNDI that it messes.
Prem
On 7/23/07, Wade Chandler <hwadechandler-apache@(protected):
>
> From a JSP page try to make a MYSQL connection using
> just pure JDBC calls. It may be something to do with
> your JDBC classes and the directory your JAR files are
> housed. If I remember correctly I had to put my MYSQL
> JAR file in the shared folder so the server could
> access them. This versus having them in the
> WEB-INF/lib folder. May or may not be your issue, but
> make sure you can actually make a JDBC connection with
> the drivers first. If not then the DataSource won't
> work either.
>
> I have never used
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
>
> before either. Maybe comment out this line and see if
> it has any impact.
>
> Wade
>
> --- Prem Padarath <ppadarath@(protected):
>
> > Hi,
> >
> > I am trying to set up a database resource in Tomcat
> > 5.5.20 . I am having a
> > problem getting a DataSource object back from a JNDI
> > lookup.
> > (I am getting a
> > "org.apache.tomcat.dbcp.dbcp.BasicDataSource" object
> > returned and throwing an exception - code below)
> >
> > My problem is similar to the "Re: MySql Connector"
> > thread of messages.
> >
> > I can see the resource listed in the Tomcat
> > Administration Tool under Tomcat
> > Server --> Service --> Host --> Context(/dbtest)
> > and all the information for the datasource looks
> > fine (as from the
> > context.xml file below).
> >
> > My context.xml file (placed in my webapp under
> > META-INF) looks as follows:
> >
> > <Context crossContext="true" path="/dbtest"
> > reloadable="true">
> > <Logger
> > className="
org.apache.catalina.logger.FileLogger"
> > prefix="localhost-dbtest-log."
> > suffix="txt"
> > timestamp="true"/>
> >
> > <Resource
> > name="jdbc/MYSQLDS"
> > auth="Container"
> > type="
javax.sql.DataSource"
> > maxActive="5"
> > maxIdle="3"
> > maxWait="10000"
> > username="myuser"
> > password="mypwd"
> > driverClassName="
com.mysql.jdbc.Driver"
> >
> > url="jdbc:mysql://localhost:3306/testdb"/>
> >
> > <WatchedResource>WEB-INF/web.xml</WatchedResource>
> > </Context>
> >
> > My web.xml file contains the following:
> >
> > <resource-ref>
> > <description>DB Connection</description>
> > <res-ref-name>jdbc/MYSQLDS</res-ref-name>
> > <res-type>
javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> >
> > And the snippet/code I am using to acquire a
> > datasource is as follows:
> >
> > DataSource ds = null;
> > ....
> > ds =
> >
> (DataSource)initContext.lookup("java:/comp/env/jdbc/MYSQLDS");
> > ....
> >
> > When the app is run, I get back
> >
> >
java.lang.Exception:
> > org.apache.tomcat.dbcp.dbcp.BasicDataSource
> > dbtest.HelloWorld.execute(HelloWorld.java:53)
> >
> >
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >
sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:39)
> >
sun.reflect.DelegatingMethodAccessorImpl.invoke> > (
> > DelegatingMethodAccessorImpl.java:25)
> >
java.lang.reflect.Method.invoke (
Method.java:585)
> >
> > (by the way, I am running this within a Struts2
> > Framework)
> >
> > Can anyone tell me what I am doing incorrectly
> > still?
> >
> > Thx,
> > Prem
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>