Search in sources :

Example 1 with MysqlType

use of com.mysql.cj.MysqlType in project JavaSegundasQuintas by ecteruel.

the class DateTimeRegressionTest method testBug20391832.

/**
 * Tests fix for Bug#20391832, SETOBJECT() FOR TYPES.TIME RESULTS IN EXCEPTION WHEN VALUE HAS FRACTIONAL PART.
 *
 * @throws Exception
 */
@Test
public void testBug20391832() throws Exception {
    createTable("testBug20391832", "(v varchar(40))");
    // fractional seconds are not supported in previous versions
    boolean withFract = versionMeetsMinimum(5, 6, 4);
    Properties props = new Properties();
    props.setProperty(PropertyKey.useSSL.getKeyName(), "false");
    props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
    props.setProperty(PropertyKey.connectionTimeZone.getKeyName(), "LOCAL");
    for (boolean useSSPS : new boolean[] { false, true }) {
        for (boolean sendFr : new boolean[] { false, true }) {
            System.out.println("useServerPrepStmts=" + useSSPS + "; sendFractSeconds=" + sendFr);
            props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "" + useSSPS);
            props.setProperty(PropertyKey.sendFractionalSeconds.getKeyName(), "" + sendFr);
            Connection testConn = getConnectionWithProps(timeZoneFreeDbUrl, props);
            this.pstmt = testConn.prepareStatement("insert into testBug20391832 values(?)");
            for (MysqlType type : new MysqlType[] { MysqlType.DATETIME, MysqlType.TIMESTAMP }) {
                subTestBug20391832(props, type, "2038-01-19", "2038-01-19 00:00:00");
                subTestBug20391832(props, type, "38-01-19", "2038-01-19 00:00:00");
                subTestBug20391832(props, type, "2038#01$19", "2038-01-19 00:00:00");
                subTestBug20391832(props, type, "38#01$19", "2038-01-19 00:00:00");
                subTestBug20391832(props, type, "20380119", "2038-01-19 00:00:00");
                subTestBug20391832(props, type, "380119", "2038-01-19 00:00:00");
                // resolved as a DATE literal
                subTestBug20391832(props, type, "030417", "2003-04-17 00:00:00");
                assertThrows(SQLException.class, ".* Conversion from java.time.Duration to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "12 1", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.Duration to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "12 13:04", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.Duration to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "12 1:4:1", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.Duration to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "12 1:04:17.123456789", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.Duration to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "-838:59:59", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "13:04:17", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "13:04", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "0417", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "03:14:07.012", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to " + type + " is not supported.", () -> {
                    subTestBug20391832(props, type, "031407.123", null);
                    return null;
                });
                assertThrows(SQLException.class, ".* There is no known date-time pattern for.*", () -> {
                    // wrong delimiter
                    subTestBug20391832(props, type, "031407#12", null);
                    return null;
                });
                subTestBug20391832(props, type, "2038-01-19 03:14:07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038-01-19 03:14:07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "38-01-19 03:14:07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "38-01-19 03:14:07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38-01-19 03:14:07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "2038#01$19 03@14%07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19 03@14%07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "38#01$19 03@14%07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "38#01$19 03@14%07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19 03@14%07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "2038#01$19T03@14%07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#01$19T03@14%07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "38#01$19T03@14%07", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "38#01$19T03@14%07.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "38#01$19T03@14%07.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "2038#1$19 3@14%7", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "2038#1$19T3@14%7.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19 3@14%7.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19T3@14%7.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19 3@14%7.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19T3@14%7.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19 3@14%7.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19T3@14%7.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19 3@14%7.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "2038#1$19T3@14%7.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "38#1$9 3@4%7", "2038-01-09 03:04:07");
                if (withFract) {
                    subTestBug20391832(props, type, "38#1$9T3@4%7.1", sendFr ? "2038-01-09 03:04:07.1" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.01", sendFr ? "2038-01-09 03:04:07.01" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.012", sendFr ? "2038-01-09 03:04:07.012" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.0123", sendFr ? "2038-01-09 03:04:07.0123" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.01234", sendFr ? "2038-01-09 03:04:07.01234" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.012345", sendFr ? "2038-01-09 03:04:07.012345" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.0123456", sendFr ? "2038-01-09 03:04:07.012346" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.01234567", sendFr ? "2038-01-09 03:04:07.012346" : "2038-01-09 03:04:07");
                    subTestBug20391832(props, type, "38#1$9T3@4%7.012345678", sendFr ? "2038-01-09 03:04:07.012346" : "2038-01-09 03:04:07");
                }
                subTestBug20391832(props, type, "20380119031407", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "20380119031407.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "20380119031407.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
                subTestBug20391832(props, type, "380119031407", "2038-01-19 03:14:07");
                if (withFract) {
                    subTestBug20391832(props, type, "380119031407.1", sendFr ? "2038-01-19 03:14:07.1" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.01", sendFr ? "2038-01-19 03:14:07.01" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.012", sendFr ? "2038-01-19 03:14:07.012" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.0123", sendFr ? "2038-01-19 03:14:07.0123" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.01234", sendFr ? "2038-01-19 03:14:07.01234" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.012345", sendFr ? "2038-01-19 03:14:07.012345" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.0123456", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.01234567", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                    subTestBug20391832(props, type, "380119031407.012345678", sendFr ? "2038-01-19 03:14:07.012346" : "2038-01-19 03:14:07");
                }
            }
            // ================================================
            subTestBug20391832(props, MysqlType.TIME, "12 1", "289:0:0");
            subTestBug20391832(props, MysqlType.TIME, "-12 1", "-289:0:0");
            subTestBug20391832(props, MysqlType.TIME, "12 12:04", "300:4:0");
            subTestBug20391832(props, MysqlType.TIME, "-12 12:04", "-300:4:0");
            subTestBug20391832(props, MysqlType.TIME, "12 1:4:1", "289:4:1");
            subTestBug20391832(props, MysqlType.TIME, "-12 1:4:7", "-289:4:7");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "5 1:04:17.123456789", sendFr ? "121:4:17.123457" : "121:4:17");
                subTestBug20391832(props, MysqlType.TIME, "-5 1:04:17.123456789", sendFr ? "-121:4:17.123457" : "-121:4:17");
            }
            subTestBug20391832(props, MysqlType.TIME, "25:59:59", "25:59:59");
            subTestBug20391832(props, MysqlType.TIME, "-838:59:59", "-838:59:59");
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalDate to TIME is not supported.", () -> {
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalDate to TIME is not supported.", () -> {
                subTestBug20391832(props, MysqlType.TIME, "38-01-19", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalDate to TIME is not supported.", () -> {
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalDate to TIME is not supported.", () -> {
                subTestBug20391832(props, MysqlType.TIME, "38#01$19", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalDate to TIME is not supported.", () -> {
                subTestBug20391832(props, MysqlType.TIME, "20380119", null);
                return null;
            });
            subTestBug20391832(props, MysqlType.TIME, "120119", "12:01:19");
            subTestBug20391832(props, MysqlType.TIME, "13:04:17", "13:04:17");
            subTestBug20391832(props, MysqlType.TIME, "13:04", "13:04:00");
            subTestBug20391832(props, MysqlType.TIME, "130417", "13:04:17");
            subTestBug20391832(props, MysqlType.TIME, "0417", "00:04:17");
            subTestBug20391832(props, MysqlType.TIME, "17", "00:00:17");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "0417.1234567", sendFr ? "00:04:17.123457" : "00:04:17");
                subTestBug20391832(props, MysqlType.TIME, "17.1234567", sendFr ? "00:00:17.123457" : "00:00:17");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "3:14:07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:4:07.012345", sendFr ? "03:04:07.012345" : "03:04:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "3:4:7.0123456", sendFr ? "03:04:07.012346" : "03:04:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:7.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "03:14:07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "031407.123", sendFr ? "03:14:07.123" : "03:14:07");
            }
            assertThrows(SQLException.class, ".* There is no known date-time pattern for.*", () -> {
                // wrong delimiter
                subTestBug20391832(props, MysqlType.TIME, "031407#12", null);
                return null;
            });
            subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038-01-19 03:14:07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38-01-19 03:14:07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19 03@14%07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19 03@14%07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "2038#01$19T03@14%07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#01$19T03@14%07.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "2038#1$19 3@14%7", "03:14:07");
            subTestBug20391832(props, MysqlType.TIME, "38#1$19 3@14%7", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19 3@14%7.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19 3@14%7.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19T3@14%7.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "38#1$19 3@14%7.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "20380119031407", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "20380119031407.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            subTestBug20391832(props, MysqlType.TIME, "380119031407", "03:14:07");
            if (withFract) {
                subTestBug20391832(props, MysqlType.TIME, "380119031407.1", sendFr ? "03:14:07.1" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.01", sendFr ? "03:14:07.01" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.012", sendFr ? "03:14:07.012" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.0123", sendFr ? "03:14:07.0123" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.01234", sendFr ? "03:14:07.01234" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.012345", sendFr ? "03:14:07.012345" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.0123456", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.01234567", sendFr ? "03:14:07.012346" : "03:14:07");
                subTestBug20391832(props, MysqlType.TIME, "380119031407.012345678", sendFr ? "03:14:07.012346" : "03:14:07");
            }
            // ================================================
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-1-9", "2038-01-09");
            subTestBug20391832(props, MysqlType.DATE, "38-1-9", "2038-01-09");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "030417", "2003-04-17");
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "12 1", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "12 13:04", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "12 1:4:1", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "12 1:04:17.123456789", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "-838:59:59", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "13:04:17", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "13:04", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "0417", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "03:14:07.012", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to DATE is not supported.", () -> {
                subTestBug20391832(props, MysqlType.DATE, "031407.123", null);
                return null;
            });
            assertThrows(SQLException.class, ".* There is no known date-time pattern for.*", () -> {
                // wrong delimiter
                subTestBug20391832(props, MysqlType.DATE, "031407#12", null);
                return null;
            });
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038-01-19 03:14:07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38-01-19 03:14:07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19 03@14%07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19 03@14%07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#01$19T03@14%07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.12", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#01$19T03@14%07.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "2038#1$19 3@14%7", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "38#1$9 3@4%7", "2038-01-09");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.01", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "20380119031407.012345678", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.1", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.01", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.012", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.0123", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.01234", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.012345", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.0123456", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.01234567", "2038-01-19");
            subTestBug20391832(props, MysqlType.DATE, "380119031407.012345678", "2038-01-19");
            // ================================================
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "030417", "2003");
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "13:04:17", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "13:04", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "0417", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "03:14:07.012", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.LocalTime to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "031407.123", null);
                return null;
            });
            assertThrows(SQLException.class, ".* There is no known date-time pattern for.*", () -> {
                // wrong delimiter
                subTestBug20391832(props, MysqlType.YEAR, "031407#12", null);
                return null;
            });
            assertThrows(SQLException.class, ".* Conversion from java.time.Duration to YEAR is not supported.", () -> {
                subTestBug20391832(props, MysqlType.YEAR, "-838:59:59", null);
                return null;
            });
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.012345678", "2038");
            assertThrows(SQLException.class, ".* There is no known date-time pattern for.*", () -> {
                // nanos part is too long
                subTestBug20391832(props, MysqlType.YEAR, "2038-01-19 03:14:07.0123456789", null);
                return null;
            });
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38-01-19 03:14:07.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19 03@14%07.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19 03@14%07.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#01$19T03@14%07.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.12", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#01$19T03@14%07.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "2038#1$19 3@14%7", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "38#1$9 3@4%7", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.01", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "20380119031407.012345678", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.1", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.01", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.012", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.0123", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.01234", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.012345", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.0123456", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.01234567", "2038");
            subTestBug20391832(props, MysqlType.YEAR, "380119031407.012345678", "2038");
            testConn.close();
        }
    }
}
Also used : MysqlType(com.mysql.cj.MysqlType) Connection(java.sql.Connection) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 2 with MysqlType

use of com.mysql.cj.MysqlType in project JavaSegundasQuintas by ecteruel.

the class ResultSetImpl method getObjectStoredProc.

@Override
public Object getObjectStoredProc(int columnIndex, int desiredSqlType) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);
    Object value = this.thisRow.getBytes(columnIndex - 1);
    if (value == null) {
        return null;
    }
    Field field = this.columnDefinition.getFields()[columnIndex - 1];
    MysqlType desiredMysqlType = MysqlType.getByJdbcType(desiredSqlType);
    switch(desiredMysqlType) {
        case BIT:
        case BOOLEAN:
            return Boolean.valueOf(getBoolean(columnIndex));
        case TINYINT:
        case TINYINT_UNSIGNED:
            return Integer.valueOf(getInt(columnIndex));
        case SMALLINT:
        case SMALLINT_UNSIGNED:
            return Integer.valueOf(getInt(columnIndex));
        case INT:
        case INT_UNSIGNED:
        case MEDIUMINT:
        case MEDIUMINT_UNSIGNED:
            if (!field.isUnsigned() || field.getMysqlTypeId() == MysqlType.FIELD_TYPE_INT24) {
                return Integer.valueOf(getInt(columnIndex));
            }
            return Long.valueOf(getLong(columnIndex));
        case BIGINT:
            return Long.valueOf(getLong(columnIndex));
        case BIGINT_UNSIGNED:
            return getBigInteger(columnIndex);
        case DECIMAL:
        case DECIMAL_UNSIGNED:
            String stringVal = getString(columnIndex);
            BigDecimal val;
            if (stringVal != null) {
                if (stringVal.length() == 0) {
                    val = new BigDecimal(0);
                    return val;
                }
                try {
                    val = new BigDecimal(stringVal);
                } catch (NumberFormatException ex) {
                    throw SQLError.createSQLException(Messages.getString("ResultSet.Bad_format_for_BigDecimal", new Object[] { stringVal, Integer.valueOf(columnIndex) }), MysqlErrorNumbers.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
                }
                return val;
            }
            return null;
        case FLOAT:
        case FLOAT_UNSIGNED:
            return new Float(getFloat(columnIndex));
        case DOUBLE:
        case DOUBLE_UNSIGNED:
            return new Double(getDouble(columnIndex));
        case CHAR:
        case ENUM:
        case SET:
        case VARCHAR:
        case TINYTEXT:
            return getString(columnIndex);
        case JSON:
        case TEXT:
        case MEDIUMTEXT:
        case LONGTEXT:
            return getStringForClob(columnIndex);
        case BINARY:
        case GEOMETRY:
        case VARBINARY:
        case TINYBLOB:
        case BLOB:
        case MEDIUMBLOB:
        case LONGBLOB:
            return getBytes(columnIndex);
        case YEAR:
        case DATE:
            if (field.getMysqlType() == MysqlType.YEAR && !this.yearIsDateType) {
                return Short.valueOf(getShort(columnIndex));
            }
            return getDate(columnIndex);
        case TIME:
            return getTime(columnIndex);
        case TIMESTAMP:
            return getTimestamp(columnIndex);
        default:
            return getString(columnIndex);
    }
}
Also used : Field(com.mysql.cj.result.Field) MysqlType(com.mysql.cj.MysqlType) BigDecimal(java.math.BigDecimal)

Example 3 with MysqlType

use of com.mysql.cj.MysqlType in project JavaSegundasQuintas by ecteruel.

the class ColumnDefinitionReader method unpackField.

/**
 * Unpacks the Field information from the given packet.
 *
 * @param packet
 *            the packet containing the field information
 * @param characterSetMetadata
 *            encoding of the metadata in the packet
 *
 * @return the unpacked field
 */
protected Field unpackField(NativePacketPayload packet, String characterSetMetadata) {
    int offset, length;
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    // skip database name
    packet.setPosition(packet.getPosition() + length);
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    offset = packet.getPosition();
    LazyString databaseName = new LazyString(packet.getByteBuffer(), offset, length, characterSetMetadata);
    packet.setPosition(packet.getPosition() + length);
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    offset = packet.getPosition();
    LazyString tableName = new LazyString(packet.getByteBuffer(), offset, length, characterSetMetadata);
    packet.setPosition(packet.getPosition() + length);
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    offset = packet.getPosition();
    LazyString originalTableName = new LazyString(packet.getByteBuffer(), offset, length, characterSetMetadata);
    packet.setPosition(packet.getPosition() + length);
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    offset = packet.getPosition();
    LazyString columnName = new LazyString(packet.getByteBuffer(), offset, length, characterSetMetadata);
    packet.setPosition(packet.getPosition() + length);
    length = (int) packet.readInteger(IntegerDataType.INT_LENENC);
    offset = packet.getPosition();
    LazyString originalColumnName = new LazyString(packet.getByteBuffer(), offset, length, characterSetMetadata);
    packet.setPosition(packet.getPosition() + length);
    packet.readInteger(IntegerDataType.INT1);
    short collationIndex = (short) packet.readInteger(IntegerDataType.INT2);
    long colLength = packet.readInteger(IntegerDataType.INT4);
    int colType = (int) packet.readInteger(IntegerDataType.INT1);
    short colFlag = (short) packet.readInteger(this.protocol.getServerSession().hasLongColumnInfo() ? IntegerDataType.INT2 : IntegerDataType.INT1);
    int colDecimals = (int) packet.readInteger(IntegerDataType.INT1);
    String encoding = this.protocol.getServerSession().getCharsetSettings().getJavaEncodingForCollationIndex(collationIndex);
    MysqlType mysqlType = NativeProtocol.findMysqlType(this.protocol.getPropertySet(), colType, colFlag, colLength, tableName, originalTableName, collationIndex, encoding);
    // Protocol returns precision and scale differently for some types. We need to align then to I_S.
    switch(mysqlType) {
        case TINYINT:
        case TINYINT_UNSIGNED:
        case SMALLINT:
        case SMALLINT_UNSIGNED:
        case MEDIUMINT:
        case MEDIUMINT_UNSIGNED:
        case INT:
        case INT_UNSIGNED:
        case BIGINT:
        case BIGINT_UNSIGNED:
        case BOOLEAN:
            colLength = mysqlType.getPrecision().intValue();
            break;
        case DECIMAL:
            colLength--;
            if (colDecimals > 0) {
                colLength--;
            }
            break;
        case DECIMAL_UNSIGNED:
            if (colDecimals > 0) {
                colLength--;
            }
            break;
        case FLOAT:
        case FLOAT_UNSIGNED:
        case DOUBLE:
        case DOUBLE_UNSIGNED:
            // It's probably a mistake that it's exposed by protocol as a decimals and it should be replaced with 0.
            if (colDecimals == 31) {
                colDecimals = 0;
            }
            break;
        default:
            break;
    }
    return new Field(databaseName, tableName, originalTableName, columnName, originalColumnName, colLength, colType, colFlag, colDecimals, collationIndex, encoding, mysqlType);
}
Also used : MysqlType(com.mysql.cj.MysqlType) Field(com.mysql.cj.result.Field) LazyString(com.mysql.cj.util.LazyString) LazyString(com.mysql.cj.util.LazyString)

Example 4 with MysqlType

use of com.mysql.cj.MysqlType in project JavaSegundasQuintas by ecteruel.

the class DatabaseMetaData method getBestRowIdentifier.

@Override
public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, final String table, int scope, boolean nullable) throws SQLException {
    if (table == null) {
        throw SQLError.createSQLException(Messages.getString("DatabaseMetaData.2"), MysqlErrorNumbers.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
    }
    Field[] fields = new Field[8];
    fields[0] = new Field("", "SCOPE", this.metadataCollationIndex, this.metadataEncoding, MysqlType.SMALLINT, 5);
    fields[1] = new Field("", "COLUMN_NAME", this.metadataCollationIndex, this.metadataEncoding, MysqlType.CHAR, 32);
    fields[2] = new Field("", "DATA_TYPE", this.metadataCollationIndex, this.metadataEncoding, MysqlType.INT, 32);
    fields[3] = new Field("", "TYPE_NAME", this.metadataCollationIndex, this.metadataEncoding, MysqlType.CHAR, 32);
    fields[4] = new Field("", "COLUMN_SIZE", this.metadataCollationIndex, this.metadataEncoding, MysqlType.INT, 10);
    fields[5] = new Field("", "BUFFER_LENGTH", this.metadataCollationIndex, this.metadataEncoding, MysqlType.INT, 10);
    fields[6] = new Field("", "DECIMAL_DIGITS", this.metadataCollationIndex, this.metadataEncoding, MysqlType.SMALLINT, 10);
    fields[7] = new Field("", "PSEUDO_COLUMN", this.metadataCollationIndex, this.metadataEncoding, MysqlType.SMALLINT, 5);
    final ArrayList<Row> rows = new ArrayList<>();
    final Statement stmt = this.conn.getMetadataSafeStatement();
    String db = getDatabase(catalog, schema);
    try {
        new IterateBlock<String>(getDatabaseIterator(db)) {

            @Override
            void forEach(String dbStr) throws SQLException {
                ResultSet results = null;
                try {
                    StringBuilder queryBuf = new StringBuilder("SHOW COLUMNS FROM ");
                    queryBuf.append(StringUtils.quoteIdentifier(table, DatabaseMetaData.this.quotedId, DatabaseMetaData.this.pedantic));
                    queryBuf.append(" FROM ");
                    queryBuf.append(StringUtils.quoteIdentifier(dbStr, DatabaseMetaData.this.quotedId, DatabaseMetaData.this.pedantic));
                    try {
                        results = stmt.executeQuery(queryBuf.toString());
                    } catch (SQLException sqlEx) {
                        // If SQLState is 42S02, ignore this SQLException it means the table doesn't exist....
                        String sqlState = sqlEx.getSQLState();
                        // Sometimes SQLState is not mapped correctly for pre-4.1 so use error code instead.
                        int errorCode = sqlEx.getErrorCode();
                        if (!"42S02".equals(sqlState) && errorCode != MysqlErrorNumbers.ER_NO_SUCH_TABLE && errorCode != MysqlErrorNumbers.ER_BAD_DB_ERROR) {
                            throw sqlEx;
                        }
                    }
                    while (results != null && results.next()) {
                        String keyType = results.getString("Key");
                        if (keyType != null) {
                            if (StringUtils.startsWithIgnoreCase(keyType, "PRI")) {
                                byte[][] rowVal = new byte[8][];
                                rowVal[0] = Integer.toString(java.sql.DatabaseMetaData.bestRowSession).getBytes();
                                rowVal[1] = results.getBytes("Field");
                                String type = results.getString("Type");
                                int size = stmt.getMaxFieldSize();
                                int decimals = 0;
                                boolean hasLength = false;
                                /*
                                     * Parse the Type column from MySQL
                                     */
                                if (type.indexOf("enum") != -1) {
                                    String temp = type.substring(type.indexOf("("), type.indexOf(")"));
                                    java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(temp, ",");
                                    int maxLength = 0;
                                    while (tokenizer.hasMoreTokens()) {
                                        maxLength = Math.max(maxLength, (tokenizer.nextToken().length() - 2));
                                    }
                                    size = maxLength;
                                    decimals = 0;
                                    type = "enum";
                                } else if (type.indexOf("(") != -1) {
                                    hasLength = true;
                                    if (type.indexOf(",") != -1) {
                                        size = Integer.parseInt(type.substring(type.indexOf("(") + 1, type.indexOf(",")));
                                        decimals = Integer.parseInt(type.substring(type.indexOf(",") + 1, type.indexOf(")")));
                                    } else {
                                        size = Integer.parseInt(type.substring(type.indexOf("(") + 1, type.indexOf(")")));
                                    }
                                    type = type.substring(0, type.indexOf("("));
                                }
                                MysqlType ft = MysqlType.getByName(type.toUpperCase());
                                rowVal[2] = s2b(String.valueOf(ft.getJdbcType()));
                                rowVal[3] = s2b(type);
                                rowVal[4] = hasLength ? Integer.toString(size + decimals).getBytes() : Long.toString(ft.getPrecision()).getBytes();
                                rowVal[5] = Integer.toString(maxBufferSize).getBytes();
                                rowVal[6] = Integer.toString(decimals).getBytes();
                                rowVal[7] = Integer.toString(java.sql.DatabaseMetaData.bestRowNotPseudo).getBytes();
                                rows.add(new ByteArrayRow(rowVal, getExceptionInterceptor()));
                            }
                        }
                    }
                } catch (SQLException sqlEx) {
                    if (!MysqlErrorNumbers.SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND.equals(sqlEx.getSQLState())) {
                        throw sqlEx;
                    }
                } finally {
                    if (results != null) {
                        try {
                            results.close();
                        } catch (Exception ex) {
                        }
                        results = null;
                    }
                }
            }
        }.doForAll();
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
    java.sql.ResultSet results = this.resultSetFactory.createFromResultsetRows(ResultSet.CONCUR_READ_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, new ResultsetRowsStatic(rows, new DefaultColumnDefinition(fields)));
    return results;
}
Also used : MysqlType(com.mysql.cj.MysqlType) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) CJException(com.mysql.cj.exceptions.CJException) SQLException(java.sql.SQLException) AssertionFailedException(com.mysql.cj.exceptions.AssertionFailedException) Field(com.mysql.cj.result.Field) StringTokenizer(java.util.StringTokenizer) StringTokenizer(java.util.StringTokenizer) ResultSet(java.sql.ResultSet) DefaultColumnDefinition(com.mysql.cj.result.DefaultColumnDefinition) ResultsetRowsStatic(com.mysql.cj.protocol.a.result.ResultsetRowsStatic) ResultSet(java.sql.ResultSet) ResultsetRow(com.mysql.cj.protocol.ResultsetRow) ByteArrayRow(com.mysql.cj.protocol.a.result.ByteArrayRow) Row(com.mysql.cj.result.Row) ByteArrayRow(com.mysql.cj.protocol.a.result.ByteArrayRow)

Example 5 with MysqlType

use of com.mysql.cj.MysqlType in project JavaSegundasQuintas by ecteruel.

the class DatabaseMetaDataUsingInfoSchema method appendJdbcTypeMappingQuery.

private final void appendJdbcTypeMappingQuery(StringBuilder buf, String mysqlTypeColumnName, String fullMysqlTypeColumnName) {
    buf.append("CASE ");
    for (MysqlType mysqlType : MysqlType.values()) {
        buf.append(" WHEN UPPER(");
        buf.append(mysqlTypeColumnName);
        buf.append(")='");
        buf.append(mysqlType.getName());
        buf.append("' THEN ");
        switch(mysqlType) {
            case TINYINT:
            case TINYINT_UNSIGNED:
                if (this.tinyInt1isBit) {
                    buf.append("CASE");
                    buf.append(" WHEN LOCATE('ZEROFILL', UPPER(");
                    buf.append(fullMysqlTypeColumnName);
                    buf.append(")) = 0 AND LOCATE('UNSIGNED', UPPER(");
                    buf.append(fullMysqlTypeColumnName);
                    buf.append(")) = 0 AND LOCATE('(1)', ");
                    buf.append(fullMysqlTypeColumnName);
                    buf.append(") != 0 THEN ");
                    buf.append(this.transformedBitIsBoolean ? "16" : "-7");
                    buf.append(" ELSE -6 END ");
                } else {
                    buf.append(mysqlType.getJdbcType());
                }
                break;
            default:
                buf.append(mysqlType.getJdbcType());
        }
    }
    buf.append(" WHEN UPPER(DATA_TYPE)='POINT' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='LINESTRING' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='POLYGON' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='MULTIPOINT' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='MULTILINESTRING' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='MULTIPOLYGON' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='GEOMETRYCOLLECTION' THEN -2");
    buf.append(" WHEN UPPER(DATA_TYPE)='GEOMCOLLECTION' THEN -2");
    buf.append(" ELSE 1111");
    buf.append(" END ");
}
Also used : MysqlType(com.mysql.cj.MysqlType)

Aggregations

MysqlType (com.mysql.cj.MysqlType)12 Field (com.mysql.cj.result.Field)4 FeatureNotAvailableException (com.mysql.cj.exceptions.FeatureNotAvailableException)3 LazyString (com.mysql.cj.util.LazyString)2 AssertionFailedException (com.mysql.cj.exceptions.AssertionFailedException)1 CJException (com.mysql.cj.exceptions.CJException)1 WrongArgumentException (com.mysql.cj.exceptions.WrongArgumentException)1 ResultsetRow (com.mysql.cj.protocol.ResultsetRow)1 ByteArrayRow (com.mysql.cj.protocol.a.result.ByteArrayRow)1 ResultsetRowsStatic (com.mysql.cj.protocol.a.result.ResultsetRowsStatic)1 DefaultColumnDefinition (com.mysql.cj.result.DefaultColumnDefinition)1 Row (com.mysql.cj.result.Row)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BigDecimal (java.math.BigDecimal)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1