0

询问 :

 select count(*) from table_name

数据库: Sqlserver

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

Count 返回一个数值。

select count(*) num_rows from table_name

totalrowcount = 0;

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