8 messages in com.mysql.lists.javaRe: SQLException: Communication link ...
FromSent OnAttachments
Jan Pfeifer28 Nov 2003 14:43 
Christopher Taylor28 Nov 2003 17:42 
Jan Pfeifer29 Nov 2003 03:48.java
Mark Matthews29 Nov 2003 06:29 
Jan Pfeifer29 Nov 2003 07:45 
Mark Matthews29 Nov 2003 09:00 
Jan Pfeifer30 Nov 2003 07:45.java, .sh
Jan Pfeifer01 Dec 2003 04:28.java
Subject:Re: SQLException: Communication link failure
From:Mark Matthews (ma@mysql.com)
Date:11/29/2003 06:29:08 AM
List:com.mysql.lists.java

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Jan Pfeifer wrote:

thanks for the answer Christopher, i just forgot to mention it in my pseudo code. But i do close the ResultSet, just after reading the records.

to avoid further confusion, i send the code attached.

best regards,

jan

What does the table look like, and what data does it contain? Without information like that, nobody will be able to repeat your problem. "30 fields of 2500 records" can be interpreted _very_ differently by anyone, and the actual makeup and size of those records might have something to do with the issue. :(

-Mark

Christopher Taylor wrote:

You need to close that ResultSet that comes off of the executeQuery stmt.

ResultSet results = statement.executeQuery(); results.close();

hi all

first, i'm new to the list and the subject (Java MySQL), sorry for any stupid questions -- i already tried docs and google :)

i've been having the same problem as others mention, but it happens just after my second query, so it doesn't seem a timeout problem.

basically what i'm doing is:

Connection con = DriverManager.

getConnection("jdbc:mysql://localhost/dbname?&user=user&password=xxxx");

for (int i = 0; i < 10; i ++) { Statement statement = con.createStatement(); statement.executeQuery( "queries ~2500 records of 20 fields" ); statement.close() }

first it is running very slow ... then, after the first loop, the second query execution never returns ... with "$ mysqladmin processlist" I get the query waiting on "writing to net" and eventually timing out.

with that, after some time, java throws:

java.sql.SQLException: Communication link failure: java.io.EOFException, underlying cause: null

** BEGIN NESTED EXCEPTION **

java.io.EOFException

STACKTRACE:

java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1242) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1428) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1775) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1752) at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:851) at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:263) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1156) at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1070) at com.mysql.jdbc.Connection.execSQL(Connection.java:2027) at com.mysql.jdbc.Connection.execSQL(Connection.java:1984) at com.mysql.jdbc.Statement.executeQuery(Statement.java:1152) ...

i'd be very grateful for any ideas ...

many thanks! :)

jan

ps.: i'm running

debian unstable mysql 4.0.16 J/Connector 3.0.9 J2SKD 1.4.1_02

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

package (...);

import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;

import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator;

/** * DbSpeed : * * @author jan */ public class DbSpeed {

public static void main(String[] args) { // setup logging DOMConfigurator.configure("log4j.xml"); class_log.info("main(): starting ...");

try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/(...)"); String sql="(...) 30 fields of about 2500 records"; for (int i = 0; i < 10; i ++) { System.out.println("Loop "+i); System.out.println(" createStatement"); Statement statement = con.createStatement(); System.out.println(" exeuteQuery"); ResultSet res = statement.executeQuery( sql ); System.out.println(" res.next"); while (res.next()) {} System.out.println(" res.close"); res.close(); System.out.println(" statement.close"); statement.close(); System.out.println(""); } } catch (Exception e) { e.printStackTrace(); }

class_log.info("main(): exiting ..."); }

/** * class Logger * * @author jan */ static Logger class_log = Logger.getLogger(DbSpeed.class+""); }

- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 557 2388 www.mysql.com

Are you MySQL Certified? http://www.mysql.com/certification/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQE/yK1KtvXNTca6JD8RAiI5AJ0QMOg0h5aJ1NCyRfYi95+UzfI5RQCgrAGP fvRTX8AU+SpEg2QF6np3Kzg= =orJK -----END PGP SIGNATURE-----