Java Code Examples for java.sql.Connection.nativeSQL()

The following are Jave code examples for showing how to use nativeSQL() of the java.sql.Connection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: the-vigilantes   File: EscapeProcessorRegressionTest.java   View Source Code Vote up 4 votes
/**
 * Tests fix for BUG#60598 - nativeSQL() truncates fractional seconds
 * 
 * @throws Exception
 */
public void testBug60598() throws Exception {

    String expected = versionMeetsMinimum(5, 6, 4) ? "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06.007' , '11:22:33.444'"
            : "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06' , '11:22:33'";

    Connection conn_nolegacy = null;
    Connection conn_legacy = null;
    Connection conn_legacy_tz = null;

    try {
        Properties props = new Properties();

        props.setProperty("serverTimezone", TimeZone.getDefault().getID() + "");
        props.setProperty("useLegacyDatetimeCode", "false");
        conn_nolegacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        conn_legacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        props.setProperty("useTimezone", "true");
        props.setProperty("useJDBCCompliantTimezoneShift", "true");
        conn_legacy_tz = getConnectionWithProps(props);

        String input = "SELECT {ts '2001-02-03 04:05:06' } , {ts '2001-02-03 04:05:06.007' } , {t '11:22:33.444' }";

        String output = conn_nolegacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy_tz.nativeSQL(input);
        assertEquals(expected, output);

    } finally {
        if (conn_nolegacy != null) {
            conn_nolegacy.close();
        }
        if (conn_legacy != null) {
            conn_legacy.close();
        }
        if (conn_legacy_tz != null) {
            conn_legacy_tz.close();
        }
    }

}
 
Example 2
Project: OpenVertretung   File: EscapeProcessorRegressionTest.java   View Source Code Vote up 4 votes
/**
 * Tests fix for BUG#60598 - nativeSQL() truncates fractional seconds
 * 
 * @throws Exception
 */
public void testBug60598() throws Exception {

    String expected = versionMeetsMinimum(5, 6, 4) ? "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06.007' , '11:22:33.444'"
            : "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06' , '11:22:33'";

    Connection conn_nolegacy = null;
    Connection conn_legacy = null;
    Connection conn_legacy_tz = null;

    try {
        Properties props = new Properties();

        props.setProperty("serverTimezone", TimeZone.getDefault().getID() + "");
        props.setProperty("useLegacyDatetimeCode", "false");
        conn_nolegacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        conn_legacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        props.setProperty("useTimezone", "true");
        props.setProperty("useJDBCCompliantTimezoneShift", "true");
        conn_legacy_tz = getConnectionWithProps(props);

        String input = "SELECT {ts '2001-02-03 04:05:06' } , {ts '2001-02-03 04:05:06.007' } , {t '11:22:33.444' }";

        String output = conn_nolegacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy_tz.nativeSQL(input);
        assertEquals(expected, output);

    } finally {
        if (conn_nolegacy != null) {
            conn_nolegacy.close();
        }
        if (conn_legacy != null) {
            conn_legacy.close();
        }
        if (conn_legacy_tz != null) {
            conn_legacy_tz.close();
        }
    }

}
 
Example 3
Project: ProyectoPacientes   File: EscapeProcessorRegressionTest.java   View Source Code Vote up 4 votes
/**
 * Tests fix for BUG#60598 - nativeSQL() truncates fractional seconds
 * 
 * @throws Exception
 */
public void testBug60598() throws Exception {

    String expected = versionMeetsMinimum(5, 6, 4) ? "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06.007' , '11:22:33.444'"
            : "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06' , '11:22:33'";

    Connection conn_nolegacy = null;
    Connection conn_legacy = null;
    Connection conn_legacy_tz = null;

    try {
        Properties props = new Properties();

        props.setProperty("serverTimezone", TimeZone.getDefault().getID() + "");
        props.setProperty("useLegacyDatetimeCode", "false");
        conn_nolegacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        conn_legacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        props.setProperty("useTimezone", "true");
        props.setProperty("useJDBCCompliantTimezoneShift", "true");
        conn_legacy_tz = getConnectionWithProps(props);

        String input = "SELECT {ts '2001-02-03 04:05:06' } , {ts '2001-02-03 04:05:06.007' } , {t '11:22:33.444' }";

        String output = conn_nolegacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy_tz.nativeSQL(input);
        assertEquals(expected, output);

    } finally {
        if (conn_nolegacy != null) {
            conn_nolegacy.close();
        }
        if (conn_legacy != null) {
            conn_legacy.close();
        }
        if (conn_legacy_tz != null) {
            conn_legacy_tz.close();
        }
    }

}
 
Example 4
Project: BibliotecaPS   File: EscapeProcessorRegressionTest.java   View Source Code Vote up 4 votes
/**
 * Tests fix for BUG#60598 - nativeSQL() truncates fractional seconds
 * 
 * @throws Exception
 */
public void testBug60598() throws Exception {

    String expected = versionMeetsMinimum(5, 6, 4) ? "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06.007' , '11:22:33.444'"
            : "SELECT '2001-02-03 04:05:06' , '2001-02-03 04:05:06' , '11:22:33'";

    Connection conn_nolegacy = null;
    Connection conn_legacy = null;
    Connection conn_legacy_tz = null;

    try {
        Properties props = new Properties();

        props.setProperty("serverTimezone", TimeZone.getDefault().getID() + "");
        props.setProperty("useLegacyDatetimeCode", "false");
        conn_nolegacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        conn_legacy = getConnectionWithProps(props);

        props.setProperty("useLegacyDatetimeCode", "true");
        props.setProperty("useTimezone", "true");
        props.setProperty("useJDBCCompliantTimezoneShift", "true");
        conn_legacy_tz = getConnectionWithProps(props);

        String input = "SELECT {ts '2001-02-03 04:05:06' } , {ts '2001-02-03 04:05:06.007' } , {t '11:22:33.444' }";

        String output = conn_nolegacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy.nativeSQL(input);
        assertEquals(expected, output);

        output = conn_legacy_tz.nativeSQL(input);
        assertEquals(expected, output);

    } finally {
        if (conn_nolegacy != null) {
            conn_nolegacy.close();
        }
        if (conn_legacy != null) {
            conn_legacy.close();
        }
        if (conn_legacy_tz != null) {
            conn_legacy_tz.close();
        }
    }

}