Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statement leak in SQLServerPreparedStatement.getMetaData() #308

Closed
marschall opened this issue May 20, 2017 · 1 comment
Closed

Statement leak in SQLServerPreparedStatement.getMetaData() #308

marschall opened this issue May 20, 2017 · 1 comment
Assignees
Projects

Comments

@marschall
Copy link
Contributor

marschall commented May 20, 2017

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());
}
@marschall marschall changed the title Statement leak in com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getMetaData() Statement leak in SQLServerPreparedStatement.getMetaData() May 20, 2017
@v-nisidh v-nisidh added this to the Long Term Goals milestone Jun 8, 2017
@peterbae peterbae self-assigned this Aug 18, 2017
@peterbae
Copy link
Contributor

Fixed in #455

@lilgreenbird lilgreenbird added this to Closed Issues in MSSQL JDBC Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

4 participants