-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to connect hibernate and DB2
PostPosted: Thu Mar 31, 2011 2:49 am 
Newbie

Joined: Thu Mar 31, 2011 2:42 am
Posts: 4
I am running an application that used struts and hibernate. I am currently using Derby database. Now i have to shift on DB2 database.
I an giving the below mentioned settings in hibernate configuration file.

<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="connection.driver_class">com.ibm.db2.jdbc.app.DB2Driver</property>
<property name="connection.url">jdbc:db2://1988.144.141.34:500/db</property>
<property name="connection.username">Db2admin</property>
<property name="connection.password">******</property>

I also included 2 jars for DB2 (db2jcc.jar & db2jcc_license_cu.jar).

But I got exception.

Caused by:
java.lang.Throwable: org.hibernate.HibernateException: JDBC Driver class not found: com.ibm.db2.jdbc.app.DB2Driver
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:66)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
... 179 more
Caused by:
java.lang.Throwable: java.lang.ClassNotFoundException: com.ibm.db2.jdbc.app.DB2Driver
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:131)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
... 185 more

What should be the reason.

Thanks
Imran Tariq


Last edited by imrantariq on Tue May 22, 2012 2:45 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to connect hibernate and DB2
PostPosted: Thu Mar 31, 2011 4:32 am 
Contributor
Contributor

Joined: Mon Feb 28, 2011 7:27 pm
Posts: 20
Location: France
Hi,

It's because the configured JDBC driver is not found in your application class path (java.lang.ClassNotFoundException). Maybe you have made a mistake in the driver name. I've seen that the driver name could be COM.ibm.db2.jdbc.app.DB2Driver (http://publib.boulder.ibm.com/infocente ... rivers.htm).

Hope this help

--Kevin

PS: for questions related to Hibernate, you should use this forum section viewforum.php?f=1


Top
 Profile  
 
 Post subject: Re: How to connect hibernate and DB2
PostPosted: Thu Mar 31, 2011 5:44 am 
Newbie

Joined: Thu Mar 31, 2011 2:42 am
Posts: 4
Thanks this problem is over but there's another.

I am getting this error

Code:
14:22:17,804 WARN  [JDBCExceptionReporter] SQL Error: -204, SQLState: 42704
14:22:17,804 ERROR [JDBCExceptionReporter] DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.OPENINCIDENT, DRIVER=3.57.82
14:22:17,804 WARN  [JDBCExceptionReporter] SQL Error: -727, SQLState: 56098
14:22:17,804 ERROR [JDBCExceptionReporter] DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;DB2ADMIN.OPENINCIDENT, DRIVER=3.57.82
14:22:17,804 WARN  [JDBCExceptionReporter] SQL Error: -727, SQLState: 56098
14:22:17,804 ERROR [JDBCExceptionReporter] DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;DB2ADMIN.OPENINCIDENT, DRIVER=3.57.82
14:22:17,804 ERROR [VisualListAction] com.exceptions.DaoException: Unable to fetch OpenIncident Items.
14:22:17,804 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception


Error code 42704 means that OpenIncident table does not exist. But it exists in the database.

Any idea what could be the problem? Problem with schema or anything else?


Last edited by imrantariq on Tue May 22, 2012 3:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to connect hibernate and DB2
PostPosted: Thu Mar 31, 2011 6:34 am 
Newbie

Joined: Thu Mar 31, 2011 2:42 am
Posts: 4
Its solved.

Problem was with database schema.

i was using

schema.tableName

when I use

schema1.tableName

it works. Because in DB schema was schema1.


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