[Solved, pending release]: Close java.sql.ResultSet objects used in the DB implementations
See original GitHub issueCurrently ResultSet objects have not been closed in our DB implementations, they need to be closed to avoid memory leaks.
example :
public static KeyValueInfo getKeyValue(Start start, String key) throws SQLException, StorageQueryException {
String QUERY = "SELECT value, created_at_time FROM " + Config.getConfig(start).getKeyValueTable()
+ " WHERE name = ?";
try (Connection con = ConnectionPool.getConnection(start);
PreparedStatement pst = con.prepareStatement(QUERY)) {
pst.setString(1, key);
ResultSet result = pst.executeQuery();
if (result.next()) {
return KeyValueInfoRowMapper.getInstance().mapOrThrow(result);
}
}
return null;
}
Result set interface looks like this :
public interface ResultSet extends Wrapper, AutoCloseable
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (26 by maintainers)
Top Results From Across the Web
Must JDBC Resultsets and Statements be closed separately ...
Per JDBC specs closing any higher object will automatically close lower objects. Closing Connection will close any Statement s that connection has created....
Read more >Closing Connection Does Not Close Statement And ResultSet
I tried a different database and driver (MySQL) and verified that the MySQL JDBC driver DOES close these two objects once the connection...
Read more >ResultSet (Java Platform SE 7 ) - Oracle Help Center
Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
Read more >Jaybird JDBC Driver Java Programmer's Manual
This manual covers Jaybird 4 and may use Java 8 and Firebird 3.0 specific features, but most examples and information also apply to...
Read more >Features - H2 Database Engine
Compatibility modes for IBM DB2, Apache Derby, HSQLDB, MS SQL Server, MySQL, Oracle, and PostgreSQL. Security Features. Includes a solution for the SQL...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @anugrahsinghal for resolving this issue.
I have added your profile to the contributor’s list in the core’s readme. Since these are refactor changes, they will be released in the next change to the core. Keeping this issue open until then.
Hey @rishabhpoddar Have made the changes to the PostgreSQL plugin. https://github.com/supertokens/supertokens-postgresql-plugin/pull/29