You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Dy...@Sun.COM on 2006/04/06 18:39:47 UTC

[comp.lang.java.databases] Using Apache Derby in Tomcat application

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

Re: [comp.lang.java.databases] Using Apache Derby in Tomcat application

Posted by Michelle Caisse <Mi...@Sun.COM>.
Hi John,

I'm just learning about these things myself, but I think that since you 
want Derby embedded into your app, you don't want to create a jdbc JNDI 
resource.  You can just invoke the Derby embedded driver directly from 
your application.  If you do this, placing the driver in the 
application's lib dir should work fine and you have no Tomcat 
configuration to do.

As Lance mentioned in our earlier conversation, if you configure Derby 
to be accessed by JNDI, the container itself has to have access to the 
Derby driver and you must place it in common/lib, not the applications 
lib dir.

-- Michelle

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


Re: [comp.lang.java.databases] Using Apache Derby in Tomcat application

Posted by Rajesh Kartha <ka...@gmail.com>.
>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


Dyre.Tjeldvoll@Sun.COM wrote:

>
> ------------------------------------------------------------------------
>
> Subject:
> Using Apache Derby in Tomcat application
> From:
> John O'Conner <jo...@joconner.com>
> 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
>  
>
>------------------------------------------------------------------------
>
>
>
>  
>