没有结果时executeQuery(String sql)会返回什么?

编程入门 行业动态 更新时间:2024-10-28 04:23:16
本文介绍了没有结果时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.

推荐答案

您检查了 ResultSet的下一个方法。最初ResultSet的光标指向第一行之前,第一次调用next()返回false意味着ResultSet中没有数据。请参阅如何获取ResultSet的大小?,因为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)会返回什么?

本文发布于:2023-10-26 12:40:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530173.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:executeQuery   String   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!