com.mysql.cj.WarningListener Java Examples

The following examples show how to use com.mysql.cj.WarningListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDBCMySQLProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
List<NativeImageProxyDefinitionBuildItem> registerProxies() {
    List<NativeImageProxyDefinitionBuildItem> proxies = new ArrayList<>();
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcConnection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(MysqlConnection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(Statement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(AutoCloseable.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcStatement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(Connection.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(ResultSet.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(JdbcPreparedStatement.class.getName(), JdbcStatement.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcPropertySet.class.getName(), PropertySet.class.getName(),
            Serializable.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(Resultset.class.getName(), ResultSetInternalMethods.class.getName()));
    proxies.add(new NativeImageProxyDefinitionBuildItem(LoadBalancedConnection.class.getName(),
            JdbcConnection.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(ReplicationConnection.class.getName(), JdbcConnection.class.getName()));
    proxies.add(
            new NativeImageProxyDefinitionBuildItem(ResultSetInternalMethods.class.getName(),
                    WarningListener.class.getName(), Resultset.class.getName()));
    return proxies;
}
 
Example #2
Source File: SqlDateValueFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SqlDateValueFactory(TimeZone tz, WarningListener warningListener) {
    this(tz);
    this.warningListener = warningListener;
}
 
Example #3
Source File: LocalTimeValueFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public LocalTimeValueFactory(WarningListener warningListener) {
    this();
    this.warningListener = warningListener;
}
 
Example #4
Source File: SqlTimeValueFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SqlTimeValueFactory(TimeZone tz, WarningListener warningListener) {
    this(tz);
    this.warningListener = warningListener;
}
 
Example #5
Source File: LocalDateValueFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public LocalDateValueFactory(WarningListener warningListener) {
    this();
    this.warningListener = warningListener;
}
 
Example #6
Source File: SqlDateValueFactory.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public SqlDateValueFactory(Calendar calendar, TimeZone tz, WarningListener warningListener) {
    this(calendar, tz);
    this.warningListener = warningListener;
}
 
Example #7
Source File: LocalTimeValueFactory.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public LocalTimeValueFactory(WarningListener warningListener) {
    this();
    this.warningListener = warningListener;
}
 
Example #8
Source File: SqlTimeValueFactory.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public SqlTimeValueFactory(Calendar calendar, TimeZone tz, WarningListener warningListener) {
    this(calendar, tz);
    this.warningListener = warningListener;
}
 
Example #9
Source File: LocalDateValueFactory.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public LocalDateValueFactory(WarningListener warningListener) {
    this();
    this.warningListener = warningListener;
}
 
Example #10
Source File: LocalTimeValueFactoryTest.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void testBasics() {
    LocalTimeValueFactory vf = new LocalTimeValueFactory(new WarningListener() {
        @Override
        public void warningEncountered(String warning) {
            assertEquals("Precision lost converting DATETIME/TIMESTAMP to java.time.LocalTime", warning);
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from DECIMAL to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromBigDecimal(new BigDecimal("2018"));
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from BIGINT to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromBigInteger(new BigInteger("2018"));
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from BIT to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromBit(new byte[] { 1 }, 0, 2);
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from VARCHAR/TEXT/BLOB to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromBytes(new byte[] { 1 }, 0, 2);
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from DATE to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromDate(2018, 1, 1);
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from DOUBLE to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromDouble(new Double(2018));
            return null;
        }
    });

    assertThrows(DataConversionException.class, "Unsupported conversion from LONG to java.time.LocalTime", new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            vf.createFromLong(22L);
            return null;
        }
    });

    assertNull(vf.createFromNull());

    assertThrows(DataReadException.class,
            "The value '-1:0:0' is an invalid TIME value. JDBC Time objects represent a wall-clock time and not a duration as MySQL treats them. If you are treating this type as a duration, consider retrieving this value as a string and dealing with it according to your requirements.",
            new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    vf.createFromTime(-1, 0, 0, 0);
                    return null;
                }
            });

    assertThrows(DataReadException.class,
            "The value '44:0:0' is an invalid TIME value. JDBC Time objects represent a wall-clock time and not a duration as MySQL treats them. If you are treating this type as a duration, consider retrieving this value as a string and dealing with it according to your requirements.",
            new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    vf.createFromTime(44, 0, 0, 0);
                    return null;
                }
            });

    assertEquals(LocalTime.of(1, 1, 1, 1), vf.createFromTimestamp(2018, 1, 1, 1, 1, 1, 1));

    assertEquals("java.time.LocalTime", vf.getTargetTypeName());

    LocalTimeValueFactory vf2 = new LocalTimeValueFactory();
    assertEquals(LocalTime.of(1, 1, 1, 1), vf2.createFromTimestamp(2018, 1, 1, 1, 1, 1, 1));
}