Android MySQLLite 选择查询不起作用,不从代码中获取结果
我正在开发一个 Android 应用程序并有一个以下查询:
result = myDataBase.query(HD_TABLENAME, new String[]{HD_KEYDATE, HD_KEYFESTID},
"YEAR = "+ year +" AND MONTH = " + month, null, null, null, HD_KEYDATE);
我编写了一个调用此查询的自定义 DataBaseHelper。
上述结果生成以下查询:
SELECT DATE, FESTIVALID FROM HOLIDAYDATES WHERE YEAR = 2010 AND MONTH = 1 ORDER BY DATE
当我从 SQLLite admin 对同一文件执行相同查询时,它返回所需的行。
也不例外,我怎样才能使上述工作发挥作用。 数据库存在并且适用于先前的查询。 我可以检查结果对象的任何属性以查看确切的错误是什么?
不确定这是否有帮助: 执行查询后收到的 logcat 消息:
04-19 10:39:54.803: DEBUG/SntpClient(71): 请求时间失败: java.net.SocketException: 协议不支持地址族
澄清: 其中一个属性具有以下特点: result.mStackTrace 的值 = android.database.sqlite.DatabaseObjectNotClosedException: 应用程序没有关闭此处打开的游标或数据库对象
现在,我想首先我必须关闭并打开一些我愚蠢地保持打开状态的游标,但现在正在尝试找到它,如果您能提出任何建议,请这样做。
其他问题,有什么方法可以查看数据库的打开连接吗?
I am developing an Android application and have a following query:
result = myDataBase.query(HD_TABLENAME, new String[]{HD_KEYDATE, HD_KEYFESTID},
"YEAR = "+ year +" AND MONTH = " + month, null, null, null, HD_KEYDATE);
I have written a custom DataBaseHelper which calls this query.
The above results into the following query:
SELECT DATE, FESTIVALID FROM HOLIDAYDATES WHERE YEAR = 2010 AND MONTH = 1 ORDER BY DATE
when i execute the same query from SQLLite admin on the same file, it returns the required rows.
There is no exception, how can i get the above to work.
The database exists and It works for a previous query.
Is there any property of the result object which I can check to see what is the exact error?
NOT SURE IF THIS WILL HELP:
A logcat message that I get after the execution of the query :
04-19 10:39:54.803: DEBUG/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
CLARIFICATION:
One of the properties has this:
result.mStackTrace has the value = android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
Now, I guess first I have to close and open some cursor which I foolishly left open, but now trying to find it, if you can suggest anything, please do.
ADDITIONAL QUESTION, is there any way to see the open connections to the database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你用过吗。
dataBase = this.openOrCreateDatabase(dbName, MODE_PRIVATE, null);
Have You used.
dataBase = this.openOrCreateDatabase(dbName, MODE_PRIVATE, null);