Bug #84117 includeThreadNamesAsStatementComment ignored when using prepared statement
Submitted: 8 Dec 2016 14:49 Modified: 13 Dec 2016 16:47
Reporter: Radosław Postołowicz Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.40 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[8 Dec 2016 14:49] Radosław Postołowicz
Description:
Thread name as comment is not included into query when using prepared statement.

How to repeat:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ThreadNamesTest {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        try (
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb?includeThreadNamesAsStatementComment=true", "user", "pass");
            PreparedStatement preparedStatement = connection.prepareStatement("select 1");
            ResultSet resultSet = preparedStatement.executeQuery()
        ) {

        }
    }
}
[13 Dec 2016 16:46] Filipe Silva
Hi Radosław,

Thank you for this bug report.

This was verified as described.
[28 Aug 2023 14:30] OCA Admin
Contribution submitted via Github - Fix for Bug#84117 PreparedStatement support includeThreadNamesAsStatementComment 
(*) Contribution by yyjun yyjun (Github cxzl25, mysql-connector-j/pull/99#issuecomment-1695748881): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1475708784.txt (text/plain), 2.07 KiB.