Incorrect response n1
ps.setNull(3, JDBCType.INTEGER);
ps.setNull(4, JDBCType.STRING);
The second parameter to the setNull method is of type int and it expects the value to be one of the constants defined in java.sql.Types class. Among other constants, [b]it has INTEGER and VARCHAR for int and String values respectively. STRING is not a valid constant in this class[/b]. java.sql.JDBCType also defines the same names (i.e. INTEGER and VARCHAR, among others) but it is an enum.
Incorrect response n2
ps.setNull(3, JDBCType.INTEGER);
ps.setNull(4, [b]JDBCType.VARCHAR[/b]);
[b]This is wrong for the same reason as above[/b].
I'm sorry but this explanation doesn't make sense to me. "it has INTEGER and VARCHAR for int and String values respectively" vs second response being wrong despite having exactly VARCHAR described there?
Please read the explanation carefully. The difference is in the name of the type in which INTEGER and VARCHAR are declared. i.e. Types.VARCHAR vs JDBCType.VARCHAR
Types.VARCHAR is an int while JDBCType.VARCHAR is an enum.
That is why the explanation says:
The second parameter to the setNull method is of type int and it expects the value to be one of the constants defined in java.sql.Types class.
If you like our products and services, please help us by posting your review here.