I have a variable which is
Long val = null;
And I am looking for a way to pass this to PreparedStatement statement object in order to set the field value in the database as null.
statement.setLong(1,val);
It does not work for Long, but only long.
Any inputs ideas, or suggestions.
Thanks !!!
You should use the setNull
method .
statement.setNull(1, Types.BIGINT); // Types.BIGINT maps to 64-bit long
When mapping Java types to JDBC types, this article states:
The recommended Java mapping for the BIGINT type is as a Java long.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.