【发布时间】:2014-05-12 14:51:11
【问题描述】:
我正在数据库中查询数据库中可能为空的一些值。当我在 resultSet 上调用 getString() 时,如果 DB 值为 null,getString 返回的值是多少?这是javadoc:
Retrieves the value of the designated column in the current row of this ResultSet
object as a String in the Java programming language.
Parameters:
columnLabel the label for the column specified with the SQL AS clause. If the SQL AS
clause was not specified, then the label is the name of the column
Returns:
the column value; if the value is SQL NULL, the value returned is null
Throws:
SQLException - if the columnLabel is not valid; if a database access error occurs or
this method is called on a closed result set
它说返回值为空,但我不确定这是否意味着“空”或空。我知道我可以让我的代码明显测试这两个值以查看它是否为空,但我不希望它测试不必要的条件。
【问题讨论】:
-
做一个简单的测试。它将返回
null,而不是"null"。