Java Code Examples for com.mysql.jdbc.Util#isJdbc4()
The following examples show how to use
com.mysql.jdbc.Util#isJdbc4() .
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: MetaDataRegressionTest.java From Komondor with GNU General Public License v3.0 | 6 votes |
public void testReservedWords() throws Exception { if (Util.isJdbc4()) { // there is a specific JCDB4 test for this return; } final String mysqlKeywords = "ACCESSIBLE,ANALYZE,ASENSITIVE,BEFORE,BIGINT,BINARY,BLOB,CALL,CHANGE,CONDITION,DATABASE,DATABASES,DAY_HOUR," + "DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DELAYED,DETERMINISTIC,DISTINCTROW,DIV,DUAL,EACH,ELSEIF,ENCLOSED,ESCAPED,EXIT,EXPLAIN,FLOAT4,FLOAT8," + "FORCE,FULLTEXT,GENERATED,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_SECOND,IF,IGNORE,INDEX,INFILE,INOUT,INT1,INT2,INT3,INT4,INT8," + "IO_AFTER_GTIDS,IO_BEFORE_GTIDS,ITERATE,KEYS,KILL,LEAVE,LIMIT,LINEAR,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK,LONG,LONGBLOB,LONGTEXT,LOOP," + "LOW_PRIORITY,MASTER_BIND,MASTER_SSL_VERIFY_SERVER_CERT,MAXVALUE,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MIDDLEINT,MINUTE_MICROSECOND,MINUTE_SECOND," + "MOD,MODIFIES,NO_WRITE_TO_BINLOG,OPTIMIZE,OPTIMIZER_COSTS,OPTIONALLY,OUT,OUTFILE,PARTITION,PURGE,RANGE,READS,READ_WRITE,REGEXP,RELEASE," + "RENAME,REPEAT,REPLACE,REQUIRE,RESIGNAL,RETURN,RLIKE,SCHEMAS,SECOND_MICROSECOND,SENSITIVE,SEPARATOR,SHOW,SIGNAL,SPATIAL,SPECIFIC," + "SQLEXCEPTION,SQLWARNING,SQL_BIG_RESULT,SQL_CALC_FOUND_ROWS,SQL_SMALL_RESULT,SSL,STARTING,STORED,STRAIGHT_JOIN,TERMINATED,TINYBLOB,TINYINT," + "TINYTEXT,TRIGGER,UNDO,UNLOCK,UNSIGNED,USE,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VARBINARY,VARCHARACTER,VIRTUAL,WHILE,XOR,YEAR_MONTH,ZEROFILL"; assertEquals("MySQL keywords don't match expected.", mysqlKeywords, this.conn.getMetaData().getSQLKeywords()); }
Example 2
Source File: MysqlPooledConnection.java From Komondor with GNU General Public License v3.0 | 5 votes |
protected static MysqlPooledConnection getInstance(com.mysql.jdbc.Connection connection) throws SQLException { if (!Util.isJdbc4()) { return new MysqlPooledConnection(connection); } return (MysqlPooledConnection) Util.handleNewInstance(JDBC_4_POOLED_CONNECTION_WRAPPER_CTOR, new Object[] { connection }, connection.getExceptionInterceptor()); }
Example 3
Source File: PreparedStatementWrapper.java From Komondor with GNU General Public License v3.0 | 5 votes |
protected static PreparedStatementWrapper getInstance(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) throws SQLException { if (!Util.isJdbc4()) { return new PreparedStatementWrapper(c, conn, toWrap); } return (PreparedStatementWrapper) Util.handleNewInstance(JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR, new Object[] { c, conn, toWrap }, conn.getExceptionInterceptor()); }
Example 4
Source File: MysqlUtils.java From clearpool with GNU General Public License v3.0 | 5 votes |
public static XAConnection mysqlXAConnection(Connection con) throws SQLException { ConnectionImpl mysqlConn = (ConnectionImpl) con; if (mysqlConn.getPinGlobalTxToPhysicalConnection()) { if (!Util.isJdbc4()) { return new SuspendableXAConnection(mysqlConn); } return new JDBC4SuspendableXAConnection(mysqlConn); } return new MysqlXAConnection(mysqlConn, false); }
Example 5
Source File: SuspendableXAConnection.java From Komondor with GNU General Public License v3.0 | 5 votes |
protected static SuspendableXAConnection getInstance(Connection mysqlConnection) throws SQLException { if (!Util.isJdbc4()) { return new SuspendableXAConnection(mysqlConnection); } return (SuspendableXAConnection) Util.handleNewInstance(JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlConnection }, mysqlConnection.getExceptionInterceptor()); }
Example 6
Source File: MetaDataRegressionTest.java From Komondor with GNU General Public License v3.0 | 5 votes |
/** * Tests fix for BUG#17248345 - GETFUNCTIONCOLUMNS() METHOD RETURNS COLUMNS OF PROCEDURE. (this happens when * functions and procedures have a common name) * * @throws Exception * if the test fails. */ public void testBug17248345() throws Exception { if (Util.isJdbc4()) { // there is a specific JCDB4 test for this return; } Connection testConn; // create one stored procedure and one function with same name createFunction("testBug17248345", "(funccol INT) RETURNS INT DETERMINISTIC RETURN 1"); createProcedure("testBug17248345", "(IN proccol INT) SELECT 1"); // test with standard connection (getProceduresReturnsFunctions=true & useInformationSchema=false) assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) this.conn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) this.conn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(this.conn); // test with property useInformationSchema=true (getProceduresReturnsFunctions=true) testConn = getConnectionWithProps("useInformationSchema=true"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); // test with property getProceduresReturnsFunctions=false (useInformationSchema=false) testConn = getConnectionWithProps("getProceduresReturnsFunctions=false"); assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); // test with property useInformationSchema=true & getProceduresReturnsFunctions=false testConn = getConnectionWithProps("useInformationSchema=true,getProceduresReturnsFunctions=false"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); }
Example 7
Source File: StatementRegressionTest.java From Komondor with GNU General Public License v3.0 | 5 votes |
/** * Tests fix for BUG#73163 - IndexOutOfBoundsException thrown preparing statement. * * This bug occurs only if running with Java6+. Duplicated in testsuite.regression.StatementRegressionTest.testBug73163(). * * @throws Exception * if the test fails. */ public void testBug73163() throws Exception { try { stmt = conn.prepareStatement("LOAD DATA INFILE ? INTO TABLE testBug73163"); } catch (SQLException e) { if (e.getCause() instanceof IndexOutOfBoundsException && Util.isJdbc4()) { fail("IOOBE thrown in Java6+ while preparing a LOAD DATA statement with placeholders."); } else { throw e; } } }
Example 8
Source File: ConnectionWrapper.java From Komondor with GNU General Public License v3.0 | 5 votes |
protected static ConnectionWrapper getInstance(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException { if (!Util.isJdbc4()) { return new ConnectionWrapper(mysqlPooledConnection, mysqlConnection, forXa); } return (ConnectionWrapper) Util.handleNewInstance(JDBC_4_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlPooledConnection, mysqlConnection, Boolean.valueOf(forXa) }, mysqlPooledConnection.getExceptionInterceptor()); }
Example 9
Source File: ConnectionWrapper.java From r-course with MIT License | 5 votes |
protected static ConnectionWrapper getInstance(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa) throws SQLException { if (!Util.isJdbc4()) { return new ConnectionWrapper(mysqlPooledConnection, mysqlConnection, forXa); } return (ConnectionWrapper) Util.handleNewInstance(JDBC_4_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlPooledConnection, mysqlConnection, Boolean.valueOf(forXa) }, mysqlPooledConnection.getExceptionInterceptor()); }
Example 10
Source File: ConnectionTest.java From r-course with MIT License | 5 votes |
/** * Checks if setting useCursorFetch to "true" automatically enables * server-side prepared statements. */ public void testCouplingOfCursorFetch() throws Exception { if (!versionMeetsMinimum(5, 0)) { return; } Connection fetchConn = null; try { Properties props = new Properties(); props.setProperty("useServerPrepStmts", "false"); // force the issue props.setProperty("useCursorFetch", "true"); fetchConn = getConnectionWithProps(props); String classname = "com.mysql.jdbc.ServerPreparedStatement"; if (Util.isJdbc42()) { classname = "com.mysql.jdbc.JDBC42ServerPreparedStatement"; } else if (Util.isJdbc4()) { classname = "com.mysql.jdbc.JDBC4ServerPreparedStatement"; } assertEquals(classname, fetchConn.prepareStatement("SELECT 1").getClass().getName()); } finally { if (fetchConn != null) { fetchConn.close(); } } }
Example 11
Source File: StatementWrapper.java From r-course with MIT License | 5 votes |
protected static StatementWrapper getInstance(ConnectionWrapper c, MysqlPooledConnection conn, Statement toWrap) throws SQLException { if (!Util.isJdbc4()) { return new StatementWrapper(c, conn, toWrap); } return (StatementWrapper) Util.handleNewInstance(JDBC_4_STATEMENT_WRAPPER_CTOR, new Object[] { c, conn, toWrap }, conn.getExceptionInterceptor()); }
Example 12
Source File: CallableStatementWrapper.java From r-course with MIT License | 5 votes |
protected static CallableStatementWrapper getInstance(ConnectionWrapper c, MysqlPooledConnection conn, CallableStatement toWrap) throws SQLException { if (!Util.isJdbc4()) { return new CallableStatementWrapper(c, conn, toWrap); } return (CallableStatementWrapper) Util.handleNewInstance(JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR, new Object[] { c, conn, toWrap }, conn.getExceptionInterceptor()); }
Example 13
Source File: PreparedStatementWrapper.java From r-course with MIT License | 5 votes |
protected static PreparedStatementWrapper getInstance(ConnectionWrapper c, MysqlPooledConnection conn, PreparedStatement toWrap) throws SQLException { if (!Util.isJdbc4()) { return new PreparedStatementWrapper(c, conn, toWrap); } return (PreparedStatementWrapper) Util.handleNewInstance(JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR, new Object[] { c, conn, toWrap }, conn.getExceptionInterceptor()); }
Example 14
Source File: MysqlXAConnection.java From r-course with MIT License | 5 votes |
protected static MysqlXAConnection getInstance(com.mysql.jdbc.Connection mysqlConnection, boolean logXaCommands) throws SQLException { if (!Util.isJdbc4()) { return new MysqlXAConnection(mysqlConnection, logXaCommands); } return (MysqlXAConnection) Util.handleNewInstance(JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlConnection, Boolean.valueOf(logXaCommands) }, mysqlConnection.getExceptionInterceptor()); }
Example 15
Source File: SuspendableXAConnection.java From r-course with MIT License | 5 votes |
protected static SuspendableXAConnection getInstance(Connection mysqlConnection) throws SQLException { if (!Util.isJdbc4()) { return new SuspendableXAConnection(mysqlConnection); } return (SuspendableXAConnection) Util.handleNewInstance(JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] { mysqlConnection }, mysqlConnection.getExceptionInterceptor()); }
Example 16
Source File: StatementWrapper.java From Komondor with GNU General Public License v3.0 | 5 votes |
protected static StatementWrapper getInstance(ConnectionWrapper c, MysqlPooledConnection conn, Statement toWrap) throws SQLException { if (!Util.isJdbc4()) { return new StatementWrapper(c, conn, toWrap); } return (StatementWrapper) Util.handleNewInstance(JDBC_4_STATEMENT_WRAPPER_CTOR, new Object[] { c, conn, toWrap }, conn.getExceptionInterceptor()); }
Example 17
Source File: MetaDataRegressionTest.java From r-course with MIT License | 5 votes |
/** * Tests fix for BUG#17248345 - GETFUNCTIONCOLUMNS() METHOD RETURNS COLUMNS OF PROCEDURE. (this happens when * functions and procedures have a common name) * * @throws Exception * if the test fails. */ public void testBug17248345() throws Exception { if (Util.isJdbc4()) { // there is a specific JCDB4 test for this return; } Connection testConn; // create one stored procedure and one function with same name createFunction("testBug17248345", "(funccol INT) RETURNS INT DETERMINISTIC RETURN 1"); createProcedure("testBug17248345", "(IN proccol INT) SELECT 1"); // test with standard connection (getProceduresReturnsFunctions=true & useInformationSchema=false) assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) this.conn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) this.conn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(this.conn); // test with property useInformationSchema=true (getProceduresReturnsFunctions=true) testConn = getConnectionWithProps("useInformationSchema=true"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); // test with property getProceduresReturnsFunctions=false (useInformationSchema=false) testConn = getConnectionWithProps("getProceduresReturnsFunctions=false"); assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); // test with property useInformationSchema=true & getProceduresReturnsFunctions=false testConn = getConnectionWithProps("useInformationSchema=true,getProceduresReturnsFunctions=false"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkMetaDataInfoForBug17248345(testConn); testConn.close(); }
Example 18
Source File: StatementRegressionTest.java From r-course with MIT License | 5 votes |
/** * Tests fix for BUG#73163 - IndexOutOfBoundsException thrown preparing statement. * * This bug occurs only if running with Java6+. Duplicated in testsuite.regression.StatementRegressionTest.testBug73163(). * * @throws Exception * if the test fails. */ public void testBug73163() throws Exception { try { stmt = conn.prepareStatement("LOAD DATA INFILE ? INTO TABLE testBug73163"); } catch (SQLException e) { if (e.getCause() instanceof IndexOutOfBoundsException && Util.isJdbc4()) { fail("IOOBE thrown in Java6+ while preparing a LOAD DATA statement with placeholders."); } else { throw e; } } }
Example 19
Source File: MetaDataRegressionTest.java From Komondor with GNU General Public License v3.0 | 4 votes |
/** * Tests fix for BUG#69298 - Different outcome from DatabaseMetaData.getFunctions() when using I__S. * * @throws Exception * if the test fails. */ public void testBug69298() throws Exception { if (Util.isJdbc4()) { return; } Connection testConn; createFunction("testBug69298_func", "(param_func INT) RETURNS INT COMMENT 'testBug69298_func comment' DETERMINISTIC RETURN 1"); createProcedure("testBug69298_proc", "(IN param_proc INT) COMMENT 'testBug69298_proc comment' SELECT 1"); // test with standard connection assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) this.conn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) this.conn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Std. Connection MetaData", this.conn); checkGetProcedureColumnsForBug69298("Std. Connection MetaData", this.conn); // test with property useInformationSchema=true testConn = getConnectionWithProps("useInformationSchema=true"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. useInfoSchema(1) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. useInfoSchema(1) MetaData", testConn); testConn.close(); // test with property getProceduresReturnsFunctions=false testConn = getConnectionWithProps("getProceduresReturnsFunctions=false"); assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. getProcRetFunc(0) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. getProcRetFunc(0) MetaData", testConn); testConn.close(); // test with property useInformationSchema=true & getProceduresReturnsFunctions=false testConn = getConnectionWithProps("useInformationSchema=true,getProceduresReturnsFunctions=false"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. useInfoSchema(1) + getProcRetFunc(0) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. useInfoSchema(1) + getProcRetFunc(0) MetaData", testConn); testConn.close(); }
Example 20
Source File: MetaDataRegressionTest.java From r-course with MIT License | 4 votes |
/** * Tests fix for BUG#69298 - Different outcome from DatabaseMetaData.getFunctions() when using I__S. * * @throws Exception * if the test fails. */ public void testBug69298() throws Exception { if (Util.isJdbc4()) { return; } Connection testConn; createFunction("testBug69298_func", "(param_func INT) RETURNS INT COMMENT 'testBug69298_func comment' DETERMINISTIC RETURN 1"); createProcedure("testBug69298_proc", "(IN param_proc INT) COMMENT 'testBug69298_proc comment' SELECT 1"); // test with standard connection assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) this.conn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) this.conn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Std. Connection MetaData", this.conn); checkGetProcedureColumnsForBug69298("Std. Connection MetaData", this.conn); // test with property useInformationSchema=true testConn = getConnectionWithProps("useInformationSchema=true"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertTrue("Property getProceduresReturnsFunctions should be true", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. useInfoSchema(1) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. useInfoSchema(1) MetaData", testConn); testConn.close(); // test with property getProceduresReturnsFunctions=false testConn = getConnectionWithProps("getProceduresReturnsFunctions=false"); assertFalse("Property useInformationSchema should be false", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. getProcRetFunc(0) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. getProcRetFunc(0) MetaData", testConn); testConn.close(); // test with property useInformationSchema=true & getProceduresReturnsFunctions=false testConn = getConnectionWithProps("useInformationSchema=true,getProceduresReturnsFunctions=false"); assertTrue("Property useInformationSchema should be true", ((ConnectionProperties) testConn).getUseInformationSchema()); assertFalse("Property getProceduresReturnsFunctions should be false", ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions()); checkGetProceduresForBug69298("Prop. useInfoSchema(1) + getProcRetFunc(0) MetaData", testConn); checkGetProcedureColumnsForBug69298("Prop. useInfoSchema(1) + getProcRetFunc(0) MetaData", testConn); testConn.close(); }