I need to check if a field in my table is empty (null) and if so, do a specific task; if not, do something different. I have tried rs.wasNull() and got the error "wasNull() called with no data retrieved". Are there any other methods to do this?
在调用rs.wasNull()
之前,您首先需要从rs
获取值,例如使用rs.getInt("col1")
rs.wasNull()
。
Another method? rs.wasNull()
is the best way. But if you insist... Depending on the implementation of the JDBC driver (varies according to the vendor database), you can do the following:
Object decimalDigits = rs.getObject("DECIMAL_DIGITS");
if (decimalDigits == null) {
// do something
}
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.