aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Hibernate :No suitable driver found for jdbc:sqlserver://localhost:1433;DatabaseName=XXX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Hibernate :No suitable driver found for jdbc:sqlserver://localhost:1433;DatabaseName=XXX" Watch "Hibernate :No suitable driver found for jdbc:sqlserver://localhost:1433;DatabaseName=XXX" New topic
Author

Hibernate :No suitable driver found for jdbc:sqlserver://localhost:1433;DatabaseName=XXX

Hitesh Kumar C
Ranch Hand

Joined: Sep 12, 2008
Posts: 35

Hi,

I was trying to connect SQL Server 2005 through JDBC. Here is my Hibernate Configuration File :




I added the latest SQL JDBC 4.0 jar to my Eclipse Project Build classpath, but it is throwing an exception while running application :



I tried the connection string with username and password also but that also didn't worked for me.

The same URL is working fine for me on a Console Java Application, but since i am trying this on this web, so i think it is not able to find the SQLJDBC4.0.jar on the Server path.

Where i can add the Jar apart from Project Classpath so it will search the Appropriate Driver from the Jar?

I added SQLJDBC4.0 jar under Project > Properties > Libraries.

Kindly suggest?

Any comments and help is greatly appreciated.


OCJP 6.0, OCPJWCD 5
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

You must have the class:
com.microsoft.sqlserver.jdbc.SQLServerDriver
in your classpath. Database vendors usually provide drivers for Java. When you are using Hibernate in a standalone application you can load the driver's class manually:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

When you run your application, is it running standalone or within an application server?
Hitesh Kumar C
Ranch Hand

Joined: Sep 12, 2008
Posts: 35

#James Boswell
It is running on Web Application Server(JBoss). In Console it is working perfectly fine!

#Lucas Smith
I added the jar to the Project classpath having the SQLServerDriver class. I think that automatically uploads the file on the Server.
I tried this also:


but, didn't worked.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I think that your JAR that contains the driver is not deployed on the server. What kind of an archive do you use? Is it WAR or EAR?
Hitesh Kumar C
Ranch Hand

Joined: Sep 12, 2008
Posts: 35

WAR
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

Hitesh

Adding the jar to the classpath within eclipse does not automatically add it to the server's classpath when your application is deployed.

What version of JBoss are you using? Prior to version 7, the standard location for additional jar files is <JBOSS_HOME>/server/<INSTANCE_NAME>/lib

If you using a standard instance, your <INSTANCE_NAME> will be default.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

OK, so change the file extension of this file from war to zip, extract it and take a look if the extracted folder WEB-INF/lib contains JAR with the driver.
However James Boswell has a good idea - the driver should be placed in the application server's lib folder.
Hitesh Kumar C
Ranch Hand

Joined: Sep 12, 2008
Posts: 35

Lucas Smith
Yes, the file is there.

James Boswell
Let me try that and get back.
Hitesh Kumar C
Ranch Hand

Joined: Sep 12, 2008
Posts: 35

James Boswell
Thanks for your help. It worked for me!
I copied the Sqljdbc4.0.jar to E:\Servers\jboss-6.1.0.Final\server\default\lib and working fine.
I thought that the Server automatically will take care of the classpath uploads.


Lucas Smith
Thanks for your suggestions and efforts.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate :No suitable driver found for jdbc:sqlserver://localhost:1433;DatabaseName=XXX