public static int queryInt ( PreparedStatement stmt , int def ) throws SQLException { ResultSet rs = null ; try { rs = stmt . executeQuery ( ) ; if ( rs . next ( ) ) { int value = rs . getInt ( 1 ) ; if ( ! rs . wasNull ( ) ) { return value ; } } return def ; } finally { close ( rs ) ; } }
Runs a SQL query that returns a single integer value .