我想使用 DQL 的 COUNT 命令获取我找到的值。通常,我将要访问的列名称输入到 getInt() getString() 方法中。当没有特定的列名称时我应该做什么。
{
String query = "select count(*) as count from dm_user;";
return query;
}
获取结果的代码
{
IDfCollection total = dql.execute(session, IDfQuery.DF_READ_QUERY);
while (total.next()){
cint = total.getInt("count");
}
Tomcat 结果
DfException:: THREAD: http-8080-2; MSG: [DM_QUERY_E_SYNTAX]error: "A Parser Error (syntax error) has occurred in the vicinity of: select count(*) as count"; ERRORCODE: 100; NEXT: null
最佳答案
您正在使用 count
这是您的列自定义名称的关键字,您发布的错误清楚地表明了这一点:解析器错误(语法错误)
这样就可以了
select count(*) as quantity from dm_user;
并获取结果,例如
IDfCollection total = dql.execute(session, IDfQuery.DF_READ_QUERY);
while (total.next()){
cint = total.getInt("quantity");
可以工作
关于java - 如何在 Java 程序中访问 DQL count() 查询的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39796843/