-->
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: Exception while creating temporary tables
PostPosted: Fri Jul 15, 2005 12:58 pm 
Newbie

Joined: Tue Apr 19, 2005 4:32 pm
Posts: 14
Hibernate version: 3.0

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

Something similar has been discussed here a few times before, but none of those posts provided a solution to my problem.

I get the following exception while attempting to create a temporary table with JDBC using the connection obtained from Hibernate session:

com.sybase.jdbc2.jdbc.SybSQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.

Full stack trace:
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:414)
at xxx.HibernateSession.createTempAuditTable(HibernateSession.java:453)

Following is the Code (1):
Code:
Session session = sessionFactory.openSession();
Connection conn = session.connection();
Statement stmt = con.createStatement();
stmt.executeUpdate("create table #whatever(col1 int)");


What's interesting is that I don't get any exceptions when I do the same using a JDBC connection created from scratch:

Code (2):
Code:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
Connection conn = DriverManager.getConnection(dbUrl, uid, pwd);
conn.setAutoCommit(false);
Statement stmt = con.createStatement();
stmt.executeUpdate("create table #whatever(col1 int)");


Auto commit is set to false in BOTH cases (automatically by Hibernate in first and explicitely in code in the second) and I do not explicitely begin a new transaction in either case.

So what is different about the JDBC connection obtained through Hibernate?

Thanks, Rishabh


Top
 Profile  
 
 Post subject: Solved
PostPosted: Mon Jul 18, 2005 1:20 pm 
Newbie

Joined: Tue Apr 19, 2005 4:32 pm
Posts: 14
The problem seems to be with using the DriverManagerConnectionProvider class as the connection provider.

Using either C3P0ConnectionProvider or DatasourceConnectionProvider fixes the issue.

Rishabh


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.