Search code examples
javasql-updaterelational-databasehsqldb

EOFException when updating multiple rows


A multi columns ,multi rows table... on updating a cell/cells of a row/rows…..I update the entire table row by row(might not be an efficient way )...on execute I get :

  java.sql.SQLTransientConnectionException: connection exception: 
  connection failure: java.io.EOFException

the EOFException refers to end of data stream as I read...how it’s relate to my code ?

100 rows,10 columns, column 1 is IDENTITY starts with 1.

 for(int persistRowNum=1;persitRowNum<100;persistRowNum++){

try{
    resultSet.absolute(persistRowNum);

    if((newByteArrayOne.lenght)>0){
        resultSet.updateBytes(2,newByteArrayOne);
        resultSet.updateRow();
      }
      else{
        resultSet.updateBytes(2,resultSet.getBytes(2));
        resultSet.updateRow();
      }
   }catch(SQLException e){
       return;
   }

try{
   resultSet.absolute(persistRowNum);

    if((newByteArrayTwo.length)>0){
       resultSet.updateBytes(3,newByteArrayTwo);
       resultSet.updateRow();
    }
    else{
        resultSet.updateBytes(3,resultSet.getBytes(3));
        resultSet.updateRow();
    }
  }catch(SQLException e){
    return;
  }
}

the 2 images , first show what data I entered in 4 cells in row 1 & 2. after execution...entered data in row 1 not show, while only # 3 from data entered in row 2....more weird notice row # 3 has gone from the table after execution !

Note: persistRowNum is "ID" column

enter image description here

enter image description here

and lastly the stack :

java.sql.SQLTransientConnectionException: connection exception: connection failure: java.io.EOFException
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCResultSet.performUpdate(Unknown Source)
at org.hsqldb.jdbc.JDBCResultSet.updateRow(Unknown Source)
at principal.PrincipalPageController.persistPrinStudTableChanges(PrincipalPageController.java:1077)
at principal.PrincipalPageController.access$2400(PrincipalPageController.java:47)
at principal.PrincipalPageController$34.handle(PrincipalPageController.java:1015)
at principal.PrincipalPageController$34.handle(PrincipalPageController.java:1011)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8863)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:200)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:206)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3876)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:844)
 Caused by: org.hsqldb.HsqlException: connection exception: connection 
 failure: java.io.EOFException
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ClientConnection.execute(Unknown Source)
... 53 more

Solution

  • Try to avoid multiple updates on the same row of the ResultSet

    for(int persistRowNum=1;persitRowNum<100;persistRowNum++){
    try{
        resultSet.absolute(persistRowNum);
    
        if((newByteArrayOne.lenght)>0){
            resultSet.updateBytes(2,newByteArrayOne);
          } else{
            resultSet.updateBytes(2,resultSet.getBytes(2));
          }
    
        if((newByteArrayTwo.length)>0){
           resultSet.updateBytes(3,newByteArrayTwo);
        } else{
            resultSet.updateBytes(3,resultSet.getBytes(3));
        }
    
        resultSet.updateRow();
    
       }catch(SQLException e){
         return;
       }
    }