JDBC Verbindungsabbruch (Connection reset)

Status
Nicht offen für weitere Antworten.
T

timbo

Gast
Hallo,

ich habe ein RMI remote Object welches eine Datenbankverbindung zu einem MySQL Server über JDBC aufbaut. Soweit funktioniert alles super. Nach einiger Leerlaufzeit aber beendet der MySQL Server die Verbindung und ich bekomme dieses nicht abgefangen um die Verbindung neu zu initialisieren.

Das RMI Object wirft dann folgende Exception.

Code:
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Connection reset

STACKTRACE:

java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
        at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
        at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1902)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2351)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2862)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2988)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2917)
        at com.mysql.jdbc.Statement.executeQuery(Statement.java:824)
        at server.ProjektorDatabaseImpl.query(ProjektorDatabaseImpl.java:210)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
        at sun.rmi.transport.Transport$1.run(Transport.java:148)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:534)


** END NESTED EXCEPTION **

Hier der Code von meiner connect Funktion die immer am Anfang einer DB Operation aufgerufen wird.

Code:
private void connect()
	{	
		try
		{
			if( connection == null || connection.isClosed() )
			{					
				connection = DriverManager.getConnection("jdbc:"+properties.getProperty("type")+"://"+properties.getProperty("host")+"/"+properties.getProperty("database")+"", properties.getProperty("user"), properties.getProperty("password"));
				System.out.println("Datenbankverbindung hergestellt ...");
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();			
			connect();
		}
	}

Vielleicht kann mir jemand einen Hinweis geben wo ich da ansetzen kann.

Gruß, Tim
 

Bleiglanz

Gesperrter Benutzer
1. fang nur die SQL-Exception ab

2. wenn eine Ex fliegt, dann geht er in eine Endlosschleife?

3. in obigem Stacktrace fehlt diese Methode?

4. schau mal in die Doku, es gibt ein autoreconnect=true für die URL
 
T

timbo

Gast
Hallo,

autoReconnect=true hat geholfen.

Vielen Dank,

Gruß, Tim
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
Thallius JDBC getConnection kommt nicht zurück Netzwerkprogrammierung 1
R JDBC - Direktzugriff auf MySQL Netzwerkprogrammierung 15
T JDBC Transaktion autocommit Netzwerkprogrammierung 7
R Fehler bei RMI in Verbidung mit JDBC Netzwerkprogrammierung 6
F TCP Socket auf Verbindungsabbruch prüfen Netzwerkprogrammierung 15
Z Socket Server/Client vernünftiger Verbindungsabbruch Netzwerkprogrammierung 4
T Alternative Socket mit Verbindungsabbruch Erkennung Netzwerkprogrammierung 2
D Keine Benachrichtigung bei Verbindungsabbruch? Netzwerkprogrammierung 3
x46 Connection reset by peer: socket write error Netzwerkprogrammierung 6
F Probleme mit Connection Reset bei Telnet Verbindung Netzwerkprogrammierung 1
Thalion TCP Connection zu langsam Netzwerkprogrammierung 2
S Client Server Connection Netzwerkprogrammierung 4
C Handle Connection Problem Netzwerkprogrammierung 3
R Socket InputStream readObject > Connection Reset Netzwerkprogrammierung 3
L ssh connection; Zugriff auf 'screen' Prozess Netzwerkprogrammierung 5
C Client connection per Portforwarding auf einen lokalen Serverport Netzwerkprogrammierung 3
M Connection refused? Netzwerkprogrammierung 2
D Connection refused Netzwerkprogrammierung 3
B Client/Server Connection Problem Netzwerkprogrammierung 2
D Socket Socket absichtlich so schließen, dass Gegenseite java.net.SocketException: Connection reset wirft Netzwerkprogrammierung 4
C Socket Connection refused bei Internetverbindung - Welcher Port? Netzwerkprogrammierung 5
K Socket Exception Connection reset Netzwerkprogrammierung 9
VfL_Freak Socket SocketException: Connection reset Netzwerkprogrammierung 11
C Socket Socket: Connection timed out Netzwerkprogrammierung 3
T Empfangen klappt Senden nicht - Connection timed out Netzwerkprogrammierung 12
H java.net.ConnectException: Connection refused Netzwerkprogrammierung 3
Z Socket Connection reset by peer nur per IP nicht über localhost Netzwerkprogrammierung 13
RELAXccc HTTP Connection timed out: connect ?an was kann es liegen? Netzwerkprogrammierung 4
G Exception: Connection reset by peer: socket write error Netzwerkprogrammierung 2
N Socket verliert die Connection. Netzwerkprogrammierung 4
A UCP Connection über Proxy möglich? Netzwerkprogrammierung 7
M RMI - Connection Problem Netzwerkprogrammierung 7
trash HTTP Internet Connection bei Proxy ?! Netzwerkprogrammierung 3
D Client Server Problem, Methode readline() löst SocketException "Connection reset" aus Netzwerkprogrammierung 8
H RMI Connection refused bei RMI-Registry Netzwerkprogrammierung 10
S SSH-Connection - Auto-Vervollständigung mittels TAB Netzwerkprogrammierung 4
A Chatprogramm: Connection refused Netzwerkprogrammierung 4
T RMI RMI und VPN - callbackObject Connection refused Netzwerkprogrammierung 13
A Socket Client Server Connection wird aufgebaut aber keine daten geschickt. Netzwerkprogrammierung 5
J Connection Speed Test ohne Applet Netzwerkprogrammierung 5
0din Connection refused bei localhost?! Netzwerkprogrammierung 7
M FTP-Connection über FTP-Proxy Netzwerkprogrammierung 20
T Wie connection Reset abfragen/abfangen? Netzwerkprogrammierung 10
A RMI java.rmi.ConnectException: Connection refused to host: 1 Netzwerkprogrammierung 4
M chat funktioniert nicht (Connection refused: connect) Netzwerkprogrammierung 3
G InputStreamReader lässt TCP-Connection offen Netzwerkprogrammierung 9
X URL connection Problem Netzwerkprogrammierung 3
R ConnectException: Connection refused to host: 192.168.1.4 ? Netzwerkprogrammierung 8
sparrow Connection Reset bei Webserver, Java WebStart als Client Netzwerkprogrammierung 9
tfa RMI-Problem: Connection refused to host: 127.0.0.2 Netzwerkprogrammierung 4
G Connection zu MySQL ohne ODBC Netzwerkprogrammierung 8
IT-MaD Connection reset by peer: socket write error Netzwerkprogrammierung 2
B RMI & Connection refused to host Netzwerkprogrammierung 12
G httpUnit: Connection timed out Netzwerkprogrammierung 3
lhein java.io.IOException: Unable to establish loopback connection Netzwerkprogrammierung 4
Paule Connection Applet Servlet ohne Socket bzw RMI Netzwerkprogrammierung 2
B Multithreaded Server: Connection reset Netzwerkprogrammierung 4
M SocketException: Connection reset Netzwerkprogrammierung 10
G MAC / IP Connection Netzwerkprogrammierung 10
M Problem: connection abbrechen und login erkennen Netzwerkprogrammierung 2
M Umlaute gehen bei URL Connection verloren Netzwerkprogrammierung 6
M seltsam: java.net.SocketException: Connection reset Netzwerkprogrammierung 1
B RMI Connection Problem Netzwerkprogrammierung 13
T Dateien wia P2P Connection versenden Netzwerkprogrammierung 2
D Socketverbindung schlägt fehl - Connection refused: connect Netzwerkprogrammierung 4
H java.net.SocketException: Software caused connection abort Netzwerkprogrammierung 4
R FTP Connection zu Server Netzwerkprogrammierung 4
M Ausgangsport für FTp-Connection festlegen??? Netzwerkprogrammierung 3

Ähnliche Java Themen

Neue Themen


Oben