java.sql.SQLException: Io 異常: Got minus one from a read call

 

博客分類:
 

Tomcat服務器下的應用鏈接Oracle時報錯,出現如下異常:html

java.sql.SQLException: Io 異常: Got minus one from a read call

查詢數據庫鏈接狀況:java

Java代碼   收藏代碼
  1. SQL> select username,count(username) from v$session where username is not null group by username;  
  2.   
  3. USERNAME                       COUNT(USERNAME)  
  4. ------------------------------ ---------------  
  5. SP2                                         33  
  6. YWTWEBDB                                    14  
  7. SYS                                          2  
  8. INFO                                         1  
  9. MF                                         658  
  10. UC                                         183  
  11.   
  12. 6 rows selected.  

 

Java代碼   收藏代碼
  1. SQL> select count(*) from v$session where status='ACTIVE';  
  2.   
  3.   COUNT(*)  
  4. ----------  
  5.        675  

 

緣由不明:表現是數據庫的鏈接數比較大,臨時處理是重啓數據庫,重啓後解決,但估計不是最終的解決方法。。重啓後的鏈接狀況:sql

Java代碼   收藏代碼
  1. 正常的時候的數據庫鏈接數:  
  2. SQL> select username,count(username) from V$SESSION where username is not null group by username ;  
  3.   
  4. USERNAME                       COUNT(USERNAME)  
  5. ------------------------------ ---------------  
  6. SP2                                         11  
  7. YWTWEBDB                                     2  
  8. SYS                                          1  
  9. INFO                                         1  
  10. MF                                          79  
  11. MYJIN                                        1  
  12. UC                                          19  
  13.   
  14. 7 rows selected.  

 

如下收集了網上此問題的相關解決方法以下:數據庫

http://www.iteye.com/topic/1126453服務器

http://blog.sina.com.cn/s/blog_529aacbd0100t22b.htmlsession

http://hi.baidu.com/xjieni/item/1afbff62dab025167cdecc21oracle

摘錄以下:負載均衡

Java代碼   收藏代碼
  1. 今日無心中用java鏈接oracle時,竟出現如下異常,甚是奇怪:   
  2. Caused by: java.sql.SQLException: Io 異常: Got minus one from a read call   
  3. at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)   
  4. at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)   
  5. at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)   
  6. at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)   
  7. at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)   
  8. at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) ....   
  9.   
  10. 問題在從新啓動應用後,應用鏈接oracle時出錯,沒法啓動應用。   
  11.   
  12. 最後從新啓動oracle11g的服務,沒有問題了,可是尚未找到具體緣由。   
  13.   
  14. 後來在另一臺應用上也發現一樣問題,發現問題的嚴重性,通過分析多是驅動問題;在不從新啓動oracle11g服務的狀況下,替換最新版本的jdbc驅動包,問題解決;   
  15.   
  16. 出問題的ojdbc14.jar版本:(查看jar包的MANIFEST.MF文件)   
  17. Manifest-Version: 1.0   
  18. Specification-Title:    Oracle JDBC driver classes for use with JDK14   
  19. Sealed: true   
  20. Created-By: 1.4.2_08 (Sun Microsystems Inc.)   
  21. Implementation-Title:   ojdbc14.jar   
  22. Specification-Vendor:   Oracle Corporation   
  23. Specification-Version:  Oracle JDBC Driver version - "10.2.0.1.0"   
  24. Implementation-Version: Oracle JDBC Driver version - "10.2.0.1.0"   
  25. Implementation-Vendor:  Oracle Corporation   
  26. Implementation-Time:    Wed Jun 22 11:19:45 2005   
  27.   
  28. Name: oracle/sql/converter/   
  29. Sealed: false   
  30.   
  31. Name: oracle/sql/   
  32. Sealed: false   
  33.   
  34. Name: oracle/sql/converter_xcharset/   
  35. Sealed: false   
  36.   
  37.   
  38. 解決問題的ojdbc14.jar版本:   
  39. Manifest-Version: 1.0   
  40. Specification-Title:    Oracle JDBC driver classes for use with JDK14   
  41. Sealed: true   
  42. Created-By: 1.4.2_14 (Sun Microsystems Inc.)   
  43. Implementation-Title:   ojdbc14.jar   
  44. Specification-Vendor:   Oracle Corporation   
  45. Specification-Version:  Oracle JDBC Driver version - "10.2.0.4.0"   
  46. Implementation-Version: Oracle JDBC Driver version - "10.2.0.4.0"   
  47. Implementation-Vendor:  Oracle Corporation   
  48. Implementation-Time:    Sat Feb  11:40:29 2008   
  49.   
  50. Name: oracle/sql/converter/   
  51. Sealed: false   
  52.   
  53. Name: oracle/sql/   
  54. Sealed: false   
  55.   
  56. Name: oracle/sql/converter_xcharset/   
  57. Sealed: false   

 

Java代碼   收藏代碼
  1. Caught: java.sql.SQLException: Io 異常: Got minus one from a read call  
  2. 使用JDBC鏈接Oracle時,屢次出現上述錯誤,後來去網上找了下,基本提供的方法有這麼幾種:  
  3.   
  4. 1:數據庫鏈接滿了,擴大數據庫鏈接池  
  5.   
  6. 2:所登陸的機子IP不在sqlnet.ora內,加入後重啓listerner便可  
  7.   
  8. 3:數據庫負載均衡時,指定了(SERVER=DEDICATED),去除這個便可  
  9.   
  10. 4:網管在Oracle配置上限制了該臺機子訪問Oracle的權限,這個問題基本和2相似,也是修改Oracle配置便可;  
  11. 正在尋找解決辦法,如今數據庫不歸我管,不能重啓,擴大鏈接池治標不治本,並且數據庫鏈接池是我本身寫的,盲目的擴大會形成其餘用戶訪問的多種問題,最好是能銷燬以前建立的那些連接。哎,這就是代碼不規範的壞處啊。建立Connection的時候必定不能忘了close,就算鏈接池也不要忘了returnConnection啊。  

 

Java代碼   收藏代碼
  1. 由於,數據庫一直都是正常的,因此不能夠是那些配置之類的錯誤。  
  2. 後面DBA查了些東西后,給出結論說是,系統資源不夠了。  
  3. --查看系統資源  
  4. SELECT   resource_name,  
  5.          current_utilization,  
  6.          max_utilization,  
  7.          LIMIT,  
  8.          ROUND (max_utilization / LIMIT * 100) || '%' rate  
  9.   FROM   (SELECT   resource_name,  
  10.                    current_utilization,  
  11.                    max_utilization,  
  12.                    TO_NUMBER (initial_allocation) LIMIT  
  13.             FROM   v$resource_limit  
  14.            WHERE   resource_name IN ('processes', 'sessions')  
  15.                    AND max_utilization > 0);  
  16.    
  17. RESOURCE_NAME                  CURRENT_UTILIZATION MAX_UTILIZATION      LIMIT RATE  
  18. ------------------------------ ------------------- --------------- ---------- -----  
  19. processes                                      312             500        500 100%  
  20. sessions                                       317             509        555 92%  
  21. 發現是資源不足。  
  22. 處理方法是:  
  23. alter system set processes=1000 scope=spfile;  
  24. alter system set sessions=1110 scope=spfile; 而後重啓數據庫  
  25.    
  26. 只是,我重啓以後值也都降低了,估計還有其餘緣由致使資源不足的吧。 
相關文章
相關標籤/搜索