see my post from yesterday "RE: JNDI DataSource GlobalResources problem" :)
This exception means that TC cannot find your Resource.
Your only guess is correct! Put your <Context> in either
webapps/yourwebapp/META_INF/context.xml (if you are deploying in a
war)
or
conf/Catalina/localhost/yourwebapp.xml (if you are deploying
"unpacked")
or for v5.5 maybe that should be
conf/context.xml (if you are deploying "unpacked")
I think it'll then work as long as your ResourceParams are all correct.
It's OK for <Context> to be the top level tag in the file. If the context
tag already in context.xml is for your webapp, then just add the
<ResourceParams> tag inside that <Context>. You can add <Resource> too but
it's not required as long as you have a matching <resource-ref> in your
web.xml file. If the existing <Context> is for a different webapp, I think
I'm right in saying that you can add another whole <Context> to the same
file.
Alternatively I think I'm right in saying that you can add your Context tag
inside the default <Host> tag in server.xml corresponding to the default
localhost. You're right there is no examples context tag there - this is a
correction that I plan to submit to the howto. Having said that, as of
v5.5, placing <Context>s inside server.xml is not recommended.
> -----Original Message-----
> From: Nat Titman [mailto:[EMAIL PROTECTED]
> Sent: Wednesday 27 October 2004 12:22
> To: [EMAIL PROTECTED]
> Subject: Database connection pooling
>
>
> Hi,
>
> I'm attempting to integrate database connection pooling into an
> exisiting JSP-based web application.
>
> I'm running Tomcat 5.5.2 Server, with J2SE 1.5.0 and a MySQL database
> (version 11.18) accessed through the com.mysql.jdbc package.
>
> I've followed MySQL instructions from this page:
>
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasourc
> e-examples-howto.html
>
> I made the changes to server.xml and the web app's web.xml, changing
> variables to match the database name, user name and password of the
> correct database. I ensured the MySQL package was in common/lib/.
>
> My DAO objects now have constructors of the following form, which was
> adapted from code found online ('broadband' is the database name):
>
> private Connection myConn;
> private DataSource dataSource;
>
> /**
> * Constructs the data accessor using the connection pool
> *
> * @exception SQLException thrown for SQL errors
> */
> public SearchDAO() throws SQLException {
>
> try {
>
> // retrieve datasource
> Context init = new InitialContext();
> Context ctx = (Context) init.lookup("java:comp/env");
> dataSource = (DataSource) ctx.lookup("jdbc/broadband");
>
> // get connection
> synchronized (dataSource) {
>
> myConn = dataSource.getConnection();
>
> }
>
> } catch (NamingException ex) {
>
> System.err.println(
> "new SearchDAO: Cannot retrieve
> java:comp/env/jdbc/broadband: "
> + ex);
>
> } catch (SQLException excep) {
>
> System.err.println(
> "new SearchDAO: Could not get connection: " + excep);
>
> } catch (Exception e) {
>
> System.err.println("new SearchDAO: " + e);
>
> // System.out.println ("In the catch block : ....");
> //e.printStackTrace();
>
> }
>
> }
>
> The constructor throws the following exception:
>
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
> driver of class '' for connect URL 'null'
>
> The connect URL is present in server.xml and is correct for
> the database.
>
> My only guess at this point is that the howto document above asks for
> the Context tag to be added to server.xml between the example close
> Context and the first open Host tag, however there wasn't an example
> Context tag in server.xml and there appears to be a
> context.xml file in
> the same directory. I'm wondering if Contexts have moved to a
> different
> file in a recent version of Tomcat? It's just a wild guess
> (and I've no
> idea how to add the Context to context.xml as there's already
> a Context
> tag in there and no higher level tag around it).
>
> Any help would be greatly appreciated. Sorry if I'm wasting your time
> with an obvious or frequently asked question, I've googled and read
> quite a few documents, but I think I'm just at the 'stabbing in the
> dark' point and could do with guru guidance.
>
> Thanks,
>
>
> Nat.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]