我的代码看起来像这样:
PreparedStatement ask = connectionToSql.prepareStatement("SELECT COUNT(*) FROM tableName");
ResultSet result = ask.executeQuery();
Run Code Online (Sandbox Code Playgroud)
所以结果对象只有一个int,Integer或任何其他类型的值,不是吗?我怎么才能得到它?
你可以使用这个getInt(int)方法:
if (result.next()) { // just in case
int count = result.getInt(1); // note that indexes are one-based
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
80 次 |
| 最近记录: |