Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with hibernate

 
ilyas besli
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you send us your hibernate configuration file?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like it is probably something to do with your driver. Are you sure you are using the latest version?
 
ilyas besli
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ilyas besli
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please update your mysql driver
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic