diff --git a/src/main/java/com/zaxxer/hikari/pool/ProxyStatement.java b/src/main/java/com/zaxxer/hikari/pool/ProxyStatement.java index 4bdce5001..45ca772ea 100644 --- a/src/main/java/com/zaxxer/hikari/pool/ProxyStatement.java +++ b/src/main/java/com/zaxxer/hikari/pool/ProxyStatement.java @@ -227,8 +227,13 @@ public ResultSet getResultSet() throws SQLException { public ResultSet getGeneratedKeys() throws SQLException { var resultSet = delegate.getGeneratedKeys(); - if (proxyResultSet == null || ((ProxyResultSet) proxyResultSet).delegate != resultSet) { - proxyResultSet = ProxyFactory.getProxyResultSet(connection, this, resultSet); + if (resultSet != null) { + if (proxyResultSet == null || ((ProxyResultSet) proxyResultSet).delegate != resultSet) { + proxyResultSet = ProxyFactory.getProxyResultSet(connection, this, resultSet); + } + } + else { + proxyResultSet = null; } return proxyResultSet; }