Reputation: 579
My code looks like this:
PreparedStatement ask = connectionToSql.prepareStatement("SELECT COUNT(*) FROM tableName");
ResultSet result = ask.executeQuery();
So the result object will only have one int, Integer or any other type of value, won't it? How can I get it?
Upvotes: 1
Views: 1371
Reputation: 311458
You could use the getInt(int)
method:
if (result.next()) { // just in case
int count = result.getInt(1); // note that indexes are one-based
}
Upvotes: 5