• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

error: Cannot load JDBC driver class

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I'm new to J2EE and I'm figuring out how to make JDBC work. I try to use Initial Context and do lookup for the database but I get this error:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

I've defined the resource in web.xml:

<resource-ref>
<res-ref-name>jdbc/Friend_DB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

and defined it in context.xml:


<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Friend_Management_System">
<Resource name = "jdbc/Friend_DB" type = "javax.sql.DataSource"
driverClassName = "org.apache.derby.jdbc.ClientDriver"
url = "jdbc:derby://localhost:1527/Friend_DB"
username = "use_name"
password = "pass"
/>
</Context>


Could somebody please advice if there's something else I need to do to make this work?

Thank you very much
[ November 08, 2006: Message edited by: Bear Bibeault ]
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi dude
It means that derby driver is not in your application server classpath.
so you should add derbyClient.jar in your application server common or shared library.
for example it could be glassfish_home\domain1\lib or tomcat_home\shared\lib
what ever place your shared library is.

hth
 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I put the derbyClient.jar file into the folder: C:\Program Files\netbeans-5.0\enterprise2\jakarta-tomcat-5.5.9\common\lib

The original error disappeared and was replaced by:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (java.security.PrivilegedActionException : Error

Further, it was said to be "Caused by: org.apache.derby.client.am.DisconnectException: java.security.PrivilegedActionException : Error opening socket to server localhost on port 1527 with message : null"

Could you please help with this? I have no idea what the problem is.

Here is the code that opens the connection:

try
{
Context ctx = new InitialContext();
DataSource datasource = (DataSource) ctx.lookup("java:comp/env/jdbc/Friend_DB");

Connection con = datasource.getConnection();

Statement state = con.createStatement();

ResultSet res = state.executeQuery(select);

person_name = res.getString("person_name");

if(datasource == null)
person_name = "no Datasource";

request.setAttribute("person_name",person_name);

}
catch(Exception e)
{
e.printStackTrace();
}
 
Masoud Kalali
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have firewall installed on your machine ?
it looks like that some other application does not allows derby to listen on the port.
 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I check for this firewall? Could you please advice? Thank you very much
reply
    Bookmark Topic Watch Topic
  • New Topic