aspose file tools*
The moose likes Object Relational Mapping and the fly likes java.sql.SQLException: No suitable driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.sql.SQLException: No suitable driver" Watch "java.sql.SQLException: No suitable driver" New topic
Author

java.sql.SQLException: No suitable driver

Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34
Hi,

I am new in hibernate, i want to on connect DB2 database. but i got this exception:

org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
at Controller.service(Controller.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:675)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:334)
at com.evermind.server.http.HttpRequestHandler.doDispatchRequest(HttpRequestHandler.java:942)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:843)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:658)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:626)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:417)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:189)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:163)
at oracle.oc4j.network.ServerSocketReadHandler$ClientRunnable.run(ServerSocketReadHandler.java:275)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:237)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:29)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:877)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)

hibernate.cfg.xml:


and my code is:


the problem appear in this statement
Transaction transaction = session.beginTransaction();

any help please
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

COM.ibm.db2.jdbc.app.DB2Driver


Try using "com.ibm.db2.jdbc.app.DB2Driver", instead.
Is you driver jar file available in classpath?
Also are you using Windows or Unix system to run the app?


If you are not laughing at yourself, then you just didn't get the joke.
Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34
I am using db2java.jar, but the exception : Caused by: java.sql.SQLException: No suitable driver

I am using Windows Vista to run the application
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

If you're sure that the jar file is in classpath, please check the complete path by opening the jar and see if the Driver file exists in the said location.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

What kind of application is this, web/standalone? If standalone then how you invoke the class (i.e.: command)? If web/enterprise application, where have you put the driver jar?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34
the strange is the jar file in classpath and the class is exist but it doesn't work.

i am trying to download latest db2java jar file, do you know where can i download db2java jar file?
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Did you check if there are two jar files ( different versions), sitting in different location and if that is causing this confusion?
Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34

What kind of application is this, web/standalone? If standalone then how you invoke the class (i.e.: command)? If web/enterprise application, where have you put the driver jar?

this is web appication, i used JDeveloper IDE, in Tools ---> Manage Library i Created my own library , after that i added the library to my project by Libraries and Classpath in project's properties.


Did you check if there are two jar files ( different versions), sitting in different location and if that is causing this confusion?

i think there is no other jar file in different location, because when i remove the jar from classpath and run the application i got this exception
Missing class: COM.ibm.db2.jdbc.app.DB2Driver

i think the problem in the jar file itself, but i can't find any web site to download another version from this jar.
Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34

What kind of application is this, web/standalone? If standalone then how you invoke the class (i.e.: command)? If web/enterprise application, where have you put the driver jar?

this is web appication, i am using JDeveloper 11g IDE, in Tools ---> Manage Library i Created my own library , after that i added the library to my project by Libraries and Classpath in project's properties.


Did you check if there are two jar files ( different versions), sitting in different location and if that is causing this confusion?

i think there is no other jar file in different location, because when i remove the jar from classpath and run the application i got this exception
Missing class: COM.ibm.db2.jdbc.app.DB2Driver

i think the problem in the jar file itself, but i can't find any web site to download another version from this jar.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Why is the COM capitalized?
Omar Mohaidat
Ranch Hand

Joined: Jan 16, 2008
Posts: 34
The db2java jar file contains COM capitalized. so i write the path of COM.ibm.db2.jdbc.app.DB2Driver class as in jar file.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Omar Mohaidat wrote:....this is web appication, i am using JDeveloper 11g IDE, in Tools ---> Manage Library i Created my own library , after that i added the library to my project by Libraries and Classpath in project's properties.

Just to make sure, do you have the jar file in the lib directory inside the container once the application deployed? And have checked with the DB documentation for the compatible driver with what you have got?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: No suitable driver