環境:數據庫sql server2005,jdk1.6 ,myeclipse,驅動jdts1.2.2
執行以下代碼,報錯:
報錯信息爲:
java.sql.SQLException: Output parameters have not yet been processed. Call getMoreResults().
at net.sourceforge.jtds.jdbc.ParamInfo.getOutValue(ParamInfo.java:159)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.getOutputValue(JtdsCallableStatement.java:116)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.getString(JtdsCallableStatement.java:310)
報錯信息說得很明白,就是輸出結果參數未處理,必須調用getMoreResults()方法以判斷是否還有結果集。
然後修改代碼,問題解決:
其中改爲以下代碼也不報錯: