-->
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: Hibernate with Informix - Transactions not Supported
PostPosted: Wed Nov 03, 2010 7:04 am 
Newbie

Joined: Wed Nov 03, 2010 6:55 am
Posts: 2
Hello All,

I've been trying to get Hibernate to work with Informix on Linux, but have been facing a couple of issues.
Here's the errant piece of code:

Session session = null;

System.out.println("Starting session");

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
System.out.println("Loading config");
session =sessionFactory.openSession();



System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(6);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_38@yahoo.com");
session.save(contact);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
try {
// Actual contact insertion will happen at this step
session.flush();
session.close();
} catch (Exception e){
e.printStackTrace();
}

}


Pretty standard example, I picked it up from a Hibernate tutorial.

I think I've configured the xmls and classpaths correctly.

Here's the error I received upon running the jar:

Starting session
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment ).
log4j:WARN Please initialize the log4j system properly.
Loading config
Opened session
Inserting Record
Done
org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException (SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j ava:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp er.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp er.java:29)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.jav a:384)
at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:141)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:88)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.j ava:73)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.j ava:66)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatc her.java:130)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntit yPersister.java:1809)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntit yPersister.java:2171)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.ja va:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio ns(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa der.java:56)
Caused by: java.sql.SQLException: Transactions not supported
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:395)
at com.informix.jdbc.IfxSqliConnect.setAutoCommit(IfxSqliConnect.java:18 41)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnectio n(DriverManagerConnectionProvider.java:112)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.jav


... 20 more



Sigh. 20 more to plod through. I'd really appreciate help with the first though.

Help, please! And many thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate with Informix - Transactions not Supported
PostPosted: Wed Nov 03, 2010 10:55 am 
Beginner
Beginner

Joined: Tue Oct 26, 2010 6:12 pm
Posts: 29
The root cause appears to be:

Quote:
Caused by: java.sql.SQLException: Transactions not supported


Is your database logged or is it no-log? If it is a no-log database, you could try setting the property "connection.autocommit" to true in your hibernate properties.


Top
 Profile  
 
 Post subject: Re: Hibernate with Informix - Transactions not Supported
PostPosted: Wed Nov 03, 2010 2:54 pm 
Newbie

Joined: Wed Nov 03, 2010 6:55 am
Posts: 2
You mean add "hibernate.connection.autocommit" to hibernate.cfg.xml and set it to true?
Tried that, didn't work. :-/

Anything else that might work? Or am I going about this the wrong way?

Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate with Informix - Transactions not Supported
PostPosted: Fri Nov 05, 2010 12:07 pm 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
What dialect class are you using?


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.