I tried many times to get the connection between my web application and Derby and I received these error messages in the eclipse console:

INFO: Server startup in 3772 ms

ERROR: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

ERROR: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

11/02/2011 19:08:53 org.apache.catalina.core.StandardContext reload 


My class and database definition is showed bellow:

// Obtain our environment naming context            
javax.naming.Context initCtx = new InitialContext();

javax.naming.Context envCtx = (Context) initCtx.lookup("java:comp/env");


// Look up our data source by the name we gave it when we created it.
// In this case that's "jdbc/customer".
javax.sql.DataSource ds = (DataSource) envCtx.lookup("jdbc/customer");

conn = ds.getConnection();

And my web.xml and context are showed bellow.

in context.xml ...

Resource name="jdbc/customer" 
auth="Container"
type="javax.sql.DataSource"
username="qwert"
password="asdf"
driverClassName="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/C:\\testes_db\\customer;create=true;"
       maxActive="8"

and in the web.xml ...

res-ref-name jdbc/customer

res-type javax.sql.DataSource

res-auth Container


-- my second attempt 

resource-env-ref-name jdbc/customer

resource-env-ref-type javax.sql.DataSource

I'm using tomcat 6 with eclipse wtp (europa) in windows. And I already put derby.jar and derbclinet.jar inside of WEB_INF\lib directory ...

There are something that I can do to solve this issue?

Thanks!

1

There are 1 answers

0
nos On BEST ANSWER

Since you're configuring the DataSource in context.xml, it's Tomcat that manages this, not your webapp.

You have to place the JDBC driver, derbyclient.jar, in your $TOMCAT_HOME/lib/ directory, not yourwebapp/WEB-INF/lib/