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.  [ 2 posts ] 
Author Message
 Post subject: Problem Setting Up Hibernate to Work With Sybase
PostPosted: Fri Feb 04, 2005 6:01 pm 
Newbie

Joined: Mon Jan 24, 2005 7:12 pm
Posts: 5
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1

Mapping documents:
<session-factory>
<property name="connection.datasource">UCDB4</property>
<property name="hibernate.jndi.url">
jdbc:sybase:Tds:sybserv4.ucop.edu:2125/pwanew
</property>
<property name="hibernate.jndi.class">
com.sybase.jdbc2.jdbc.SybDriver
</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">pass</property>
<!-- dialect for Sybase -->
<property name="dialect">
net.sf.hibernate.dialect.SybaseDialect
</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
net.sf.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<mapping resource="edu/ucop/ucap/Event.hbm.xml"/>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.7
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: edu/ucop/ucap/Event.hbm.xml
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: edu.ucop.ucap.Event -> EVENTS
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Feb 4, 2005 12:56:06 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.SybaseDialect
Feb 4, 2005 12:56:06 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Feb 4, 2005 12:56:06 PM net.sf.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{java.naming.provider.url=jdbc:sybase:Tds:sybserv4.ucop.edu:2125/pwanew, java.naming.factory.initial=com.sybase.jdbc2.jdbc.SybDriver}
Feb 4, 2005 12:56:06 PM net.sf.hibernate.util.NamingHelper getInitialContext
SEVERE: Could not obtain initial context
javax.naming.NoInitialContextException: Cannot instantiate class: com.sybase.jdbc2.jdbc.SybDriver [Root exception is java.lang.ClassCastException]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.sf.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at edu.ucop.ucap.EventManager.<init>(EventManager.java:20)
at edu.ucop.ucap.EventManager.main(EventManager.java:28)
Caused by: java.lang.ClassCastException
... 12 more
Feb 4, 2005 12:56:06 PM net.sf.hibernate.connection.DatasourceConnectionProvider configure
SEVERE: Could not find datasource: UCDB4
javax.naming.NoInitialContextException: Cannot instantiate class: com.sybase.jdbc2.jdbc.SybDriver [Root exception is java.lang.ClassCastException]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.sf.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at edu.ucop.ucap.EventManager.<init>(EventManager.java:20)
at edu.ucop.ucap.EventManager.main(EventManager.java:28)
Caused by: java.lang.ClassCastException
... 12 more
net.sf.hibernate.HibernateException: Could not find datasource
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at edu.ucop.ucap.EventManager.<init>(EventManager.java:20)
at edu.ucop.ucap.EventManager.main(EventManager.java:28)
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com.sybase.jdbc2.jdbc.SybDriver [Root exception is java.lang.ClassCastException]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.sf.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
... 6 more
Caused by: java.lang.ClassCastException

Name and version of the database you are using:Sybase 12.5

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I'm having trouble setting up my configuration file to connect to Sybase 12.5.

Here's what I've done so far:
- I set up The Road to Hibernate Tutorial examples and ran them successfullly.

- I set up a small sample Hibernate program. It gave me errors when I tried to connect to Sybase.

- I went back to The Road to Hibernate Tutorial example and tried to set it up using Sybase. This set up included changing the hibernate.cfg.xml file and adding the jconn2.jar file to the program classpath. When I try to run the Road to Hibernate Tutorial example after making these changes it gives me the errors listed above.

If anyone has used Hibernate with Sybase and could tell me where I'm going wrong, I'd appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 12:33 am 
Newbie

Joined: Wed Jan 05, 2005 11:32 pm
Posts: 7
I have used Hibernate with Sybase. I have used it with WebLogic and JBoss connection pools as well as with Hibernate connection pools. I use the hibernate.properties file to configure it. The example in hibernate-2.1\etc has a Sybase connection pool configured:

## Sybase

#hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver
#hibernate.connection.username sa
#hibernate.connection.password sasasa
#hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb

Just uncomment and change the values to match your configuration.

I have not used hibernate.cfg.xml , but your configuration appears to have connection pool information in the "hibernate.jndi.url" property, which from the log appears to be being used to attempt to create an initial context.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.