servlet執行update報錯ORA-12518,servletora-12518
ORA-12518: TNS:listener could not hand off client connection
這種錯誤一般是在測試資料庫並發性的,多個使用者的,
後台用servlet方法執行個update ,只不過updated的記錄為1100個,後台一直報這個錯誤,
我也更改了oracle的串連數為1200,但是當執行到356行的時候,還是報上述的錯誤
解決方案:程式碼的問題,執行更新後,沒有關閉串連,囧,切記關閉串連
public boolean update(Department e) {boolean flag = true ;String updateSQL = "update department set sort="+e.sort+" where id = " + e.getId();try {<span style="white-space:pre"></span>stmt.executeUpdate(updateSQL);} catch (Exception e1) {e1.printStackTrace();flag = false ;}return flag ;}
public boolean update(Department e) {boolean flag = true ;String updateSQL = "update department set sort="+e.sort+" where id = " + e.getId();try {stmt.executeUpdate(updateSQL);} catch (Exception e1) {e1.printStackTrace();flag = false ;}finally{ stmt.close; //切記關閉 conn.close; //切記關閉 }return flag ;}
以前的程式碼量小也沒發覺到不關閉的危害,這次終於嘗試到了,而且還花費了半天的時候找其他的原因,福禍相依,同時也發現了oracle的小秘密——並發性測試