com.alibaba.druid.util.JdbcConstants Java Examples
The following examples show how to use
com.alibaba.druid.util.JdbcConstants.
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: ElasticSearchPreparedStatement.java From elasticsearch-sql with Apache License 2.0 | 6 votes |
public String getExecutableSql() { if (parametersSize < 1) { return sql; } List<Object> parameters = new ArrayList<>(parametersSize); JdbcParameter jdbcParam; for (int i = 0; i < parametersSize; ++i) { jdbcParam = this.parameters[i]; parameters.add(jdbcParam != null ? jdbcParam.getValue() : null); } try { SQLStatementParser parser = ESActionFactory.createSqlStatementParser(sql); List<SQLStatement> statementList = parser.parseStatementList(); return SQLUtils.toSQLString(statementList, JdbcConstants.MYSQL, parameters, sqlFormatOption); } catch (ClassCastException | ParserException ex) { LOG.warn("format error", ex); return sql; } }
Example #2
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #3
Source File: MycatStatementParser.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
@Override public SQLSelectStatement parseSelect() { MycatSelectParser selectParser = new MycatSelectParser(this.selectExprParser); return new SQLSelectStatement(selectParser.select(), JdbcConstants.MYSQL); }
Example #4
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #5
Source File: AutoCompensateDeleteHandler.java From txle with Apache License 2.0 | 5 votes |
public boolean prepareCompensationBeforeDeleting(PreparedStatement delegate, SQLStatement sqlStatement, String executeSql, String globalTxId, String localTxId, String server, Map<String, Object> standbyParams) throws SQLException { if (JdbcConstants.MYSQL.equals(sqlStatement.getDbType())) { return MySqlDeleteHandler.newInstance().prepareCompensationBeforeDeleting(delegate, sqlStatement, executeSql, globalTxId, localTxId, server, standbyParams); } return false; }
Example #6
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #7
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #8
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.ORACLE); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #9
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #10
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #11
Source File: DruidProperties.java From SpringBootBucket with MIT License | 5 votes |
public void config(DruidDataSource dataSource) { dataSource.setDbType(JdbcConstants.MYSQL); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setInitialSize(initialSize); // 定义初始连接数 dataSource.setMinIdle(minIdle); // 最小空闲 dataSource.setMaxActive(maxActive); // 定义最大连接数 dataSource.setMaxWait(maxWait); // 获取连接等待超时的时间 dataSource.setRemoveAbandoned(removeAbandoned); // 超过时间限制是否回收 dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout); // 超过时间限制多长 // 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // 配置一个连接在池中最小生存的时间,单位是毫秒 dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 用来检测连接是否有效的sql,要求是一个查询语句 dataSource.setValidationQuery(validationQuery); // 申请连接的时候检测 dataSource.setTestWhileIdle(testWhileIdle); // 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnBorrow(testOnBorrow); // 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 dataSource.setTestOnReturn(testOnReturn); // 打开PSCache,并且指定每个连接上PSCache的大小 dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); // 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: // 监控统计用的filter:stat // 日志用的filter:log4j // 防御SQL注入的filter:wall try { dataSource.setFilters(filters); } catch (SQLException e) { e.printStackTrace(); } }
Example #12
Source File: DriverLoader.java From es_data_export with Apache License 2.0 | 5 votes |
public static void setDriverClassName(String driver) { if (driver != null && driver.length() > 256) { throw new IllegalArgumentException("driverClassName length > 256."); } if (JdbcConstants.ORACLE_DRIVER2.equalsIgnoreCase(driver)) { driver = "oracle.jdbc.OracleDriver"; logger.warn("oracle.jdbc.driver.OracleDriver is deprecated.Having use oracle.jdbc.OracleDriver."); } driverClass = driver; }
Example #13
Source File: AutoCompensateUpdateHandler.java From txle with Apache License 2.0 | 5 votes |
public boolean prepareCompensationAfterUpdating(PreparedStatement delegate, SQLStatement sqlStatement, String executeSql, String globalTxId, String localTxId, String server, Map<String, Object> standbyParams) throws SQLException { if (JdbcConstants.MYSQL.equals(sqlStatement.getDbType())) { return MySqlUpdateHandler.newInstance().prepareCompensationAfterUpdating(delegate, sqlStatement, executeSql, globalTxId, localTxId, server, standbyParams); } return false; }
Example #14
Source File: AutoCompensateUpdateHandler.java From txle with Apache License 2.0 | 5 votes |
public boolean prepareCompensationBeforeUpdating(PreparedStatement delegate, SQLStatement sqlStatement, String executeSql, String globalTxId, String localTxId, String server, Map<String, Object> standbyParams) throws SQLException { if (JdbcConstants.MYSQL.equals(sqlStatement.getDbType())) { return MySqlUpdateHandler.newInstance().prepareCompensationBeforeUpdating(delegate, sqlStatement, executeSql, globalTxId, localTxId, server, standbyParams); } return false; }
Example #15
Source File: AutoCompensateInsertHandler.java From txle with Apache License 2.0 | 5 votes |
public boolean prepareCompensationAfterInserting(PreparedStatement delegate, SQLStatement sqlStatement, String executeSql, String globalTxId, String localTxId, String server, Map<String, Object> standbyParams) throws SQLException { if (JdbcConstants.MYSQL.equals(sqlStatement.getDbType())) { return MySqlInsertHandler.newInstance().prepareCompensationAfterInserting(delegate, sqlStatement, executeSql, globalTxId, localTxId, server, standbyParams); } return false; }
Example #16
Source File: SQLStatistic.java From fiery with Apache License 2.0 | 4 votes |
public void addSqlMap(String sqlStr, Long hour, Double costTime) { if (sqlStr == null || sqlStr.trim().length() == 0) { return; } //clean up the parameter of sql String sqlStrPure = SQLUtils.format(sqlStr, JdbcConstants.MYSQL); sqlStrPure = ParameterizedOutputVisitorUtils.parameterize(sqlStrPure, JdbcConstants.MYSQL); sqlStrPure = sqlStrPure.replaceAll("\\s+", " "); SimHash hash1; try { hash1 = new SimHash(sqlStrPure, 64); } catch (Exception e) { log.debug(e.getMessage()); return; } boolean issame = false; for (Map.Entry<SQLKey, Map<Long, SqlStatisticStruct>> entry : _sqlMap.entrySet()) { Integer similityThreadHold; if (sqlStrPure.length() < 100) { similityThreadHold = 8; } else if (sqlStrPure.length() < 500) { similityThreadHold = 5; } else { similityThreadHold = 3; } if (entry.getKey().getHash().hammingDistance(hash1) <= similityThreadHold) { addHourMap(entry.getValue(), entry.getKey().getSql(), hour, costTime); issame = true; break; } } if (!issame) { Map<Long, SqlStatisticStruct> hourMap = new HashMap<Long, SqlStatisticStruct>(); addHourMap(hourMap, sqlStr, hour, costTime); SQLKey sqlKey = new SQLKey(); sqlKey.setHash(hash1); sqlKey.setPureSql(sqlStrPure); sqlKey.setSql(sqlStr); _sqlMap.put(sqlKey, hourMap); } }
Example #17
Source File: DruidSelectParser.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
protected String getCurentDbType() { return JdbcConstants.MYSQL; }
Example #18
Source File: DruidSelectOracleParser.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
protected String getCurentDbType() { return JdbcConstants.ORACLE; }
Example #19
Source File: DruidSelectPostgresqlParser.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
protected String getCurentDbType() { return JdbcConstants.POSTGRESQL; }
Example #20
Source File: DruidSelectSqlServerParser.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
protected String getCurentDbType() { return JdbcConstants.SQL_SERVER; }
Example #21
Source File: DruidSelectDb2Parser.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
protected String getCurentDbType() { return JdbcConstants.DB2; }
Example #22
Source File: ElasticSqlExprParser.java From elasticsearch-sql with Apache License 2.0 | 4 votes |
public ElasticSqlExprParser(Lexer lexer){ super(lexer, JdbcConstants.MYSQL); this.aggregateFunctions = AGGREGATE_FUNCTIONS; this.aggregateFunctionHashCodes = AGGREGATE_FUNCTIONS_CODES; }