![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e255. Getting the Number of Rows in a Database TableThis 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) { }
e252. Getting Data from a Result Set e253. Determining If a Fetched Value Is NULL e254. Getting the Column Names in a Result Set e256. Getting BLOB Data from a Database Table e257. Matching with Wildcards in a SQL Statement © 2002 Addison-Wesley. |