public static int queryForInt ( Statement stmt , String sql , int nullvalue ) { try { ResultSet rs = stmt . executeQuery ( sql ) ; try { if ( ! rs . next ( ) ) return nullvalue ; return rs . getInt ( 1 ) ; } finally { rs . close ( ) ; } } catch ( SQLException e ) { throw new DukeException ( e ) ; } }
Runs a query that returns a single int .