Solved

JDBC Driver cannot be loaded

Posted on 2004-09-19
10
1,577 Views
Last Modified: 2008-01-09
I am currently doing an application which includes using stateless session bean, i am using oracle jdeveloper 10g as my IDE, bea weblogic 6.1 as my app server and mysql for database.. i have this code tat connects to the database however when i test my client script, there is this exception

java.sql.SQLException: JDBC driver class cannot be loaded

      at Db.Database.<init>(Database.java:22)

      at Member.MemberEJBBean.addMember(MemberEJBBean.java:23)

      at Member.MemberEJBBean_fow6gt_EOImpl.addMember(MemberEJBBean_fow6gt_EOImpl.java:36)

      at Member.MemberEJBBean_fow6gt_EOImpl_WLSkel.invoke(Unknown Source)

      at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:360)

      at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)

      at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:329)

      at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)

      at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:140)

      at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:121)


anyone know y? i have already included the jar file in the library of the IDE
0
Comment
Question by:ginola29
  • 5
  • 4
10 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 12099555
What's the code that creates the conenction? Do you call:
Class.forName("oracle.jdbc.driver.OracleDriver");
0
 

Author Comment

by:ginola29
ID: 12099568
private final String driver = "com.mysql.jdbc.Driver";
private final String url = "jdbc:mysql://localhost/dvd";
private final String user = "";
private final String password = "";

/**
 * The constructor attempts to load the jdbc driver class.
 * If failed, the ClassNotFoundException is rethrown as SQLException
 **/
public Database() throws SQLException {
      try {
            Class.forName(driver);
      } catch (ClassNotFoundException ce) {
            throw (new SQLException("JDBC driver class cannot be loaded"));
      }
}
/**
 * Get a new connection.  User must close it after used.
 **/
public Connection getConnection() throws SQLException {
      return DriverManager.getConnection(url, user, password);
}

by the way, i am using mysql...i tik i have to setup a datasource at the weblogic console, but i just can't get it right, anyone can help me with that?
0
 
LVL 92

Expert Comment

by:objects
ID: 12099586
Its not finding your driver class, make sure the jar is available to the WL class loader.
eg. put the jar in <webapp>/WEB-INF/lib
0
 

Author Comment

by:ginola29
ID: 12099600
erm..my project doesn't have a web-inf folder, must i just create that folder? just under the folder <webapp>
0
 
LVL 92

Expert Comment

by:objects
ID: 12099614
yes where <webapp> is the folder that you webapplication is in.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ginola29
ID: 12099667
i still got the same error, driver cannot be loaded, must i do some configuration between weblogic server and mysql? can i know hw to if it is a must?
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 12099694
0
 

Author Comment

by:ginola29
ID: 12099737
there are some errors i have encounter

i entered:
name : dvdProject
url: jdbc:mysql://localhost/dvd
driver classname: com.mysql.jdbc.Driver
properties: user=root

the rest all blanks

then i went to the target tab, and tried to deploy it, errors are returned.

weblogic.management.DistributedOperationUpdateException: Error creating connection pool - with nested exception:
[weblogic.management.DeploymentException: Error creating connection pool - with nested exception:
[weblogic.common.ResourceException: Cannot load driver class: com.mysql.jdbc.Driver]]
      at weblogic.management.internal.ConfigurationMBeanImpl.updateConfigMBeans(ConfigurationMBeanImpl.java:518)
      at weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImpl.java:376)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
      at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:468)
      at weblogic.management.in--------------- nested within: ------------------
weblogic.management.console.utils.SetException: An error occurred while updating Targets-Server on Proxy for mydomain:Name=dvdProject,Type=JDBCConnectionPool - with nested exception:
[java.lang.reflect.InvocationTargetException - with target exception:
[weblogic.management.DistributedManagementException: Distributed Management [1 exceptions]]]
      at weblogic.management.console.actions.mbean.DoEditMBeanAction.perform(DoEditMBeanAction.java:155)
      at weblogic.management.console.actions.internal.ActionServlet.doAction(ActionServlet.java:171)
      at weblogic.management.console.actions.internal.ActionServlet.doPost(ActionServlet.java:85)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
      at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
      at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2678)
      at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2412)
      at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:140)
      at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:121)
0
 
LVL 92

Expert Comment

by:objects
ID: 12099764
still looks like its not finding your driver class
chechk the jar contains the specified class
0
 

Author Comment

by:ginola29
ID: 12099816
ok i got it solve, the classpath wasnt' set correctly at the right place in the startweblogic.cmd .. thx anyway
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 73
JAVA part two 5 58
Java Server Faces parameter pass? 6 39
simple java question 3 44
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now