Hibernate Verbindung geht nach 2 Minuten verloren

qwerqer

Mitglied
Hallo!

Ich habe ein großes Problem in meinem Schul-Projekt...

Und zwar folgendes:

Wenn meine Anwendung circa 2 - 3 Minuten im "Leerlauf" läuft (also es werden keine Abfragen erzeugt), dann erhalte ich folgende Exception wenn ich wieder eine Abfrage absetzen möchte:
Java:
Exception in thread "AWT-EventQueue-0" org.hibernate.TransactionException: commit failed
	at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:185)
	at at.fhv.roomanizer.technicalServices.HibernateManager.executeQuery(HibernateManager.java:220)
	at at.fhv.roomanizer.persistence.person.DBAddressCountryFacade.getAllDBCountries(DBAddressCountryFacade.java:191)
	at at.fhv.roomanizer.persistence.person.DBAddressCountryFacade.getAllCountries(DBAddressCountryFacade.java:175)
	at at.fhv.roomanizer.domain.person.AddressCountryFacade.getAllCountries(AddressCountryFacade.java:42)
	at at.fhv.roomanizer.application.CountryController.getAllCountries(CountryController.java:33)
	at at.fhv.roomanizer.application.CheckInController.getAllCountries(CheckInController.java:54)
	at at.fhv.roomanizer.presentation.CustomerInformationPanel.initCountries(CustomerInformationPanel.java:86)
	at at.fhv.roomanizer.presentation.CustomerInformationPanel.<init>(CustomerInformationPanel.java:43)
	at at.fhv.roomanizer.presentation.BookingDetailPanel.initComponents(BookingDetailPanel.java:238)
	at at.fhv.roomanizer.presentation.BookingDetailPanel.<init>(BookingDetailPanel.java:72)
	at at.fhv.roomanizer.presentation.CheckInPanel.initComponents(CheckInPanel.java:130)
	at at.fhv.roomanizer.presentation.CheckInPanel.<init>(CheckInPanel.java:37)
	at at.fhv.roomanizer.presentation.GUIController.openCheckIn(GUIController.java:59)
	at at.fhv.roomanizer.presentation.NavigationPanel$CheckInButtonActionListener.actionPerformed(NavigationPanel.java:96)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Caused by: org.hibernate.TransactionException: unable to commit against JDBC connection
	at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:116)
	at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:178)
	... 50 more


Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
	at com.mysql.jdbc.Util.getInstance(Util.java:386)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
	at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1663)
	at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112)
	... 51 more

Wobei die die erste eigentlich nur anzeigt, wo der Fehler ausgelöst wurde (beim Klick auf den Button, welcher eine Abfrage auslöst) und die zweite und dritte die wirklichen Fehler sind (wenn ich das richtig sehe)

dh:
Caused by: org.hibernate.TransactionException: unable to commit against JDBC connection

und

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.

Kann mir jemand erklären warum das so ist?

Infos zum Programm:
Session wird nie geschlossen (wenn die Session zu war, konnte ich keine updates mehr machen - konnte das Problem selbst leider nicht beheben und meine Mitschüler haben mir diesen Tipp gegeben (so klappen auch die updates))

hibernate.cfg.xml (URL, Username und PW entfernt)
Java:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="hibernate.connection.password">******</property>
		<property name="hibernate.connection.url">*****?autoReconnect=true</property>
		<property name="hibernate.connection.username">******</property>
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
		<property name="hibernate.show_sql">true</property>
		<property name="hibernate.current_session_context_class">thread</property>
		<property name="hibernate.transaction.auto_close_session">false</property>
	</session-factory>
</hibernate-configuration>

Vielen herzlichen Dank!

Grüße,
Stefan
 

qwerqer

Mitglied
Hallo!

Entschuldigung - habe deinen Beitrag gelesen und vergessen zu antworten.
War sehr im Stress auf Grund des Projektes.

Haben alles versucht (auch das was Du uns gepostet hast). Es hat aber leider nichts geholfen.

Die Lösung war den DB-Server zu wechseln. Mit dem neuen haben wir keine Probleme mehr.

Gruß
Stefan
 

Ähnliche Java Themen

Neue Themen


Oben