JDBC-SQLITE选择变量 [英] JDBC - SQLITE Select to variable
问题描述
我正在尝试运行查询/选择语句并将其保存在变量中.我知道如何从特定的列中获取特定的内容,而不是从计数行中获取.
I am trying to run a query / select statement and save it in a variable. I know how to get something specific from a specific column but not from counting rows.
这是我专门获得MYID时的工作.
This is working as I getting MYID specifically.
ResultSet MYIDrs = stmtCFG.executeQuery( "SELECT rowid, MYID from MYINDEX order by rowid desc limit 1;" );
MYID = MYIDrs.getString("MYID");
现在,我试图计算在SQLite客户端中可用但在jdbc中不可用的行,因为我无法确定要请求什么.
Now I am trying to count the rows that works in SQLite client but not in the jdbc as I can't figure out what to request.
这就是我所拥有的,但并没有达到我的期望.
this is what I have but is not resulting in what I am expecting.
ResultSet FILE_COUNTrs = stmtCFG.executeQuery( "SELECT count(*) from TABLE where MYID = '"+MYID+"';");
FILE_COUNT = FILE_COUNTrs.getString(?????);
问题或问题是:我在??????中输入什么?因为我已经尝试了一切.
problem or question is: What do I put in the ????? as I already tried everything.
我希望看到一个数字.
推荐答案
很抱歉,我给我分配了名称TOTAL来找到我想要的东西
I am really sorry I found what I was looking for by assigning a name TOTAL
这是我的代码,可以正常工作...
This is my code and it works...
ResultSet FILE_COUNTrs = stmtCFG.executeQuery( "SELECT count(*) AS TOTAL from TABLE where MYID = '"+MYID+"';");
FILE_COUNT = FILE_COUNTrs.getString("TOTAL");
这篇关于JDBC-SQLITE选择变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!