pgjdbc-ng icon indicating copy to clipboard operation
pgjdbc-ng copied to clipboard

Inconsistent Handling of Invalid setFetchDirection Input between ResultSet and Statement

Open dwenking opened this issue 1 year ago • 0 comments

When an invalid fetch direction value is passed to setFetchDirection, the ResultSet object accepts it without throwing an exception, whereas the Statement object correctly throws a SQLException for the same invalid input.

@Test
public void test() throws SQLException {
    Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test11?user=user&password=password");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.getGeneratedKeys();
    rs.setFetchDirection(425635067); // succeed
    System.out.println(rs.getFetchDirection());
    stmt.setFetchDirection(425635067); // java.sql.SQLException: Illegal argument
}

dwenking avatar Nov 16 '23 08:11 dwenking