Bug #104592 the connection_j version is 8.0 access the column type is tinyint(1)
Submitted: 11 Aug 2021 9:54 Modified: 16 Aug 2021 8:59
Reporter: jom jon Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.6 and 8.0 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[11 Aug 2021 9:54] jom jon
Description:
Hello everyone.I operate column that the type is tinyint(1) by mysql-connection-J 8.0.26 or mysql-connection-j 5.6. The result is different to update the connection url.The version is 5.6 add "tinyInt1isBit=false" int the url,the result is int,but use 8.0 still is boolean.
so if i want to return int data rather than boolean in the version is 8.0 by update the connection url,like the version is 5.6's result.what should I do?

How to repeat:
/**
* table A1 DDL statement :
* CREATE TABLE `A1` (
  `id` int DEFAULT NULL,
  `type` tinyint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='ad';
*/
public void testSQL() throws Exception {
        Connection conn = null;
        Statement stmt = null;
        try {
            
            Class.forName("com.mysql.cj.jdbc.Driver");

           
            System.out.println("connection database...");
            DriverManager.setLoginTimeout(90);
            Properties properties = new Properties();
            properties.put("remarksReporting", "true");
            properties.put("user", "root");
            properties.put("password", "aaa");
            conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", "root","Hello123$");
          
            stmt = conn.createStatement();
            String sql;
            changeDatabase(conn);
            sql = "SELECT * FROM `TEST`.`A1`";
            ResultSet rs = stmt.executeQuery(sql);

            
            while (rs.next()) {
               
                System.out.println(rs.getObject("type"));
            // the result is boolean rather than int 
                System.out.println(rs.getInt("type")); // it is ok
            }
            
            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException se) {
            
            se.printStackTrace();
        } catch (Exception e) {
            
            e.printStackTrace();
        } finally {
            
            try {
                if (stmt != null) stmt.close();
            } catch (SQLException se2) {
            }
            try {
                if (conn != null) conn.close();
            } catch (SQLException se) {
                se.printStackTrace();
            }
        }
        System.out.println("Goodbye!");
    }
[16 Aug 2021 8:59] Alexander Soklakov
Hi jom jon,

I can not reproduce the issue you have reported, with tinyInt1isBit=false Connector/J getObject() returns java.lang.Integer as expected. Please check your connection string for typos, maybe some properties are just ignored due to that.