Update error: Failed to update database due to java.sql.SQLException... cannot insert the value NULL...

Updating data fails with an error similar to "Failed to update database due to java.sql.SQLException... cannot insert the value NULL... column does not allow nulls..."

Cause: The number of rows that a trigger in the database counts differs from the number of the rows that the Update operation sends to the JDBC driver.

Solution: For SQL Server and ASE database with JDBC driver, use the "SET NOCOUNT ON" statement before executing SQL statements when you create a trigger object.

For example:

CREATE TRIGGER trigger_name
ON { table | view }
[ WITH ENCRYPTION ]
{
{ { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] }
[ WITH APPEND ] [ NOT FOR REPLICATION ]
AS
set nocount on  
[ { IF SELECT ( column )[ { AND | OR } UPDATE ( column ) ][ ...n ]
| IF ( COLUMNS_UPDATED ( ) { bitwise_operator } updated_bitmask )
{ comparison_operator } column_bitmask [ ...n ]} ]
Xsql_statement [ ...n ]
}
}