java.sql.SQLException: Io 异常: Got minus one from a read call
生活随笔
收集整理的這篇文章主要介紹了
java.sql.SQLException: Io 异常: Got minus one from a read call
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
http://quicker.iteye.com/blog/1740690
?
Tomcat服務(wù)器下的應(yīng)用連接Oracle時(shí)報(bào)錯(cuò),出現(xiàn)以下異常:
java.sql.SQLException: Io 異常: Got minus one from a read call
查詢數(shù)據(jù)庫連接情況:
Java代碼 SQL> select username,count(username) from v$session where username is not null group by username;USERNAME COUNT(USERNAME) ------------------------------ --------------- SP2 33 YWTWEBDB 14 SYS 2 INFO 1 MF 658 UC 1836 rows selected.?
Java代碼 SQL> select count(*) from v$session where status='ACTIVE';COUNT(*) ----------675?
原因不明:表現(xiàn)是數(shù)據(jù)庫的連接數(shù)比較大,臨時(shí)處理是重啟數(shù)據(jù)庫,重啟后解決,但估計(jì)不是最終的解決方法。。重啟后的連接情況:
Java代碼 正常的時(shí)候的數(shù)據(jù)庫連接數(shù): SQL> select username,count(username) from V$SESSION where username is not null group by username ;USERNAME COUNT(USERNAME) ------------------------------ --------------- SP2 11 YWTWEBDB 2 SYS 1 INFO 1 MF 79 MYJIN 1 UC 197 rows selected.?
以下收集了網(wǎng)上此問題的相關(guān)解決方法如下:
http://www.iteye.com/topic/1126453
http://blog.sina.com.cn/s/blog_529aacbd0100t22b.html
http://hi.baidu.com/xjieni/item/1afbff62dab025167cdecc21
摘錄如下:
Java代碼 今日無意中用java連接oracle時(shí),竟出現(xiàn)以下異常,甚是奇怪: Caused by: java.sql.SQLException: Io 異常: Got minus one from a read call at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) .... 問題在重新啟動(dòng)應(yīng)用后,應(yīng)用連接oracle時(shí)出錯(cuò),無法啟動(dòng)應(yīng)用。 最后重新啟動(dòng)oracle11g的服務(wù),沒有問題了,但是還沒有找到具體原因。 后來在另外一臺(tái)應(yīng)用上也發(fā)現(xiàn)同樣問題,發(fā)現(xiàn)問題的嚴(yán)重性,經(jīng)過分析可能是驅(qū)動(dòng)問題;在不重新啟動(dòng)oracle11g服務(wù)的情況下,替換最新版本的jdbc驅(qū)動(dòng)包,問題解決; 出問題的ojdbc14.jar版本:(查看jar包的MANIFEST.MF文件) Manifest-Version: 1.0 Specification-Title: Oracle JDBC driver classes for use with JDK14 Sealed: true Created-By: 1.4.2_08 (Sun Microsystems Inc.) Implementation-Title: ojdbc14.jar Specification-Vendor: Oracle Corporation Specification-Version: Oracle JDBC Driver version - "10.2.0.1.0" Implementation-Version: Oracle JDBC Driver version - "10.2.0.1.0" Implementation-Vendor: Oracle Corporation Implementation-Time: Wed Jun 22 11:19:45 2005 Name: oracle/sql/converter/ Sealed: false Name: oracle/sql/ Sealed: false Name: oracle/sql/converter_xcharset/ Sealed: false 解決問題的ojdbc14.jar版本: Manifest-Version: 1.0 Specification-Title: Oracle JDBC driver classes for use with JDK14 Sealed: true Created-By: 1.4.2_14 (Sun Microsystems Inc.) Implementation-Title: ojdbc14.jar Specification-Vendor: Oracle Corporation Specification-Version: Oracle JDBC Driver version - "10.2.0.4.0" Implementation-Version: Oracle JDBC Driver version - "10.2.0.4.0" Implementation-Vendor: Oracle Corporation Implementation-Time: Sat Feb 2 11:40:29 2008 Name: oracle/sql/converter/ Sealed: false Name: oracle/sql/ Sealed: false Name: oracle/sql/converter_xcharset/ Sealed: false?
Java代碼 Caught: java.sql.SQLException: Io 異常: Got minus one from a read call 使用JDBC連接Oracle時(shí),多次出現(xiàn)上述錯(cuò)誤,后來去網(wǎng)上找了下,基本提供的方法有這么幾種:1:數(shù)據(jù)庫連接滿了,擴(kuò)大數(shù)據(jù)庫連接池2:所登錄的機(jī)子IP不在sqlnet.ora內(nèi),加入后重啟listerner即可3:數(shù)據(jù)庫負(fù)載均衡時(shí),指定了(SERVER=DEDICATED),去除這個(gè)即可4:網(wǎng)管在Oracle配置上限制了該臺(tái)機(jī)子訪問Oracle的權(quán)限,這個(gè)問題基本和2類似,也是修改Oracle配置即可; 正在尋找解決辦法,現(xiàn)在數(shù)據(jù)庫不歸我管,不能重啟,擴(kuò)大連接池治標(biāo)不治本,而且數(shù)據(jù)庫連接池是我自己寫的,盲目的擴(kuò)大會(huì)造成其他用戶訪問的多種問題,最好是能銷毀之前創(chuàng)建的那些鏈接。哎,這就是代碼不規(guī)范的壞處啊。創(chuàng)建Connection的時(shí)候一定不能忘了close,就算連接池也不要忘了returnConnection啊。?
Java代碼 ?總結(jié)
以上是生活随笔為你收集整理的java.sql.SQLException: Io 异常: Got minus one from a read call的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 重构36计
- 下一篇: linux cmake编译源码,linu