Fix executeQuery to not run statement.execute()

This commit is contained in:
김선우
2025-01-29 11:53:44 +09:00
parent 2e62abe6df
commit 041c8fbddc
2 changed files with 33 additions and 1 deletions

View File

@@ -53,9 +53,20 @@ public class JDBC4Statement implements Statement {
this.resultSetHoldability = resultSetHoldability;
}
// TODO: should executeQuery run execute right after preparing the statement?
@Override
public ResultSet executeQuery(String sql) throws SQLException {
execute(sql);
ensureOpen();
statement = this.withConnectionTimeout(
() -> {
try {
// TODO: if sql is a readOnly query, do we still need the locks?
connectionLock.lock();
return connection.prepare(sql);
} finally {
connectionLock.unlock();
}
});
requireNonNull(statement, "statement should not be null after running execute method");
return new JDBC4ResultSet(statement.getResultSet());