So, can anyone help me understand how to add the DataSource resource and
JNDI entry somewhere just local to the app itself. I'm trying to put
this information into WEB-INF/web.xml, but I'm not sure this is
possible. Any thoughts?
To use the JNDI lookup for a datasource with Tomcat, the 'common/lib' is
the only place to put the jar file, see
http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html
Just a thought, but instead of using JNDI to get a Datasource, would
creating an EmbeddedDataSource directly and passing it
to the needed methods (that need a DataSource object ) work for you ?
This way, the derby.jar could sit in theWEB-INF/lib to be made local to
the application.
Example:
...
EmbeddedDataSource oxds1=new EmbeddedDataSource();
oxds1.setDatabaseName("adb");
oxds1.setConnectionAttributes("create=true");
getConn(oxds1); //pass it to the needed methods that takes a
java.sql.DataSource as the param
....
}
private static void getConn(DataSource ds) {
//get Connection and do work
}
-Rajesh
[EMAIL PROTECTED] wrote:
------------------------------------------------------------------------
Subject:
Using Apache Derby in Tomcat application
From:
John O'Conner <[EMAIL PROTECTED]>
Date:
Wed, 05 Apr 2006 17:52:59 GMT
Newsgroups:
comp.lang.java.databases
Heya,
I'm trying to integrate Derby as an embedded db into the Roller web log
app on Tomcat. All the FAQs and install instructions describe how to
1. create the jdbc/rollerdb JNDI resource and DataSource in the
server.xml file.
2. place the Derby JDBC driver in Tomcat's common/lib subdir
I have a couple problems with this:
1. I don't control the Tomcat installation and don't have access to the
common/lib directory. However, I do have access to a CATALINA_BASE dir
in my home directory and to the app's WEB-INF directory.
2. Without putting the driver in common/lib, the existing instructions
cause exceptions trying to find the Derby driver...obviously derby.jar
isn't in common/lib but is instead in my app's WEB-INF/lib directory.
3. Creating a global JNDI resource and DataSource in server.xml is
causing the exceptions in #2 above.
So, can anyone help me understand how to add the DataSource resource and
JNDI entry somewhere just local to the app itself. I'm trying to put
this information into WEB-INF/web.xml, but I'm not sure this is
possible. Any thoughts?
Thanks for your help!
Regards,
John O'Conner
------------------------------------------------------------------------