I believe there is a statement leak in SQLServerPreparedStatement.getMetaData(). If no result set is present #getMetaData() calls #buildExecuteMetaData() which in tern creates and executes a statement and returns a result set. #close() on this result set and statement is never called because the caller of #getMetaData() only sees a ResultSetMetaData object which has no #close() method.
The following code can be used to reproduce the issue
try (Connection con = DriverManager.getConnection(connectionString);
PreparedStatement stmt = con.prepareStatement("SELECT 1")) {
ResultSetMetaData metaData = stmt.getMetaData();
assertEquals(1, metaData.getColumnCount());
}
I believe there is a statement leak in
SQLServerPreparedStatement.getMetaData(). If no result set is present#getMetaData()calls#buildExecuteMetaData()which in tern creates and executes a statement and returns a result set.#close()on this result set and statement is never called because the caller of#getMetaData()only sees aResultSetMetaDataobject which has no#close()method.The following code can be used to reproduce the issue