-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Web Application
PostPosted: Thu Jun 07, 2007 2:40 am 
Newbie

Joined: Thu Jun 07, 2007 1:59 am
Posts: 3
Hi,

I am a newbie to Hibernate & J2EE

Am trying to use hibernate with struts2. while saving an object to db am getting "No suitable driver".Am getting this error only when running it as a web application.When i run the same Hibernate code using same hibernate mapping file as a standalone it's working fine.

I placed the db2java.zip file in /WEB-INF/lib.Should i need to do anything else..?

Can anyone help to resolve it???
Thanx in advance....

Below are my configuration:
--------------------------
Hibernate version:3.2.2
AppServer : ApacheTomcat v6.0.13
FrameWork : Struts v2.0.5
DB : DB2 v8.1.0
IDE : MyEclipse v5.1.0

Exception:
----------
[http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - No suitable driver
[http-8080-1] ERROR org.apache.struts2.dispatcher.Dispatcher - Could not execute action
org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:424)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)

.
.
.
.
.
.

Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:421)
... 110 more





Below is my Hibernate Mapping xml:
-----------------------------------

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">COM.ibm.db2.jdbc.app.DB2Driver</property>
<property name="connection.url">jdbc:db2:testdb</property>
<property name="connection.username">admin</property>
<property name="connection.password">pass123</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<!-- Enable Hibernate's automatic session context management -->
<!--property name="current_session_context_class">thread</property-->
<!-- Disable the second-level cache -->
<!-- property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property-->
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<mapping resource="PayTxn.hbm.xml" />

</session-factory>
</hibernate-configuration>


Hibernate Code:
---------------
SessionFactory sf = new Configuration().configure().buildSessionFactory();
System.out.println("sf : " + sf);
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
payTxnTO.setPayTxnId(113);
session.saveOrUpdate(payTxnTO);
tx.commit();


Thanks& Regards
Bala


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 1:04 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Do you have a db2java jar file instead of a zip file? Try putting a jar file into WEB-INF/lib

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 1:17 am 
Newbie

Joined: Thu Jun 07, 2007 1:59 am
Posts: 3
Hi himawan

Thanks for ur reply.

I already tried by placing the db2java.jar in my WEB-INF/lib.But it doesn't work.I got the same error...

[http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - No suitable driver
[http-8080-1] ERROR org.apache.struts2.dispatcher.Dispatcher - Could not execute action
org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:424)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)

Thanks
Bala


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 1:27 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
How about putting it into shared/lib

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 1:47 am 
Newbie

Joined: Thu Jun 07, 2007 1:59 am
Posts: 3
I tried to put db2java.jar in two locations...But no luck...got the same error...

F:\Apache Tomcat\apache-tomcat-6.0.13\lib
F:\Apache Tomcat\apache-tomcat-6.0.13\server\lib

Also please have a look at http://www.hibernate.org/114.html. I Followed the same procedure in the above mentioned link...and i got the same error.

Also tried to run the same web app in JBOSS 4.2.0 and got the same error...

Anyother clues???


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