Skip to content

Statement leak in SQLServerPreparedStatement.getMetaData() #308

@marschall

Description

@marschall

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());
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions