1- java.sql.SQLException: ソケットから読み込むデータはこれ以上ありません(java.sql.SQLException: No more data to read from socket)
Driver Version: 9i.* or 10g.*
該異常通常是因?yàn)槭褂昧诉B接池,當(dāng)從連接池取得的connection失效或者超時(shí)的時(shí)候,使用這個(gè)連接來(lái)進(jìn)行數(shù)據(jù)庫(kù)操作就會(huì)拋出以上異常。
解決方法就是讓數(shù)據(jù)庫(kù)連接池在給你返回connection之前,檢查該connnection是否超時(shí)或者失效,如果是,則evict這個(gè)connection,并返回一個(gè)可用的connection。
以DBCP為例,做如下配置即可解決問(wèn)題:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="testOnBorrow">
<value>true</value>
</property>
<property name="testOnReturn">
<value>true</value>
</property>
<property name="testWhileIdle">
<value>true</value>
</property>
<property name="minEvictableIdleTimeMillis">
<value>180000</value>
</property>
<property name="timeBetweenEvictionRunsMillis">
<value>360000</value>
</property>
<property name="validationQuery">
<value>SELECT 1 FROM SYS.DUAL</value>
</property>
<property name="maxActive">
<value>100</value>
</property>
</bean>
另外,你也可以參考這里:http://www.websina.com/bugzero/errors/oracle-SQLException.html
轉(zhuǎn)貼: Oracle SQLException: No more data to read from socket
java.sql.SQLException: No more data to read from socket at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963)
at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:375)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1094)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2132)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2015)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2877)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
This error most likely occurs in applications that use a database connections pool. When the application checked out a connection that has been timed out or has been staled, and used it to connect to the database, this error occurs.
You may need start your Oracle database server as well as your Java application. In a better designed system, however, the staled connection should be cleared out and a new connection should be establised automatically.
--------------------------------------------------
2-ORA-17004: Invalid column type (java.sql.SQLException: 列の型が無(wú)効です。) Driver Version: 9i.*
該異常初次出現(xiàn)在使用spring+iBatis的程序中,后來(lái)通過(guò)檢查出現(xiàn)錯(cuò)誤的字段和SQLMAP的參考文檔,才發(fā)現(xiàn)問(wèn)題之所在。
如果你使用iBatis,那從他的SqlMap參考文檔中應(yīng)該找到以下文字,當(dāng)你看到他們的時(shí)候,你就發(fā)現(xiàn)了通向成功之門的鑰匙,呵呵
Note! Most drivers only need the type specified for nullable columns. Therefore, for such drivers you only
need to specify the type for the columns that are nullable.
Note! When using an Oracle driver, you will get an “Invalid column type” error if you attempt to set a null
value to a column without specifying its type.
也就是說(shuō),當(dāng)某個(gè)column允許為空,而你傳的參數(shù)對(duì)應(yīng)該column的值也為null的時(shí)候,對(duì)于oracle的驅(qū)動(dòng)來(lái)說(shuō),這個(gè)異常是鐵定的了。
解決方法,可以通過(guò)iBatis的parameterMap,指定parameter元素的jdbcType和nullValue來(lái)解決;如果你沒(méi)有使用iBatis,那你可以通過(guò)檢查參數(shù),如果他對(duì)應(yīng)的列為可以為空,而當(dāng)前值恰好就是空的時(shí)候,為他設(shè)置一個(gè)不是空的值即可。
--------------------------------------------------
3-java.sql.SQLException: OALL8矛盾した狀態(tài)にあります;(java.sql.SQLException: OALL8 is in an inconsistent state.)
該異常在我們的程序中通常是在第一個(gè)異常出現(xiàn)之后出現(xiàn),但也不盡然,該異常搜遍網(wǎng)上也找不到合理的解釋,只有以下信息可能會(huì)有用一些(from http://forums.oracle.com/forums/thread.jspa?messageID=1275383):
This is known to occur under when you are using too big an array size. How big your array can be depends on the length of each record and the Driver/Database combination. If you exceed the maximum size you will get the "OALL8" SQLException and your connection object may become unusable.
This message is also created if you are using the following:
9.0.1 Database
10.1.0 JDBC Driver
Generated Code that passes in an ARRAY or VARRAY of VARCHAR2 as a Parameter
或者(from http://opensource.atlassian.com/projects/spring/browse/SPR-1545?decorator=none&view=rss):
[SPR-1545] Oracle error 17447 should result in a DataAccessResourceFailureException
Oracle error 17447 is currently an unmapped exception but it should be a DataAccessResourceFailureException. This error occurs when a JDBC connection has become corrupted, usually because of failure to properly close a connection before returning the connection to the connection pool. Here is the error message:
SQL state [null]; error code [17447]; OALL8 is in an inconsistent state; nested exception is java.sql.SQLException: OALL8 is in an inconsistent state
java.sql.SQLException: OALL8 is in an inconsistent state
This is a kind of "oh crap, something bad happened and it's not really your fault" exception in Oracle. A few causes of this message are suggested in my searches on Google, including (see http://forums.oracle.com/forums/thread.jspa?threadID=274018&tstart=0):
- use of Oracle 10g JDBC drivers to connect to Oracle 9 databases
- using too big an array size (9.0.1 Database, 10.1.0 JDBC Driver and Generated Code that passes in an ARRAY or VARRAY of VARCHAR2 as a Parameter )
In any case, after this exception is thrown the connection is corrupted and unusable, hence why I advocate this exception be mapped to a DataAccessResourceFailureException
解決方法,我也不知道,呵呵,反正調(diào)整了第一個(gè)問(wèn)題之后,這個(gè)異常再?zèng)]有在我們的程序中出現(xiàn)。