在JDBC中调用SQL Server中的存储过程时出现如下异常:
解决方法:在存储过程首行加上
环境:SQL Server 2000 sp4 + 官方2008驱动(sqljdbc4.jar)
com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:394)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:283)
解决方法:在存储过程首行加上
SET NOCOUNT ON
环境:SQL Server 2000 sp4 + 官方2008驱动(sqljdbc4.jar)