Reputation: 1071
The Java code below:
JdbcTemplate jdbcTemplate = getJdbcTemplate();
Boolean isEnabled = true;
String sql = "INSERT INTO user_table (username, is_enabled) VALUES(?, ?)";
jdbcTemplate.update(sql, new Object[]{"a_username", isEnabled}
the is_enabled column in Oracle database user_table is Number type with 0 or 1 values.
I did it wrong by using a java Boolean value instead of int; but jdbcTemplate doesn't complain and it works.
Any one please explain what's going on with JdbcTemplate?
thanks
Upvotes: 1
Views: 2630
Reputation: 14008
Oracle does not have a boolean type other than in PL/SQL (a question about why they don't support booleans can be found here).
What is happening in your case is that the Oracle JDBC Driver is actually taking care of the data type mapping for you (so mapping from the boolean that you gave it to the number type that oracle requires). Details on this can be found here: http://docs.oracle.com/cd/B10501_01/java.920/a96654/basic.htm#1022590
Upvotes: 2