java.sql.SQLException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received on y -1 bytes. The connection has been terminated.

Apache's JIRA Issue Tracker | Oliver Seidel | 9 years ago
  1. 0

    Thanks again to the DERBY developers. For my convenience I use the client/server variant of DERBY. This is where the error occurs. I have temporarily alleviated the problem for my case by using the embedded version. I'm forced to use outlook and have built a program which siphons the messages into a derby database (phase 1 -- table has two varchar fields and a clob). When reading them back (phase 2 -- simple select of all records in no particular order, all 3 attributes), it has developed an exception. This is a result of data volume. I have reduced the problem to a single demonstration program. This behaviour, and the fact that the error is not a "DERBY Exception", but a proper exception coming back from the JDBC call, leads me to the diagnosis that it is a derby network client jdbc problem. The problem has been reproduced once by Bryan Pendleton: http://www.nabble.com/IndexOutOfBoundsException-t4926228.html I'll try to attach the code "error.java"; it can also be found on: http://www.os10000.net/error.java Please use as follows: javac -classpath derby.jar:derbynet.jar error.java java -cp .:derby.jar:derbynet.jar error It will create a directory "test_db" and fill it with approx 120mb data. Then you will observe the failure. /* -*- Mode:Java; c-basic-offset:8 -*- */ // -------------------------------------------------------------------------------- public class error { // ------------------------------------------------------------------------ public static final int port = 1527; public static final String host = "127.0.0.1"; // ------------------------------------------------------------------------ public static void log(String x) { System.out.println(x); }; // ------------------------------------------------------------------------ public static void log_stacktrace(Exception e) { java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); e.printStackTrace(pw); log(sw.toString()); }; // ------------------------------------------------------------------------ public static void start_server() { try { org.apache.derby.drda.NetworkServerControl server = new org.apache.derby.drda.NetworkServerControl(java.net.InetAddress.getByName(host),port); server.start(null); try { java.lang.Thread.sleep(5000); } catch (Exception e) { }; log("started DERBY on host "+host+" port "+Integer.toString(port)+"."); } catch (Exception e) { log_stacktrace(e); }; }; // ------------------------------------------------------------------------ public static java.sql.Connection con() throws java.sql.SQLException, java.lang.ClassNotFoundException { Class.forName("org.apache.derby.jdbc.ClientDriver"); String x_dbse = "test_db"; String x_user = ";user=os10000"; String x_pass = ";password=ding"; String x_crte = ";create=true"; String x_msgs = ";retrieveMessagesFromServerOnGetMessage=true"; String connect = "jdbc:derby://"+host+":"+port+"/"+x_dbse+x_user+x_crte+x_msgs; return java.sql.DriverManager.getConnection(connect); }; // ---------------------------------------------------------------------- public static String getclob(java.sql.Clob b) { java.io.CharArrayWriter caw = new java.io.CharArrayWriter(); try { java.io.Reader rd = b.getCharacterStream(); char cb[] = new char[4096]; int off=0, bts = rd.read(cb); while (bts>0) { caw.write(cb,off,bts); off+=bts; bts=rd.read(cb); }; rd.close(); } catch(Exception e) {}; String res = caw.toString(); caw.close(); return res; }; // ---------------------------------------------------------------------- public static class myclob implements java.sql.Clob { String v; public myclob(String z) { v=z; }; public java.io.InputStream getAsciiStream() { return new java.io.ByteArrayInputStream(v.getBytes()); }; public java.io.Reader getCharacterStream() { return new java.io.CharArrayReader(v.toCharArray()); }; public String getSubString(long pos, int length) { return v.substring((int)pos,(int)(pos+length)); }; public long length() { return v.length(); }; public long position(java.sql.Clob pattern, long start) { return 0; }; public long position(String pattern, long start) { return 0; }; public java.io.OutputStream setAsciiStream(long pos) { new java.sql.SQLException("setAsciiStream not implemented."); return null; }; public java.io.Writer setCharacterStream(long pos) { new java.sql.SQLException("setCharacterStream not implemented."); return null; }; public int setString(long pos, String s) { new java.sql.SQLException("setString not implemented."); return -1; }; public int setString(long pos, String s, int offset, int len) { new java.sql.SQLException("setString not implemented."); return -1; }; public void truncate(long len) { new java.sql.SQLException("truncate not implemented."); }; }; public static java.sql.Clob putclob(String x) { return new myclob(x); }; // ------------------------------------------------------------------------ public static String getLob(java.sql.ResultSet rs, int arg) throws java.sql.SQLException { return getclob(rs.getClob(arg)); }; public static void setLob(java.sql.PreparedStatement ps, int arg, String val) throws java.sql.SQLException { ps.setClob(arg,putclob(val)); }; // ------------------------------------------------------------------------ public static String clean_string(String x) { return x.replaceAll("[\0\r\\\\]","").replaceAll("'","\\\"").replaceAll(",+",","); }; // ------------------------------------------------------------------------ public static String make_string(int digits) { double dl = (Math.random()) * (Math.pow(10.0,digits*Math.random())); int len = (int) dl; byte buf[] = new byte[len]; while (len>0) { double db = 256*Math.random(); buf[--len] = (byte)db; }; return clean_string(new String(buf)); }; // ------------------------------------------------------------------------ public static void update(java.sql.Connection c, String cmd) throws java.sql.SQLException { c.createStatement().execute(cmd); }; // ------------------------------------------------------------------------ public static final int entries=100000; public static void fill_db(java.sql.Connection c) throws java.sql.SQLException { try { update(c,"drop table mail_raw"); } catch (Exception e) {}; try { update(c,"create table mail_raw ( msg varchar(999), att varchar(100), val clob )"); } catch (Exception e) { log_stacktrace(e); }; java.sql.PreparedStatement pstmt = null; try { pstmt = c.prepareStatement("insert into mail_raw values ( ?, ?, ? )"); } catch (Exception e) { log_stacktrace(e); }; for (int i=0; i<entries; i++) { pstmt.setString(1,make_string(3)); pstmt.setString(2,"5 body"); setLob(pstmt,3,make_string(4)); pstmt.executeUpdate(); if (i%100==0) log("step "+i+"/"+entries); }; }; // ------------------------------------------------------------------------ public static void dump_db(java.sql.Connection c) throws java.sql.SQLException { log("performing dump."); java.sql.ResultSet rs = c.createStatement().executeQuery("select * from mail_raw"); while (rs.next()) { String msg = rs.getString(1); String att = rs.getString(2); String val = getLob(rs,3); }; }; // ------------------------------------------------------------------------ public static void main(String args[]) { start_server(); try { java.sql.Connection c = con(); fill_db(c); dump_db(c); } catch (Exception e) { log_stacktrace(e); }; }; // ------------------------------------------------------------------------ };

    Apache's JIRA Issue Tracker | 9 years ago | Oliver Seidel
    java.sql.SQLException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received on y -1 bytes. The connection has been terminated.
  2. 0

    [DERBY-3729] Error message is rather unrevealing when creating large databases on FAT32 drives - ASF JIRA

    apache.org | 1 year ago
    java.sql.SQLException: A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message
  3. 0

    I was creating a test database on an external USB drive formatted as FAT32- it contains some tables that have quite large binary objects in: This was in conjunction with Hibernate. I got this rather cryptic error message. Looks rather scary: 18:02:37,550 WARN JDBCExceptionReporter:77 - SQL Error: 40000, SQLState: 08006 18:02:37,550 ERROR JDBCExceptionReporter:78 - A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message 18:02:37,597 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session org.hibernate.exception.JDBCConnectionException: could not insert: [proteinChainMoleculeBinaryData] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister. java:2263) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) Initially it didnt even occur to me that this may be due to me using a FAT32 drive, but eventually I figured out that the table's file had got to the operating FAT32 limit: I had a file of 4,194,272 KB. In the derby log, there's a more revealing, but still incorrect, error message: ERROR XSDG1: Page Page(131071,Container(0, 2384)) could not be written to disk, please check if disk is full. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.store.raw.data.CachedPage.writePage(Unknown Source) at org.apache.derby.impl.store.raw.data.CachedPage.createIdentity(Unknown Source) at org.apache.derby.impl.services.cache.CachedItem.takeOnIdentity(Unknown Source) at org.apache.derby.impl.services.cache.Clock.addEntry(Unknown Source) at org.apache.derby.impl.services.cache.Clock.create(Unknown Source) at org.apache.derby.impl.store.raw.data.FileContainer.initPage(Unknown Source) at org.apache.derby.impl.store.raw.data.FileContainer.newPage(Unknown Source) at org.apache.derby.impl.store.raw.data.BaseContainer.addPage(Unknown Source) at org.apache.derby.impl.store.raw.data.StoredPage.getNewOverflowPage(Unknown Source) at org.apache.derby.impl.store.raw.data.BasePage.insertLongColumn(Unknown Source) at org.apache.derby.impl.store.raw.data.BasePage.insertAllowOverflow(Unknown Source) at org.apache.derby.impl.store.raw.data.BasePage.insert(Unknown Source) at org.apache.derby.impl.store.access.heap.HeapController.doInsert(Unknown Source) at org.apache.derby.impl.store.access.heap.HeapController.insertAndFetchLocation(Unknown Source) at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(Unknown Source) at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(Unknown Source) at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source) at org.apache.derby.impl.drda.DRDAStatement.execute(Unknown Source) at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTTobjects(Unknown Source) at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(Unknown Source) at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source) at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source) Caused by: java.io.IOException: There is not enough space on the disk at sun.nio.ch.FileDispatcher.pwrite0(Native Method) at sun.nio.ch.FileDispatcher.pwrite(FileDispatcher.java:51) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:100) at sun.nio.ch.IOUtil.write(IOUtil.java:75) at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:651) at org.apache.derby.impl.store.raw.data.RAFContainer4.writeFull(Unknown Source) at org.apache.derby.impl.store.raw.data.RAFContainer4.writePage0(Unknown Source) at org.apache.derby.impl.store.raw.data.RAFContainer4.writePage(Unknown Source) ... 26 more The error is still strictly speaking incorrect - my disk is far from full, but I have created a file too big for the disk type - but the error is at least closer to the truth and this would be useful information for the derby client to display rather than the rather scary looking message I was getting.

    Apache's JIRA Issue Tracker | 8 years ago | Jason C. Cole
    java.sql.SQLException: A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Answer a Question | WebRatio

    webratio.com | 4 months ago
    java.sql.SQLNonTransientConnectionException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes.  The connection has been terminated.
  6. 0

    Sonar plugin - hudson - Hudson Wiki

    hudson-ci.org | 1 month ago
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0-beta-2:sonar (default-cli) on project cdnssp: Can not execute Sonar

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.apache.derby.client.am.DisconnectException

      Insufficient data while reading from the network - expected minimum of 6 bytes and received only -1 bytes. The connection has been terminated.

      at org.apache.derby.client.net.Reply.fill()
    2. Apache Derby Client JDBC Driver
      PreparedStatement.executeUpdate
      1. org.apache.derby.client.net.Reply.fill(Reply.java:195)
      2. org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Reply.java:215)
      3. org.apache.derby.client.net.Reply.readDssHeader(Reply.java:317)
      4. org.apache.derby.client.net.Reply.startSameIdChainParse(Reply.java:1147)
      5. org.apache.derby.client.net.NetStatementReply.readExecute(NetStatementReply.java:69)
      6. org.apache.derby.client.net.StatementReply.readExecute(StatementReply.java:55)
      7. org.apache.derby.client.net.NetPreparedStatement.readExecute_(NetPreparedStatement.java:183)
      8. org.apache.derby.client.am.PreparedStatement.readExecute(PreparedStatement.java:1796)
      9. org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:2116)
      10. org.apache.derby.client.am.PreparedStatement.executeUpdateX(PreparedStatement.java:396)
      11. org.apache.derby.client.am.PreparedStatement.executeUpdate(PreparedStatement.java:382)
      11 frames
    3. Unknown
      error.main
      1. error.fill_db(error.java:147)
      2. error.main(error.java:171)
      2 frames