Getting the Number of Rows in a Database Table
This example gets the number of rows in a table using the SQL
statement `SELECT COUNT(*)'.
try {
// Select the number of rows in the table
Statement stmt = connection.createStatement();
ResultSet resultSet = stmt.executeQuery("SELECT COUNT(*) FROM my_table");
// Get the number of rows from the result set
resultSet.next();
int rowcount = resultSet.getInt(1);
} catch (SQLException e) {
}
statement stmt = connection.createStatement();
errm wad does the connection in this statement refer to?
Here's some code that will create a connection:
http://exampledepot.com/egs/java.sql/ConnectMySql.html