Using the spring JdbcTemplate to manipulate additions and deletions, Basedao executes the stored procedure as follows:
This method either returns a true or throws an exception;
Phenomenon:
When the project is published in Tomcat, the same code, the same process, before testing this method, you can capture the process of manually thrown errors, after a period of time to test today, found that the process was not caught manually thrown error, and this method directly returned true! Pit Daddy
Check Data debugging:
1: The current process does not have set NOCOUNT on;
2: In the process of manual throw error RAISERROR before, if there is an INSERT statement, Tomcat may not catch this hand throw error, but in the case without set NOCOUNT on, put RAISERROR in front of the insert, you can capture.
Solve:
In Create PROCEDURE ..... As the following line, write:
SET NOCOUNT on
Conclusion:
Without set NOCOUNT ON, the process is no problem in WebSphere projects, but there may be problems in Tomcat, and Tomcat does not have many fault-tolerant mechanisms like websphere;
Why is the same code, process, can be captured before, and now cannot be captured? Because this time the database is restored, and the backup is a database backup of the production environment in the field, guess should be related to the database environment, the specific unknown, in short, directly add SET NOCOUNT on to the process, in Tomcat JDBC can normally capture the
Java does not capture hand-thrown errors inside stored procedures