【故障處理】由於ojdbc14.jar版本不正確導致ORA-01461和ORA-01483故障的處理

secooler發表於2011-05-06
  今天遭遇由於ojdbc14.jar版本不正確導致ORA-01461和ORA-01483報錯的問題。簡單記錄一下這個問題的處理過程。

1.應用程式報錯現象
以下是從應用程式日誌中擷取的兩段報錯資訊。
2011-05-05 04:24:28,148 INFO  [org.iata.asdcore.acdm.esb.service.AcdmEsbServiceImpl] The number is ***********************986
2011-05-05 04:24:28,451 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01461: can bind a LONG value only for insert into a LONG column

2011-05-05 04:24:28,451 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01461: can bind a LONG value only for insert into a LONG column

2011-05-05 04:24:28,451 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update


2011-05-03 19:10:14,414 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01483: invalid length for DATE or NUMBER bind variable

2011-05-03 19:10:14,414 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-01483: invalid length for DATE or NUMBER bind variable

2011-05-03 19:10:14,414 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)


這裡提到的兩個報錯資訊彙總如下:
ORA-01461: can bind a LONG value only for insert into a LONG column
ORA-01483: invalid length for DATE or NUMBER bind variable

由於這個報錯的發生,導致資料出現了異常。業務資料的恢復耗費了很大的精力。

2.問題分析
MOS上記錄了這個報錯資訊的基本原因和處理方法。
參見MOS文章“OERR: ORA 1461 can bind a LONG value only for insert into a LONG column [ID 18864.1]”,內容如下。
Error:  ORA 1461
Text:   can bind a LONG value only for insert into a LONG column
-------------------------------------------------------------------------------
Cause:  An attempt was made to insert a value from a LONG datatype into
        another datatype.
        This is not allowed.
Action: Do not try to insert LONG datatypes into other types of columns.


從報錯資訊上看,貌似是由於插入的值過大導致的報錯。
不過從插入的資訊和表結構定義進行分析,初步排除了這種可能性。

3.進一步的問題現象
從測試環境上進行了反覆測試,現象如下:
在序列執行下,應用程式執行正確無誤,沒有出現如上報錯。
然而,在並行執行的條件下,便“偶爾”會出現這個問題。

從此現象分析,便可以排除故障是由於資料本身問題導致的。

4.問題原因
經過嘗試和測試。最終確認了此問題是由於應用程式中使用的驅動程式與Oracle伺服器端的版本不一致導致的。

5.處理方法
將伺服器端的驅動程式(ojdbc14.jar)替換應用程式中的檔案。

資料庫伺服器上驅動程式位置如下。
ora10g@secdb /home/oracle$ cd $ORACLE_HOME/jdbc/lib
ora10g@secdb /oracle/ora10gR2/product/10.2.0/db_2/jdbc/lib$ ls -ltr
total 13M
-rw-r----- 1 oracle oinstall 1.6M Jun 22  2005 nls_charset12.jar
-rw-r----- 1 oracle oinstall 1.6M Jun 22  2005 classes12.jar
-rw-r----- 1 oracle oinstall 1.6M Jun 22  2005 classes12.zip
-rw-r----- 1 oracle oinstall 1.6M Jun 22  2005 classes12dms.jar
-rw-r----- 1 oracle oinstall 1.5M Jun 22  2005 ojdbc14.jar
-rw-r----- 1 oracle oinstall 1.5M Jun 22  2005 ojdbc14dms.jar
-rw-r----- 1 oracle oinstall 1.9M Jun 22  2005 ojdbc14_g.jar
-rw-r----- 1 oracle oinstall 1.9M Jun 22  2005 ojdbc14dms_g.jar

經過反覆測試,故障得到了有效處理。

6.小結
從此問題分析和處理過程中我們得到的經驗和教訓是:需要充分重視應用程式開發與資料庫技術結合的重要性!
任何細節上的疏忽都有可能對生產環境產生重大的影響。

Good luck.

secooler
11.05.06

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-694743/,如需轉載,請註明出處,否則將追究法律責任。

相關文章