-->
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: Does the session object have an INTRINSIC transaction?
PostPosted: Fri Jun 06, 2008 3:06 pm 
Newbie

Joined: Wed May 28, 2008 11:11 am
Posts: 12
I am getting errors from a PostgreSQL database when trying to programmatically create a new Database. The error I am getting is:

ERROR: CREATE DATABASE cannot run inside a transaction block

Hmm..the thing is that I did not set up any transaction objects in my code.


Code:

Session session = HibernateUtil.getSessionFactory().openSession();
Connection c = session.connection();
String databaseName = "TEST";
String user = "postgres";

String qString = "CREATE DATABASE \"" + databaseName + "\" WITH OWNER = \"" + user + "\" ENCODING = 'SQL_ASCII' TABLESPACE = pg_default";

Statement st = c.createStatement();
st.execute(qString);
st.close();

So the DB is complaining that this CREATE DATABASE statement is being executed from within a transaction because it only supports this operation outside of an explicit transaction.

IS THERE ANY WAY TO GET CONNECTION TO A DB WITHOUT A TRANSACTION?

Thanks Venkman


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.