0

クエリ:

 select count(*) from table_name

DB: SQL サーバー

totalrowcount = Integer.parseInt(resultSet.getString(1));

カウントを返すクエリを実行しようとすると、から値を取得しようとすると例外がスローされresultSetます。

例外:

com.microsoft.sqlserver.jdbc.SQLServerException: Could not find stored procedure 'count'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
    at com.heb.endeca.util.BatchManagerHelper.getRowCount(BatchManagerHelper.java:91)
    at com.heb.endeca.util.BatchManagerHelper.generateFeed(BatchManagerHelper.java:70)
    at com.heb.endeca.batch.BatchManager.startEndecaBatchManager(BatchManager.java:87)
    at com.heb.endeca.batch.BatchManager.main(BatchManager.java:50)
4

1 に答える 1

0

カウントは数値を返します。

select count(*) num_rows from table_name

totalrowcount = 0;

if(rs.next())
{
    totalrowcount = rs.getInt("num_rows");
}
于 2015-01-23T20:03:11.690 に答える