ginola29
asked on
JDBC Driver cannot be loaded
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>(Databas e.java:22)
at Member.MemberEJBBean.addMe mber(Membe rEJBBean.j ava:23)
at Member.MemberEJBBean_fow6g t_EOImpl.a ddMember(M emberEJBBe an_fow6gt_ EOImpl.jav a:36)
at Member.MemberEJBBean_fow6g t_EOImpl_W LSkel.invo ke(Unknown Source)
at weblogic.rmi.internal.Basi cServerRef .invoke(Ba sicServerR ef.java:36 0)
at weblogic.rmi.cluster.Repli caAwareSer verRef.inv oke(Replic aAwareServ erRef.java :93)
at weblogic.rmi.internal.Basi cServerRef .handleReq uest(Basic ServerRef. java:329)
at weblogic.rmi.internal.Basi cExecuteRe quest.exec ute(BasicE xecuteRequ est.java:2 2)
at weblogic.kernel.ExecuteThr ead.execut e(ExecuteT hread.java :140)
at weblogic.kernel.ExecuteThr ead.run(Ex ecuteThrea d.java:121 )
anyone know y? i have already included the jar file in the library of the IDE
java.sql.SQLException: JDBC driver class cannot be loaded
at Db.Database.<init>(Databas
at Member.MemberEJBBean.addMe
at Member.MemberEJBBean_fow6g
at Member.MemberEJBBean_fow6g
at weblogic.rmi.internal.Basi
at weblogic.rmi.cluster.Repli
at weblogic.rmi.internal.Basi
at weblogic.rmi.internal.Basi
at weblogic.kernel.ExecuteThr
at weblogic.kernel.ExecuteThr
anyone know y? i have already included the jar file in the library of the IDE
ASKER
private final String driver = "com.mysql.jdbc.Driver";
private final String url = "jdbc:mysql://localhost/dv d";
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.getConnectio n(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?
private final String url = "jdbc:mysql://localhost/dv
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.getConnectio
}
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?
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
eg. put the jar in <webapp>/WEB-INF/lib
ASKER
erm..my project doesn't have a web-inf folder, must i just create that folder? just under the folder <webapp>
yes where <webapp> is the folder that you webapplication is in.
ASKER
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Distri butedOpera tionUpdate Exception: Error creating connection pool - with nested exception:
[weblogic.management.Deplo ymentExcep tion: Error creating connection pool - with nested exception:
[weblogic.common.ResourceE xception: Cannot load driver class: com.mysql.jdbc.Driver]]
at weblogic.management.intern al.Configu rationMBea nImpl.upda teConfigMB eans(Confi gurationMB eanImpl.ja va:518)
at weblogic.management.intern al.Configu rationMBea nImpl.invo ke(Configu rationMBea nImpl.java :376)
at com.sun.management.jmx.MBe anServerIm pl.invoke( MBeanServe rImpl.java :1557)
at com.sun.management.jmx.MBe anServerIm pl.invoke( MBeanServe rImpl.java :1525)
at weblogic.management.intern al.MBeanPr oxy.invoke (MBeanProx y.java:468 )
at weblogic.management.in---- ---------- - nested within: ------------------
weblogic.management.consol e.utils.Se tException : An error occurred while updating Targets-Server on Proxy for mydomain:Name=dvdProject,T ype=JDBCCo nnectionPo ol - with nested exception:
[java.lang.reflect.Invocat ionTargetE xception - with target exception:
[weblogic.management.Distr ibutedMana gementExce ption: Distributed Management [1 exceptions]]]
at weblogic.management.consol e.actions. mbean.DoEd itMBeanAct ion.perfor m(DoEditMB eanAction. java:155)
at weblogic.management.consol e.actions. internal.A ctionServl et.doActio n(ActionSe rvlet.java :171)
at weblogic.management.consol e.actions. internal.A ctionServl et.doPost( ActionServ let.java:8 5)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 760)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at weblogic.servlet.internal. ServletStu bImpl.invo keServlet( ServletStu bImpl.java :262)
at weblogic.servlet.internal. ServletStu bImpl.invo keServlet( ServletStu bImpl.java :198)
at weblogic.servlet.internal. WebAppServ letContext .invokeSer vlet(WebAp pServletCo ntext.java :2678)
at weblogic.servlet.internal. ServletReq uestImpl.e xecute(Ser vletReques tImpl.java :2412)
at weblogic.kernel.ExecuteThr ead.execut e(ExecuteT hread.java :140)
at weblogic.kernel.ExecuteThr ead.run(Ex ecuteThrea d.java:121 )
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.Distri
[weblogic.management.Deplo
[weblogic.common.ResourceE
at weblogic.management.intern
at weblogic.management.intern
at com.sun.management.jmx.MBe
at com.sun.management.jmx.MBe
at weblogic.management.intern
at weblogic.management.in----
weblogic.management.consol
[java.lang.reflect.Invocat
[weblogic.management.Distr
at weblogic.management.consol
at weblogic.management.consol
at weblogic.management.consol
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at weblogic.servlet.internal.
at weblogic.servlet.internal.
at weblogic.servlet.internal.
at weblogic.servlet.internal.
at weblogic.kernel.ExecuteThr
at weblogic.kernel.ExecuteThr
still looks like its not finding your driver class
chechk the jar contains the specified class
chechk the jar contains the specified class
ASKER
ok i got it solve, the classpath wasnt' set correctly at the right place in the startweblogic.cmd .. thx anyway
Class.forName("oracle.jdbc