-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Strange Hibernate Exception
PostPosted: Tue Aug 09, 2005 8:44 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
Hi all,

no need to mention I'm a very new Hibernate user, failing to resolve this easy issue :

Code:
net.sf.hibernate.HibernateException: JDBC Driver class not found: com.sybase.jdbc2.jdbc.SybDriver 
   at net.sf.hibernate.connection.DBCPConnectionProvider.configure(DBCPConnectionProvider.java:69)
   at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
   at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
   at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)


If I have included all the necessary JAR:s to my classpath, how can I get this error ?

Best regards
/Andreas


Top
 Profile  
 
 Post subject: Re: Strange Hibernate Exception
PostPosted: Tue Aug 09, 2005 8:47 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Nitzer_Ebb wrote:
Hi all,

no need to mention I'm a very new Hibernate user, failing to resolve this easy issue :

Code:
net.sf.hibernate.HibernateException: JDBC Driver class not found: com.sybase.jdbc2.jdbc.SybDriver 
   at net.sf.hibernate.connection.DBCPConnectionProvider.configure(DBCPConnectionProvider.java:69)
   at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
   at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
   at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)


If I have included all the necessary JAR:s to my classpath, how can I get this error ?

Best regards
/Andreas


You obviously haven't included the jar containing the Sybase driveer in your classpath.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 8:59 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
Hi again,

I have checked my classpath many times, and I'm quite sure it's correct. I will try to get the classpath at runtime, maybe the classes are loaded in some strange order.

Best regards
/Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:04 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Nitzer_Ebb wrote:
Hi again,

I have checked my classpath many times, and I'm quite sure it's correct. I will try to get the classpath at runtime, maybe the classes are loaded in some strange order.

Best regards
/Andreas


I would also make sure that the jar that you believe has the Sybase Driver in it does has a class with the name specified inside it.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:13 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
The class it can't found exists in the JAR. That has been checked.

Best regards
/Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:23 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Try something like this:

Code:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");


If the class is really in the classpath.
It will work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:26 am 
Newbie

Joined: Tue Aug 09, 2005 9:09 am
Posts: 3
Maybe hibernate expects different driver? When you select dialect you have to include driver for that database. For example if I use Oracle I have to put oracle drivers in my class path. I don't know how do Hibernate knows exact name for the Oracle but it woked fine for me.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:31 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
steckemetz wrote:
Try something like this:

Code:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");


If the class is really in the classpath.
It will work.


Tested that.It worked fine, i.e no exception thrown.

Best regards
/Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 9:33 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
katukas wrote:
Maybe hibernate expects different driver? When you select dialect you have to include driver for that database. For example if I use Oracle I have to put oracle drivers in my class path. I don't know how do Hibernate knows exact name for the Oracle but it woked fine for me.


Have done that also. Here is my hibernate.properties file ( excerpt from it ) :

Code:
hibernate.dialect net.sf.hibernate.dialect.SybaseDialect   
hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver 
hibernate.connection.username testUser
hibernate.connection.password testPassword
hibernate.connection.url jdbc:sybase:Tds:localhost:2639/test_db

Best regards
/Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 2:34 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Try the hibernate.cfg.xml configuration.
Maybe a space or something in the
"com.sybase.jdbc2.jdbc.SybDriver" on the property file.
Never tried Sybase with hibernate, but sure it does not require an specific driver ... it will use the string entered in the prop/cfg file.

Good Luck

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.