如何检查从数据库中取得的double值的空值 [英] How to check for null value for a double which is taken from a database
本文介绍了如何检查从数据库中取得的double值的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ResultSet rs = ....提取数据库中的双重值
while(...){
rs.getDouble(num);
}
如何检查rs.getDouble(num)的值是null。由于这个值被存储为一个(MySQL)双精度,我想把它存储在我的JVM中作为一个double,我不能简单地使用!= null。
是最简单的方法。将值转换为Double(),然后执行.equals(null)是最简单/最好的(在您看来)的方式?
解决方案
在rs.getDouble()之后测试rs.wasNull()。
I am extracting values from a database. I am extracting a double value from a database using
ResultSet rs = ....;
while(...){
rs.getDouble("num");
}
How do I check if the value of rs.getDouble("num") is a null. Since the value is stored as a (MySQL) double and I want to store it in my JVM as a double, I can't simply use !=null.
What is the easiest way. Would converting the value to a Double() and then doing .equals(null) be the easiest/best (in your opinion) way?
解决方案
Test rs.wasNull() after the rs.getDouble().
这篇关于如何检查从数据库中取得的double值的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文