aspose file tools*
The moose likes Object Relational Mapping and the fly likes problem with hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem with hibernate" Watch "problem with hibernate" New topic
Author

problem with hibernate

ilyas besli
Greenhorn

Joined: Sep 13, 2007
Posts: 9
I start to learning hibernate.
I find some example from internet but always same error occurs.
I use java 1.4.2 with eclipse and Postgresql.

The error is:

Java Virtual Machine Launcher:
Fatal exception occurred. Program will exit

"and then 2 exception occured"

org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
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:426)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement(AbstractBatcher.java:123)
at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:83)
at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at hibernate.HibernateManager.saveUser(HibernateManager.java:14)
at hibernate.TestClient.testSaveHibernate(TestClient.java:26)
at hibernate.TestClient.main(TestClient.java:43)
Caused by: java.sql.SQLException: ERROR: SET AUTOCOMMIT TO OFF is no longer supported

at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
at org.postgresql.jdbc1.AbstractJdbc1Connection.setAutoCommit(AbstractJdbc1Connection.java:957)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:112)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
... 16 more
Exception in thread "main"

for any help, thanks
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
can you send us your hibernate configuration file?


SCJP, SCJD, SCWCD, SCBCD
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sounds like it is probably something to do with your driver. Are you sure you are using the latest version?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ilyas besli
Greenhorn

Joined: Sep 13, 2007
Posts: 9
I am using pg73jdbc3.jar postgresql driver.

My hibernate configuration file is:

<?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>
<property name="connection.driver_class"> org.postgresql.Driver</property>
<property name="connection.url"> jdbc ostgresql://localhost </property>
<property name="connection.username">postgres</property>
<property name="connection.password">ilyas</property>
<property name="dialect"> org.hibernate.dialect.PostgreSQLDialect </property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory </property>
<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext and let Hibernate bind the session automatically to the thread-->
<property name="current_session_context_class"> thread </property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql"> true </property>
<property name="hibernate.connection.autocommit"> false </property>
<!-- mapping files -->
<mapping resource="hibernate/Hibernate.hbm.xml" />
</session-factory>
</hibernate-configuration>
ilyas besli
Greenhorn

Joined: Sep 13, 2007
Posts: 9
My driver is running properly. Because I used it my old project.
In my opinion, java could not reach to driver.

Because
Program say that;
JVM launcher
Fatal exception occurred. Program will exit
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Originally posted by ilyas besli:
My driver is running properly. Because I used it my old project.
In my opinion, java could not reach to driver.

Because
Program say that;
JVM launcher
Fatal exception occurred. Program will exit


It did reach the driver:

Caused by: java.sql.SQLException: ERROR: SET AUTOCOMMIT TO OFF is no longer supported


A quick bit of googling suggests if you try the latest version of the driver this issue will go away.
ikenna okpala
Greenhorn

Joined: Jul 12, 2006
Posts: 27
i think your driver not available or corrupt these thing usually occur at runtime.

trys and check your drivers presence on your system.

verify also your that your files are in the right order of reference.


SCJP 5.0, SCWCD 1.4, SCBCD 5.0, SCEA 5.0, OCP:AD "there is no traffic in the extra mile..."
ilyas besli
Greenhorn

Joined: Sep 13, 2007
Posts: 9
I download latest version of postgresql driver
but same error occurred.
And I test driver it is work properly.

My hibernate.hbm.xml file is that:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>

<class name="hibernate.Deneme" table="HibernateTable">
<id name="userId" type="java.lang.Long" column="USER_ID">
<generator class="increment" />
</id>
<property name="firstName" type="java.lang.String"
column="FIRST_NAME" length="20" />
<property name="lastName" type="java.lang.String"
column="LAST_NAME" length="20" />
<property name="age" type="java.lang.Integer" column="AGE"
length="-1" />
<property name="email" type="java.lang.String" column="EMAIL"
length="20" />
</class>

</hibernate-mapping>

-----------------------------------------------

My hibernate.cfg.xml file is that:

<?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>
<property name="connection.driver_class"> org.postgresql.Driver</property>
<property name="connection.url"> jdbc ostgresql://localhost/postgres </property>
<property name="connection.username">postgres</property>
<property name="connection.password">ilyas</property>
<property name="dialect"> org.hibernate.dialect.PostgreSQLDialect </property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory </property>
<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext and let Hibernate bind the session automatically to the thread-->
<property name="current_session_context_class"> thread </property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql"> true </property>
<property name="hibernate.connection.autocommit"> false </property>
<!-- mapping files -->
<mapping resource="hibernate/Hibernate.hbm.xml" />
<mapping resource="events/Event.hbm.xml" />
</session-factory>
</hibernate-configuration>


Does it have any error?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No, your Hibernate configuration looks fine. The problem is most likely your driver. Are you sure the old driver is still not in your classpath? There seems to be a problem with pg73jdbc3.jar.
coy peng
Greenhorn

Joined: Sep 24, 2007
Posts: 3
please update your mysql driver
 
Don't get me started about those stupid light bulbs.
 
subject: problem with hibernate