@ Nullable public static String firstString ( PreparedStatement stmt ) throws SQLException { ResultSet rs = stmt . executeQuery ( ) ; String s = rs . next ( ) ? rs . getString ( 1 ) : null ; stmt . close ( ) ; return s ; }
Execute the query get the String value in the first row and column of the result set and close the statement .