我在甲骨文上遇到了很奇怪的问题。我正在使用OracleXE 10g (10.2.0.1.0版本的数据库),并在ojdbc14_g驱动程序10.2.0.1.0、10.2.0.4.0和10.2.0.5.0中进行了尝试。同样的事情总是会发生。我想这是基于我在各种论坛上所读到的,但我不确定.这就是问题所在:
我有一段代码,准备语句来更新两个blobs,它们实际上是zip档案:
File fRst = new File("archive1.zip");
File fPro = new File("archive2.zip");
//...
statement = "UPDATE CURR_STATE" +
" SET ZIP_RST=?, ZIP_PRO=?" +
" WHERE SERIAL_NUMBER=" + "'" + serialNo + "'" + " AND" +
" YEAR_MONTH=" + "'" + yearMonth + "'";
pstmt = this.connection.prepareStatement(statement);
FileInputStream isR = new FileInputStream(fRst);
FileInputStream isP = new FileInputStream(fPro);
pstmt.setBinaryStream(1, isR, (int) fRst.length());
pstmt.setBinaryStream(2, isP, (int) fPro.length());
int no = pstmt.executeUpdate();
System.out.println("rows: " + no);
this.connection.commit();
pstmt.close();
我在测试给定记录在表中不存在的情况下的更新情况。如果这两个zip文件的大小较小(如2、5或10 or ),则行:
int no = pstmt.executeUpdate();
返回更新的0行,考虑到WHERE子句中定义的行不存在,这是预期的。但是,如果压缩文件稍微大一点(30,40 if ),executeUpdate()就会抛出带有各种消息的SQLException,例如:
java.sql.SQLException: Io exception: Software caused connection abort: socket write error
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:363)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1142)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1278)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498)
或
java.sql.SQLException: No more data to read from socket
或
java.sql.SQLException: OALL8 is in an inconsistent state
这些异常有效地关闭了基础套接字连接,因此它变得不可用。有趣的是,如果表中存在行,那么一切都正常,更新执行时没有问题,返回1作为更新行数。
我想知道是否有人已经遇到过这种奇怪的行为,是否有任何旁路呢?(除了显而易见的-检查该行是否存在:)
谢谢。
发布于 2011-09-01 11:09:01
java.sql.SQLException: No more data to read from socket
每当我看到这种情况时,都是因为连接到的oracle服务器已经崩溃(而不是实例)。
当这种情况发生时,你检查过警报记录了吗?
https://stackoverflow.com/questions/7268466
复制相似问题