hasRow 在填充的数据库上返回 false - SQLite4Java
我正在尝试使用以下代码检索数据库中的所有行:
我创建了一个包含两个对象,只是为了测试代码是否有效(稍后将扩展不同数量的列的机会)。
当执行到达 if 语句时,它的计算结果为 false 并跳出循环,即使该工具显示其中存在内部数据:
作者网站上的示例似乎很相似,并且搜索更好的示例没有返回任何有用的结果。
我哪里出了问题,是我对 SQL 语句的初始配置还是我处理返回查询的方式?
谢谢。
I am trying to retrieve all the rows that are in my database with the following code:
I have created a class that holds two objects, simply for the purpose of testing whether the code works or not (It will be expanded for the chance of differing amounts of columns at a later date) .
When execution reaches the if statement, it evaluates to false and breaks out of the loop even though this tool shows there is inface data inside of it:
The sample on the authors website seems to be similar and searches for better examples have returned nothing of use.
Where am I going wrong, is it my initial configuration of the SQL statement or is it the way I am handling the query returned?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有要使用
columnXYZ
方法读取的数据,SQLiteStatement.hasRow()
返回 true。仅当您至少调用一次SQLiteStatement.step()
后,才会发生这种情况。在您的示例中调用 hasRow 是不必要的。
SQLiteStatement.hasRow()
returns true if there's data to be read with thecolumnXYZ
methods. This will only happen after you've calledSQLiteStatement.step()
at least once.The call to hasRow in your example isn't necessary.
db.open(false)
返回什么?也许您正在创建一个空数据库,而不是打开您认为的数据库。也许您的意思是
user.home
?What does
db.open(false)
return? Perhaps you are creating an empty database rather than opening the one you think.Perhaps you meant
user.home
?