I am trying to execute below cmd but this one is throwing an exception:
org.hsqldb.HsqlException: incompatible data type in operation
conn.prepareStatement("INSERT INTO TableA (colA) VALUES (IFNULL(?, 1)))
Here TableA has colA with integer datatype. However, if I change above cmd to
conn.prepareStatement("INSERT INTO TableA (colA) VALUES(IFNULL(null, 1)))
works properly but doesn't make any sense because want to pass colA value at runtime.
code:
ps = conn.prepareStatement("INSERT INTO TableA (colA) VALUES(IFNULL(?, 1))")
ps.setObject(1, 5); // this cmd doesn't have any problem code is failing at preparestatement itself