I appreciate your response. DAO with JDNI retrieving data from a through a tiles controller ended up working and for those who may go down this path setting up a context on Tomcat 5.5.4 is very different so beware.
Jim
From: Eddie Bush <[EMAIL PROTECTED]> Reply-To: Eddie Bush <[EMAIL PROTECTED]> To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Re: JNDI with tiles controller Date: Mon, 20 Dec 2004 19:28:04 -0600
Jim,
JNDI is the best-practice approach to dealing with acquisition of data-sources. It's not always practical to use (for example, if you don't have control over the server config) but it sure is slick.
Not knowing what is in the tile that produces the error, it's difficult to say what your error could be. If you believe this to be a Tomcat configuration issue, you'd likely be better off asking it to the tomcat-user list. Yes, there are people here that use Tomcat, but this is the Struts list and not everyone here uses Tomcat.
If you're attempting to do your queries in your JSPs, I'd recommend against it. Let your actions / business objects / DAOs deal with that. Handling your queries in your JSPs is NOT a best practice approach. An approach that tends to work for me is to write a set of DAOs or use an O/R mapper (http://db.apache.org/ojb/ is one). The DAO appoach is really simple, but fairly powerful - it should suffice for most simple to moderately complex systems.
There's a ton of best practice stuff in the Struts' site Resources section and User Guides. There are Tomcat-specific configuration guides on the Tomcat site -- JNDI Howtos and, in fact, even DataSource Howtos. It's really best to go to horse and get things from his mouth.
Good Luck!
Eddie
On Mon, 20 Dec 2004 18:54:32 +0000, Jim Douglas <[EMAIL PROTECTED]> wrote:
> My first question is a design one. Is JDNI the best way to access a
> database from a Tiles controller? If so, this is the JDNI class problem I
> have.
>
> This is the tomcat/conf/catalina/localhost/myapp.xml file,
>
> <Context path="/Myapp" docBase="Myapp" debug="5" reloadable="true"
> crossContext="true">
> <Resource name="jdbc/UserDB" auth="Container" type="javax.sql.DataSource"
> />
> <ResourceParams name="jdbc/UserDB">
> <parameter>
> <name>username</name>
> <value>SYSDBA</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>password</value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
> <value>interbase.interclient.Driver</value>
> </parameter>
> <parameter>
> <name>url</name> <value>jdbc:interbase://localhost//usr/opt/tomcat/webapps/database/main.gdb</value>
> </parameter>
> </ResourceParams>
> </Context>
>
> This is my Myapp/WEB-INF/web.xml entry,
>
> <resource-ref>
> <description>DS Connection</description>
> <res-ref-name>jdbc/UserDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> ...and this is the error,
>
> ERROR - ServletException in '/layouts/classicLayout.jsp': Cannot create JDBC
> driver of class '' for connect URL 'null'
> javax.servlet.ServletException: Cannot create JDBC driver of class '' for
> connect URL 'null'
> at
> org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:880)
> at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
>
> For whatever reason it doens't seem to be loading the driver class. This is
> the line causing the error,
>
> Connection conn = ds.getConnection();
>
> I'm using Tomcat 5.5.4(if JDNI is not the best way to acces a database from
> a Tiles Controller, what is, what is?)
>
> (I can query by other means using the JDBC driver which is located in
> ...tomcat/common/lib/, so it's JDNI that giving me the problem.)
>
> Thanks,
> Jim,
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
-- Eddie Bush
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]