gpt4 book ai didi

java - 如何从结果集中获得双倍而不是双倍?

转载 作者:IT老高 更新时间:2023-10-28 20:38:24 25 4
gpt4 key购买 nike

在使用 JDBC 结果集时,我希望得到 Double 而不是 double,因为该列可以为空。当列为空时,Rs.getDouble 返回 0.0。

最佳答案

您可以查看 wasNull在 ResultSet 上查看该值是否为 null

Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

如果你之后真的需要一个 Double,你可以从返回的 double 创建它。

关于java - 如何从结果集中获得双倍而不是双倍?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2158187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com