A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
JDBC and Relational Databases
using setNull correctly
Joined: Oct 28, 2008
Dec 23, 2008 14:31:00
I am trying to figure out the correct way to use setNull in a prepared statement.
ps.setNull(1, Types.INTEGER); // Set my first column to null, it is an int
I currently do not have access to the type so i would like to know if this is ok:
ps.setNull(1, Types.NULL); // Sorry don't know column 1's type
I have read a few places that Types.NULL is ok in all situations but I don't believe it.
Any experts in the area.
This relates to a post I also just put up in trying to figure out what the type is from the column name. I.E. since I don't know the type is there an easy way to get it from the column name?
I agree. Here's the link:
subject: using setNull correctly
Getting strange exception while executing preparedStatement.
SetNull() in a select PreparedStatement
save Date() into mysql Timestamp
commit problem - always happens even if set to false!!
how can i insert a null value in a table
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015