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 "Dockery, Michael E SFC NG NG NGB" <mi...@us.army.mil> on 2008/02/27 04:29:08 UTC

getconnection error using Derby and tomcat6/jndi

I am trying to get derby working
 on tomcat6 via jndi


my context.xml looks like this:
<?xml version='1.0' encoding='utf-8'?>
<Context path="/testApp" docBase="testApp" antiJARLocking="true">
   <!-- ensure the db server is started and that tomcat can find the db 
driver -->
 <Resource    name="jdbc/derbyDB" auth="Container"
         type="javax.sql.DataSource"
        driverClassName="org.apache.derby.jdbc.ClientDriver"
       url="jdbc:derby://192.168.1.100:1527/setupDB"
         maxActive="10"  maxIdle="5"        />
</Context>



my web.xml looks like this
...
 <resource-ref>
   <description>Setup Database</description>
   <res-ref-name>jdbc/derbyDB</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
 </resource-ref>

...

my java code gets the datasource from jndi just fine
  envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
  ds=(DataSource)envCtx.lookup("jdbc/derbyDB");

but it fails when i try to getConnection
   conn = ds.getConnection();




i am not sure what i am doing wrong here.

Any ideas?

Thank you
Michael


ps:
note: the commandline ij tool works fine also:
   C:\Documents and Settings\Lisa>ij
   ij version 10.3
   ij> connect 'jdbc:derby://192.168.1.100/setupDB';
   ij> show tables;
   TABLE_SCHEM         |TABLE_NAME                    |REMARKS
   ------------------------------------------------------------------------
   SYS                 |SYSALIASES                    |
...


Re: getconnection error using Derby and tomcat6/jndi

Posted by JavaDoctor <mi...@us.army.mil>.
Yes!

The fix was placing derbyclient.jar into the tomcat6 lib folder

fyi - previously i only had palced the following jars into the tomcat6 lib
directory:
   derby.jar
   derbytools.jar
   derbynet.jar
   derbyrun.jar
but they were not enough

I did NOT think i would need the derbyclient.jar
  on the webapp server
   but that is what allowed my tomcat webapp using jndi to get the
connection

thank you!

ps: i probably do not need all the other derby jars on the server.


-- 
View this message in context: http://www.nabble.com/getconnection-error---using-Derby-and-tomcat6-jndi-tp15707511p15714925.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: getconnection error using Derby and tomcat6/jndi

Posted by Narayanan <V....@Sun.COM>.
Dockery, Michael E SFC NG NG NGB wrote:
> I am trying to get derby working
> on tomcat6 via jndi
>
>
> my context.xml looks like this:
> <?xml version='1.0' encoding='utf-8'?>
> <Context path="/testApp" docBase="testApp" antiJARLocking="true">
>   <!-- ensure the db server is started and that tomcat can find the db 
> driver -->
> <Resource    name="jdbc/derbyDB" auth="Container"
>         type="javax.sql.DataSource"
>        driverClassName="org.apache.derby.jdbc.ClientDriver"
>       url="jdbc:derby://192.168.1.100:1527/setupDB"
>         maxActive="10"  maxIdle="5"        />
> </Context>
>
>
>
> my web.xml looks like this
> ...
> <resource-ref>
>   <description>Setup Database</description>
>   <res-ref-name>jdbc/derbyDB</res-ref-name>
>   <res-type>javax.sql.DataSource</res-type>
>   <res-auth>Container</res-auth>
> </resource-ref>
>
> ...
>
> my java code gets the datasource from jndi just fine
>  envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
>  ds=(DataSource)envCtx.lookup("jdbc/derbyDB");
>
> but it fails when i try to getConnection
>   conn = ds.getConnection();
>
>
>
>
> i am not sure what i am doing wrong here.
>
> Any ideas?
>
> Thank you
> Michael
>
>
> ps:
> note: the commandline ij tool works fine also:
>   C:\Documents and Settings\Lisa>ij
>   ij version 10.3
>   ij> connect 'jdbc:derby://192.168.1.100/setupDB';
>   ij> show tables;
>   TABLE_SCHEM         |TABLE_NAME                    |REMARKS
>   
> ------------------------------------------------------------------------
>   SYS                 |SYSALIASES                    |
> ...
>
Do you have a stack trace of the failure ?

Not sure but I think this link matches your requirement perfectly

http://www.pintux.it/docs/Derby-Tomcat-en.pdf

Narayanan