本文介绍了没有结果时executeQuery(String sql)会返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当SQL查询的结果为零行时, executeQuery(String sql)会返回什么?如果它返回 ResultSet 对象,我们将如何检测到SQL Query没有返回任何内容。

What will executeQuery(String sql) return when the result of the SQL Query is zero rows>? If it returns a ResultSet Object, how will we detect that the SQL Query has returned nothing.

假设SQL查询为 SELECT 语句。

Assume the SQL Query to be a SELECT statement.

推荐答案

您检查了,因为Java中的Resultsets没有直接的size()或length()方法。

Did you check ResultSet's next method . Initially the ResultSet's cursor points to before the first row, the very first call to next() returns false implies there was no data in the ResultSet. See How do I get the size of a ResultSet? , since there is no direct size() or length() method for Resultsets in Java.

这篇关于没有结果时executeQuery(String sql)会返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:12
查看更多