Google News
logo
JDBC - Interview Questions
How can we set null value in JDBC PreparedStatement?
By using setNull() method of PreparedStatement interface, we can set the null value to an index. The syntax of the method is given below.
 
void setNull(int parameterIndex, int sqlType) throws SQLException

(OR)

We can use PreparedStatement setNull() method to bind the null variable to a parameter. The setNull method takes index and SQL Types as argument, for example :

ps.setNull(10, java.sql.Types.INTEGER);

Advertisement