Just prepare a Statement as follows
PreparedStatement ps = connection.prepareStatement( INSERT_TRAN_SQL, Statement.RETURN_GENERATED_KEYS);
The main JDBC driver (used indirectly through Spring JdbcTemplate here) requires specifying that you want to get the generated keys. This can be done either by preparing the PreparedStatement as
connection.prepareStatement(strSQL, Statement.RETURN_GENERATED_KEYS);
or, at the time of execution of Statement as
statement.executeUpdate(strSQL, Statement.RETURN_GENERATED_KEYS);
This is what your java.sql.SQLException points to.
source share