0

我正在使用以下简单查询来获取结果以进行测试。

    qName = "select total_requests from (select 10000 as total_requests from dual)"; //this can be dynamic query
    preStatement = connection.prepareStatement(qName);
    ParameterMetaData pmd = preStatement.getParameterMetaData();

    int stmtCount = pmd.getParameterCount();
    int paramsCount = params == null ? 0 : params.length;

    for (int i = 0; i < params.length; i++) {
        if (params[i] != null) {
            preStatement.setObject(i + 1, params[i]);
        } else {
            int sqlType = Types.VARCHAR;
            if (!paramValid) {
                try {
                    sqlType = pmd.getParameterType(i + 1);
                } catch (SQLException e) {
                    paramValid = true;
                }
            }
            preStatement.setNull(i + 1, sqlType);
        }
    }

 ResultSet   rs = preStatement.executeQuery();

一旦我执行第三行,应用程序就会抛出以下错误

Caused by: java.lang.AbstractMethodError: com.inet.pool.b.getParameterMetaData()Ljava/sql/ParameterMetaData;
        at com.core.admin.util.AnalyzeHelper.fillQuery(AnalyzeHelper.java:61)

这是由于子查询问题吗?如何解决这个问题?

4

2 回答 2

1

使用它来执行查询

preStatement.executeQuery();

您需要有一个结果集以供查看

ResultSet rs=preStatement.executeQuery();
while(rs.next())
{
rs.getString(1);// I assume that first column is a String.If it is an INT then use rs.getInt(1);

//similarly for other columns
}
于 2013-09-20T07:13:36.233 回答
0

它可能会帮助你。

qName = "select total_requests from (select 10000 as total_requests from dual)";
preStatement = connection.prepareStatement(qName);
ResultSet rs= preStatement.executeQuery();
于 2013-09-20T07:18:31.703 回答