-->
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.  [ 1 post ] 
Author Message
 Post subject: Couldn't get connection pooling to work
PostPosted: Thu Jan 12, 2006 1:59 pm 
Newbie

Joined: Thu Jan 12, 2006 1:44 pm
Posts: 3
I followed this hibernate tutorial at http://www.gloegl.de/8.html and I a little modification to it so that it runs in J2EE app. I could get it to work with regular jdbc connection based on the setting below:-

Code:
<session-factory>   
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>   
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://myserverbox:1433;databaseName=hibernateDb</property>   
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">user</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="show_sql">true</property>   
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>   
<property name="hibernate.hbm2ddl.auto">update</property> 
<mapping resource="test/hbm/dao/beans/Event.hbm.xml" />
</session-factory>


So, I tried to convert it to run with connection pooling with the following settings:-

Code:
<session-factory>   
<property name="hibernate.connection.datasource">java:comp/env/jdbc/hibernateDb</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="show_sql">true</property>   
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>   
<property name="hibernate.hbm2ddl.auto">update</property>    
<mapping resource="test/hbm/dao/beans/Event.hbm.xml" />
</session-factory>


When I run it again, I get the following error:-

Code:
1/12/06 11:37:23:225 CST] 0000003a SystemOut     O Hibernate: insert into Event (eventtitle) values (?)
[1/12/06 11:37:23:245 CST] 0000003a JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 0, SQLState: HY000
[1/12/06 11:37:23:255 CST] 0000003a JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions [IBM][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement
[1/12/06 11:37:23:295 CST] 0000003a ServletWrappe A   SRVE0242I: [hbmEAR] [/hbm] [/WEB-INF/jsp/test.jsp]: Initialization successful.
[1/12/06 11:37:23:305 CST] 0000003a LocalTranCoor W   WLTC0033W: Resource jdbc/hibernateDb rolled back in cleanup of LocalTransactionContainment.
[1/12/06 11:37:23:315 CST] 0000003a LocalTranCoor W   WLTC0032W: One or more local transaction resources were rolled back during the cleanup of a LocalTransactionContainment.
[1/12/06 11:37:23:285 CST] 0000003a SystemErr     R org.hibernate.exception.GenericJDBCException: could not insert: [test.hbm.dao.beans.Event]   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)


At first, I thought I messed up my JNDI settings in my server and web.xml. So, I did a test on the following codes with the same sql statement generated by hibernate, and it works:-

Code:
   
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/hibernateDb");
Connection con = ds.getConnection();
PreparedStatement ps = con.prepareStatement("insert into Event(eventtitle) values(?)");
ps.setString(1, "TEST");
ps.executeUpdate();
con.close();      


May I know where I set wrongly in my hibernate.cfg.xml for my connection pooling? I have been messing around for 2 hours now, but still couldn't get it to work.

Any tips would be greatly appreciated! Thanks.
Code:


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

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.