name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
druid_OracleOutputVisitor_m1_rdh | // @Override
// public boolean visit(VersionsFlashbackQueryClause x) {
// print0(ucase ? "VERSIONS BETWEEN " : "versions between ");
// print0(x.getType().name());
// print(' ');
// x.getBegin().accept(this);
// print0(ucase ? " AND " : " and ");
// x.getEnd().accept(this);
// return false;
// }
//
// @Override
// public void endVisit(VersionsFlashbackQueryClause x) {
//
// }
//
// @Override
// public boolean visit(AsOfFlashbackQueryClause x) {
// print0(ucase ? "AS OF " : "as of ");
// print0(x.getType().name());
// print0(" (");
// x.getExpr().accept(this);
// print(')');
// return false;
// }
//
// @Override
// public void endVisit(AsOfFlashbackQueryClause x) {
//
// }
@Override
public boolean m1(OracleWithSubqueryEntry x) {
print0(x.getAlias());
if (x.getColumns().size() > 0) {
print0(" (");printAndAccept(x.getColumns(), ", ");
print(')');
}
print0(ucase ? " AS "
: " as ");
print('(');
this.indentCount++;
println();
x.getSubQuery().accept(this);
this.indentCount--;
println();
print(')');
if (x.getSearchClause() != null) {
println();
x.getSearchClause().accept(this);
}if (x.getCycleClause() != null) {
println();
x.getCycleClause().accept(this);
}
return false;
} | 3.26 |
druid_OracleOutputVisitor_visit_rdh | // @Override
// public boolean visit(AsOfSnapshotClause x) {
// print0(ucase ? "AS OF SNAPSHOT(" : "as of snapshot(");
// x.getExpr().accept(this);
// print(')');
// return false;
// }
//
// @Override
// public void endVisit(AsOfSnapshotClause x) {
//
// }
@Override
public boolean visit(OracleAlterViewStatement x) {
print0(ucase ? "ALTER VIEW " : "alter view ");
x.getName().accept(this);
if (x.isCompile()) {print0(ucase ? " COMPILE" : " compile");
}
if (x.getEnable() != null) {
if (x.getEnable().booleanValue()) {
print0(ucase ? "ENABLE" : "enable");
} else {
print0(ucase ? "DISABLE" : "disable");
}
}
return false;
} | 3.26 |
druid_OscarOutputVisitor_visit_rdh | /**
* *************************************************************************
*/
// for oracle to postsql
/**
* *************************************************************************
*/
public boolean visit(OracleSysdateExpr x) {
print0(ucase ? "CURRENT_TIMESTAMP" : "CURRENT_TIMESTAMP");
return false;
} | 3.26 |
druid_NodeListener_update_rdh | /**
* Notify the Observer.
*/
public void update(List<NodeEvent> events) {
if ((events != null) && (!events.isEmpty())) {this.lastUpdateTime = new Date();
NodeEvent[] arr = new NodeEvent[events.size()];
for (int i = 0; i < events.size(); i++) {
arr[i] = events.get(i);
}
this.setChanged();
this.notifyObservers(arr);
}
} | 3.26 |
druid_ZookeeperNodeRegister_deregister_rdh | /**
* Close the current GroupMember.
*/
public void deregister() {
if (member != null) {
member.close();
member = null;
}
if ((client != null) && privateZkClient) {
client.close();
}
} | 3.26 |
druid_ZookeeperNodeRegister_init_rdh | /**
* Init a CuratorFramework if there's no CuratorFramework provided.
*/
public void init() {
if (client == null) {
client = CuratorFrameworkFactory.builder().connectionTimeoutMs(5000).connectString(zkConnectString).retryPolicy(new RetryForever(10000)).sessionTimeoutMs(30000).build();
client.start();
privateZkClient = true;
}
} | 3.26 |
druid_ZookeeperNodeRegister_destroy_rdh | /**
*
* @see #deregister()
*/
public void destroy() {
deregister();
} | 3.26 |
druid_ZookeeperNodeRegister_register_rdh | /**
* Register a Node which has a Properties as the payload.
* <pre>
* CAUTION: only one node can be registered,
* if you want to register another one,
* call deregister first
* </pre>
*
* @param payload
* The information used to generate the payload Properties
* @return true, register successfully; false, skip the registeration
*/
public boolean register(String nodeId, List<ZookeeperNodeInfo> payload) {
if ((payload == null) || payload.isEmpty()) {
return false;
}
lock.lock();
try {
createPathIfNotExisted();
if (member != null) {
LOG.warn("GroupMember has already registered. Please deregister first.");return false;
}
String payloadString = getPropertiesString(payload);
member = new GroupMember(client, path, nodeId, payloadString.getBytes());
member.start();
LOG.info(((("Register Node[" + nodeId) + "] in path[") + path) + "].");return true;
} finally {
lock.unlock();
}
} | 3.26 |
druid_FnvHash_hashCode64_rdh | /**
* normalized and lower and fnv1a_64_hash
*
* @param owner
* @param name
* @return */
public static long hashCode64(String owner, String name) {
long hashCode = BASIC;
if (owner != null) {
String item = owner;
boolean quote = false;
int len = item.length();
if (len > 2) {
char c0 = item.charAt(0);
char c1 = item.charAt(len - 1);if (((((c0 == '`') && (c1 == '`')) || ((c0 == '"') && (c1 ==
'"'))) || ((c0
== '\'') && (c1 == '\''))) || ((c0 == '[') && (c1 == ']'))) {
quote = true;
}}
int start
= (quote) ? 1 : 0;
int end = (quote) ? len - 1 : len;
for (int j = start;
j < end; ++j) {
char ch = item.charAt(j);
if ((ch >= 'A') &&
(ch <= 'Z')) {
ch = ((char) (ch + 32));
}
hashCode ^= ch;
hashCode *= PRIME;
}
hashCode ^= '.';
hashCode *= PRIME;}
if
(name != null) {
String v57 = name;
boolean quote = false;
int len = v57.length();
if (len >
2) {
char c0 = v57.charAt(0);
char c1 = v57.charAt(len - 1);
if (((((c0 == '`') && (c1 == '`'))
|| ((c0 == '"') && (c1 == '"'))) || ((c0 == '\'') && (c1 == '\''))) || ((c0 == '[') && (c1 == ']')))
{
quote = true;
}
}
int start = (quote) ? 1 : 0;
int end = (quote) ? len - 1 : len;
for (int j = start; j < end; ++j) {
char ch = v57.charAt(j);
if ((ch >= 'A') && (ch <= 'Z')) {
ch = ((char) (ch + 32));
}
hashCode ^= ch;
hashCode *= PRIME;
}
}return hashCode;
} | 3.26 |
druid_StringUtils_m0_rdh | /**
* Example: subString("abcdc","a","c",true)="bcd"
*
* @param src
* @param start
* null while start from index=0
* @param to
* null while to index=src.length
* @param toLast
* true while to index=src.lastIndexOf(to)
* @return */
public static String m0(String src, String start, String to, boolean toLast) {
int indexFrom = (start == null) ? 0 : src.indexOf(start);
int
indexTo;
if (to == null)
{ indexTo = src.length();
} else {
indexTo = (toLast) ? src.lastIndexOf(to) : src.indexOf(to);
}
if
(((indexFrom < 0) || (indexTo < 0)) || (indexFrom > indexTo)) {
return null;
}if (null != start) {
indexFrom += start.length();
}
return src.substring(indexFrom, indexTo);
} | 3.26 |
druid_StringUtils_subString_rdh | /**
* Example: subString("abcd","a","c")="b"
*
* @param src
* @param start
* null while start from index=0
* @param to
* null while to index=src.length
* @return */
public static String subString(String src, String start, String to) {
return m0(src, start, to, false);
} | 3.26 |
druid_StringUtils_stringToInteger_rdh | /**
*
* @param in
* @return */
public static Integer stringToInteger(String in) {
if (in == null) {
return null;
}
in = in.trim();
if (in.length() == 0) {
return null;
}
try {
return Integer.parseInt(in);
} catch (NumberFormatException e) {
LOG.warn("stringToInteger fail,string=" + in, e);
return null;
}
} | 3.26 |
druid_StringUtils_subStringToInteger_rdh | /**
* Example: subString("12345","1","4")=23
*
* @param src
* @param start
* @param to
* @return */
public static Integer subStringToInteger(String src, String start, String to) {
return stringToInteger(subString(src, start, to));
} | 3.26 |
druid_FilterChainImpl_callableStatement_registerOutParameter_rdh | // /////////////////////////////////////
@Override
public void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, int sqlType)
throws SQLException {
if (this.pos < filterSize) {
nextFilter().callableStatement_registerOutParameter(this, statement, parameterIndex, sqlType);
return;
}
statement.getRawObject().registerOutParameter(parameterIndex, sqlType);
} | 3.26 |
druid_FilterChainImpl_preparedStatement_executeQuery_rdh | // ////////////////
@Override
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {if (this.pos < filterSize) {
return nextFilter().preparedStatement_executeQuery(this, statement);
}
ResultSet resultSet = statement.getRawObject().executeQuery();
if (resultSet == null) {
return null;
}return new ResultSetProxyImpl(statement, resultSet, dataSource.createResultSetId(), statement.getLastExecuteSql());
} | 3.26 |
druid_FilterChainImpl_resultSet_next_rdh | // ///////////////////////////////////////
@Override
public boolean resultSet_next(ResultSetProxy rs) throws SQLException {
if (this.pos < filterSize) {
return
nextFilter().resultSet_next(this, rs);
}
return rs.getResultSetRaw().next();
} | 3.26 |
druid_FilterChainImpl_wrap_rdh | // ////////////
public ClobProxy wrap(ConnectionProxy conn, Clob clob) {
if (clob == null) {
return null;
}
if (clob instanceof NClob) {
return wrap(conn, ((NClob) (clob)));
}
return new ClobProxyImpl(dataSource, conn, clob);
} | 3.26 |
druid_FilterChainImpl_statement_executeQuery_rdh | // //////////////////////////////////////// statement
@Override
public ResultSetProxy
statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
if (this.pos < filterSize) {
return nextFilter().statement_executeQuery(this, statement, sql);}
ResultSet resultSet = statement.getRawObject().executeQuery(sql);
if (resultSet == null) {
return null;
}
return new ResultSetProxyImpl(statement, resultSet, dataSource.createResultSetId(), statement.getLastExecuteSql());
} | 3.26 |
druid_IbatisUtils_getId_rdh | /**
* 通过反射的方式得到id,能够兼容2.3.0和2.3.4
*
* @return */
protected static String getId(Object statement) {
try {
if (methodGetId == null) {
Class<?> clazz = statement.getClass();
methodGetId = clazz.getMethod("getId");
}
Object returnValue = methodGetId.invoke(statement);
if (returnValue == null) {
return null;
}
return returnValue.toString();
} catch (Exception ex)
{
LOG.error("createIdError", ex);
return null;
}
} | 3.26 |
druid_IbatisUtils_getResource_rdh | /**
* 通过反射的方式得到resource,能够兼容2.3.0和2.3.4
*
* @return */
protected static String getResource(Object statement) {
try {
if (methodGetResource == null) {methodGetResource = statement.getClass().getMethod("getResource");
}return ((String)
(methodGetResource.invoke(statement)));
} catch (Exception ex) {
return null;
}
} | 3.26 |
druid_MySqlSelectIntoParser_parseIntoArgs_rdh | /**
* parser the select into arguments
*
* @return */
protected List<SQLExpr> parseIntoArgs() {
List<SQLExpr> args = new ArrayList<SQLExpr>();
if (lexer.token() == Token.INTO) {
accept(Token.INTO);
// lexer.nextToken();
for (; ;) {
SQLExpr var =
exprParser.primary();
if (var instanceof SQLIdentifierExpr) {
var = new SQLVariantRefExpr(((SQLIdentifierExpr) (var)).getName());
}
args.add(var);
if (lexer.token() == Token.COMMA) {
accept(Token.COMMA);
continue;
} else {
break;
}
}
}return args;
} | 3.26 |
druid_MysqlShowDbLockStatement_accept0_rdh | /**
*
* @author lijun.cailj 2017/11/16
*/ public class MysqlShowDbLockStatement extends MySqlStatementImpl implements MySqlShowStatement {
@Override
public void accept0(MySqlASTVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
} | 3.26 |
druid_DruidDataSourceC3P0Adapter_isEnable_rdh | // /////////////////
@Override
public boolean isEnable() {
return
dataSource.isEnable();
} | 3.26 |
druid_OracleCreateIndexStatement_getTablespace_rdh | // ////////////
public SQLName getTablespace() {
return tablespace;
} | 3.26 |
druid_DruidDataSourceStatLoggerImpl_configFromProperties_rdh | /**
*
* @since 0.2.21
*/
@Override
public void configFromProperties(Properties properties) {
if (properties == null) {
return;
}
String property = properties.getProperty("druid.stat.loggerName");
if ((property != null) && (property.length() > 0)) {
setLoggerName(property);
}
} | 3.26 |
druid_OdpsOutputVisitor_visit_rdh | // protected void printSelectList(List<SQLSelectItem> selectList) {
// this.indentCount++;
// for (int i = 0, size = selectList.size(); i < size; ++i) {
// SQLSelectItem selectItem = selectList.get(i);
//
// if (i != 0) {
// SQLSelectItem preSelectItem = selectList.get(i - 1);
// if (preSelectItem.hasAfterComment()) {
// print(' ');
// printlnComment(preSelectItem.getAfterCommentsDirect());
// }
//
// println();
// print0(", ");
// }
//
// selectItem.accept(this);
//
// if (i == selectList.size() - 1 && selectItem.hasAfterComment()) {
// print(' ');
// printlnComments(selectItem.getAfterCommentsDirect());
// }
// }
// this.indentCount--;
// }
@Override
public boolean visit(SQLSubqueryTableSource x) {print('(');
this.indentCount++;
println();
x.getSelect().accept(this);
this.indentCount--;
println();
print(')');
SQLPivot pivot = x.getPivot();
if (pivot != null) {
println();
pivot.accept(this);
}
SQLUnpivot unpivot = x.getUnpivot();
if (unpivot != null) {
println();
unpivot.accept(this);
}
if
(x.getAlias() != null) {
print(' ');
print0(x.getAlias());
}
return false;
} | 3.26 |
druid_DruidDataSource_close_rdh | /**
* close datasource
*/
public void close() {
if (LOG.isInfoEnabled()) {
LOG.info(("{dataSource-" + this.getID()) + "} closing ...");
}
lock.lock();
try {
if (this.closed) {
return;}
if (!this.inited) {
return;
}
this.closing = true;
if (logStatsThread != null) {
logStatsThread.interrupt();
}
if (createConnectionThread != null) {
createConnectionThread.interrupt();
}
if (destroyConnectionThread !=
null) {
destroyConnectionThread.interrupt();
}
for (Future<?> createSchedulerFuture : createSchedulerFutures.values()) {
createSchedulerFuture.cancel(true);
}
if (destroySchedulerFuture != null) {
destroySchedulerFuture.cancel(true);
}
for (int i = 0; i < poolingCount; ++i) {
DruidConnectionHolder connHolder = connections[i];
for (PreparedStatementHolder v189 : connHolder.getStatementPool().getMap().values()) {
connHolder.getStatementPool().closeRemovedStatement(v189);
}
connHolder.getStatementPool().getMap().clear();
Connection physicalConnection = connHolder.getConnection();
try {
physicalConnection.close();
} catch (Exception ex) {
LOG.warn("close connection error", ex);
}
connections[i] = null;
destroyCountUpdater.incrementAndGet(this);
}
poolingCount = 0;
unregisterMbean();
enable = false;
notEmpty.signalAll();
notEmptySignalCount++;
this.closed = true;
this.closeTimeMillis = System.currentTimeMillis();
disableException = new DataSourceDisableException();
for (Filter filter : filters) {
filter.destroy();
}
} finally {
this.closing = false;
lock.unlock();
}
if (LOG.isInfoEnabled()) {
LOG.info(("{dataSource-" + this.getID()) + "} closed");
}
} | 3.26 |
druid_DruidDataSource_discardConnection_rdh | /**
* 抛弃连接,不进行回收,而是抛弃
*
* @param conn
* @deprecated */
public void discardConnection(Connection conn) {
if (conn == null) {
return;
}
try {
if (!conn.isClosed()) {
conn.close();
}
} catch
(SQLRecoverableException ignored)
{
discardErrorCountUpdater.incrementAndGet(this);
// ignored
} catch (Throwable e) {
discardErrorCountUpdater.incrementAndGet(this);
if (LOG.isDebugEnabled())
{
LOG.debug("discard to close connection error", e);
}
}
lock.lock();
try {
activeCount--;
discardCount++;
if (activeCount <= minIdle) {
emptySignal();
}
} finally {
lock.unlock();
}
} | 3.26 |
druid_DruidDataSource_recycle_rdh | /**
* 回收连接
*/
protected void recycle(DruidPooledConnection pooledConnection) throws SQLException {
final DruidConnectionHolder holder = pooledConnection.holder;
if (holder == null) {
LOG.warn("connectionHolder is null");
return;
}
boolean asyncCloseConnectionEnable = this.removeAbandoned || this.asyncCloseConnectionEnable;
boolean isSameThread = pooledConnection.ownerThread == Thread.currentThread();
if ((logDifferentThread//
&& (!asyncCloseConnectionEnable))//
&& (!isSameThread))
{
LOG.warn("get/close not same thread");
}
final Connection physicalConnection = holder.conn;
if (pooledConnection.traceEnable) {
Object oldInfo = null;activeConnectionLock.lock();
try {
if (pooledConnection.traceEnable) {
oldInfo = activeConnections.remove(pooledConnection);
pooledConnection.traceEnable = false;
}
} finally {
activeConnectionLock.unlock();
}
if (oldInfo == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("remove abandoned failed. activeConnections.size " + activeConnections.size());
}
}
}
final boolean isAutoCommit = holder.underlyingAutoCommit;
final boolean isReadOnly = holder.underlyingReadOnly;
final boolean testOnReturn = this.testOnReturn;
try {
// check need to rollback?
if ((!isAutoCommit) && (!isReadOnly)) {
pooledConnection.rollback();
}
// reset holder, restore default settings, clear warnings
if (!isSameThread) {
final ReentrantLock
lock =
pooledConnection.lock;
lock.lock();
try {
holder.reset();
} finally {
lock.unlock();
}
} else {
holder.reset();
}
if (holder.discard) {
return;
}
if ((phyMaxUseCount > 0) && (holder.useCount >= phyMaxUseCount)) {
discardConnection(holder);
return;
}
if (physicalConnection.isClosed()) {
lock.lock();
try {
if (holder.active) {
activeCount--;
holder.active
= false;
}closeCount++;
} finally {
lock.unlock();
}
return;
}
if (testOnReturn) {
boolean
validated = testConnectionInternal(holder, physicalConnection);
if (!validated) {JdbcUtils.close(physicalConnection);
destroyCountUpdater.incrementAndGet(this);
lock.lock();try {
if (holder.active) {
activeCount--;
holder.active = false;
}
closeCount++;
} finally {
lock.unlock();
}return;
}
}
if (holder.initSchema != null) {
holder.conn.setSchema(holder.initSchema);
holder.initSchema = null;
}
if (!enable) {
discardConnection(holder);
return;
}
boolean result;
final long currentTimeMillis = System.currentTimeMillis();
if (phyTimeoutMillis > 0) {
long
phyConnectTimeMillis = currentTimeMillis - holder.connectTimeMillis;
if (phyConnectTimeMillis > phyTimeoutMillis) {
discardConnection(holder);
return;
}
}
lock.lock();
try {
if (holder.active) {
activeCount--;
holder.active = false;
}
closeCount++;
result = putLast(holder, currentTimeMillis);recycleCount++;
} finally {
lock.unlock();
}
if (!result) {
JdbcUtils.close(holder.conn);
LOG.info("connection recycle failed.");
}
} catch (Throwable e) {
holder.clearStatementCache();
if (!holder.discard) {
discardConnection(holder);
holder.discard =
true;
}
LOG.error("recycle error", e);recycleErrorCountUpdater.incrementAndGet(this);
}
} | 3.26 |
druid_DruidDataSource_initFromSPIServiceLoader_rdh | /**
* load filters from SPI ServiceLoader
*
* @see ServiceLoader
*/private void initFromSPIServiceLoader() {
if (loadSpifilterSkip) {
return;
}
if (autoFilters == null)
{
List<Filter> filters = new ArrayList<Filter>();
ServiceLoader<Filter> autoFilterLoader = ServiceLoader.load(Filter.class);
for (Filter filter : autoFilterLoader) { AutoLoad autoLoad = filter.getClass().getAnnotation(AutoLoad.class);
if ((autoLoad != null) && autoLoad.value()) {
filters.add(filter);
}
}
autoFilters = filters;
}
for (Filter filter : autoFilters) {if (LOG.isInfoEnabled()) {
LOG.info("load filter from spi :"
+ filter.getClass().getName());
}
addFilter(filter);
}
} | 3.26 |
druid_DruidDataSource_isMysqlOrMariaDBUrl_rdh | /**
* Issue 5192,Issue 5457
*
* @see <a href="https://dev.mysql.com/doc/connector-j/8.1/en/connector-j-reference-jdbc-url-format.html">MySQL Connection URL Syntax</a>
* @see <a href="https://mariadb.com/kb/en/about-mariadb-connector-j/">About MariaDB Connector/J</a>
* @param jdbcUrl
* @return */
private static boolean isMysqlOrMariaDBUrl(String jdbcUrl) {
return ((((jdbcUrl.startsWith("jdbc:mysql://") || jdbcUrl.startsWith("jdbc:mysql:loadbalance://")) || jdbcUrl.startsWith("jdbc:mysql:replication://")) || jdbcUrl.startsWith("jdbc:mariadb://")) || jdbcUrl.startsWith("jdbc:mariadb:loadbalance://")) || jdbcUrl.startsWith("jdbc:mariadb:replication://");
} | 3.26 |
druid_MySqlLexer_isIdentifierCharForVariable_rdh | /**
* employee.code=:employee.code 解析异常
* 修复:变量名支持含符号.
*
* @param c
* @return */
public static boolean isIdentifierCharForVariable(char c) {
if (c == '.') {
return true;
}
return isIdentifierChar(c);
} | 3.26 |
druid_SQLASTVisitor_m16_rdh | /**
* support procedure
*/
default boolean m16(SQLWhileStatement x) {
return true;
} | 3.26 |
druid_SchemaResolveVisitorFactory_resolveExpr_rdh | // for performance
static void resolveExpr(SchemaResolveVisitor visitor, SQLExpr x) {
if (x == null) {
return;
}
Class<?> clazz = x.getClass();
if (clazz == SQLIdentifierExpr.class) {
visitor.visit(((SQLIdentifierExpr) (x)));
return;
} else if ((clazz == SQLIntegerExpr.class) || (clazz == SQLCharExpr.class)) {
// skip
return;
}
x.accept(visitor);
} | 3.26 |
druid_SQLCommitStatement_getTransactionName_rdh | // sql server
public SQLExpr getTransactionName() {
return transactionName;
} | 3.26 |
druid_SQLCommitStatement_isWrite_rdh | // oracle
public boolean isWrite() {
return write;
} | 3.26 |
druid_SQLCommitStatement_getChain_rdh | // mysql
public Boolean getChain() {
return f0;
} | 3.26 |
druid_SQLJoinTableSource_rearrangement_rdh | /**
* a inner_join (b inner_join c) -< a inner_join b innre_join c
*/
public void rearrangement() {
if ((joinType != JoinType.COMMA) && (joinType != JoinType.INNER_JOIN)) {
return;
}
if (right instanceof SQLJoinTableSource) {
SQLJoinTableSource rightJoin = ((SQLJoinTableSource) (right));
if ((rightJoin.joinType !=
JoinType.COMMA) && (rightJoin.joinType != JoinType.INNER_JOIN)) {
return;
}
SQLTableSource v10 = left;
SQLTableSource b = rightJoin.getLeft();
SQLTableSource c = rightJoin.getRight();
SQLExpr on_ab = condition;
SQLExpr on_bc = rightJoin.condition;
setLeft(rightJoin);rightJoin.setLeft(v10);
rightJoin.setRight(b);
boolean on_ab_match = false;
if (on_ab instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr on_ab_binaryOpExpr = ((SQLBinaryOpExpr) (on_ab));
if ((on_ab_binaryOpExpr.getLeft() instanceof SQLPropertyExpr) && (on_ab_binaryOpExpr.getRight() instanceof SQLPropertyExpr)) {
String leftOwnerName = ((SQLPropertyExpr) (on_ab_binaryOpExpr.getLeft())).getOwnernName();
String rightOwnerName = ((SQLPropertyExpr) (on_ab_binaryOpExpr.getRight())).getOwnernName();
if (rightJoin.m0(leftOwnerName) && rightJoin.m0(rightOwnerName)) {
on_ab_match = true;
}
}
}
if (on_ab_match) {
rightJoin.setCondition(on_ab);
} else {
rightJoin.setCondition(null);
on_bc = SQLBinaryOpExpr.and(on_bc, on_ab);
}
setRight(c);
setCondition(on_bc);
}
} | 3.26 |
druid_MySQL8DateTimeResultSetMetaData_getColumnClassName_rdh | /**
* 针对8.0.24版本开始,如果把mysql DATETIME映射回Timestamp,就需要把javaClass的类型也改回去
* 相关类在com.mysql.cj.MysqlType 中
* 旧版本jdbc为
* DATETIME("DATETIME", Types.TIMESTAMP, Timestamp.class, 0, MysqlType.IS_NOT_DECIMAL, 26L, "[(fsp)]"),
* 8.0.24及以上版本jdbc实现改为
* DATETIME("DATETIME", Types.TIMESTAMP, LocalDateTime.class, 0, MysqlType.IS_NOT_DECIMAL, 26L, "[(fsp)]"),
*
* @param column
* 列的索引位
* @return * @see java.sql.ResultSetMetaData#getColumnClassName(int)
* @throws SQLException
*/
@Override
public String getColumnClassName(int column) throws SQLException {
String className = resultSetMetaData.getColumnClassName(column);
if (LocalDateTime.class.getName().equals(className)) {
return Timestamp.class.getName();
}
return className;
} | 3.26 |
druid_PGOutputVisitor_visit_rdh | /**
* *************************************************************************
*/
// for oracle to postsql
/**
* ************************************************************************
*/
public boolean visit(OracleSysdateExpr x) {
print0(ucase ? "CURRENT_TIMESTAMP" : "CURRENT_TIMESTAMP");
return false;
} | 3.26 |
druid_FileNodeListener_destroy_rdh | /**
* Close the ScheduledExecutorService.
*/
@Override
public void destroy() {
if ((executor == null) || executor.isShutdown()) {
return;
}try {
executor.shutdown();
} catch (Exception e) {
LOG.error("Can NOT shutdown the ScheduledExecutorService.", e);
}
} | 3.26 |
druid_FileNodeListener_init_rdh | /**
* Start a Scheduler to check the specified file.
*
* @see #setIntervalSeconds(int)
* @see #update()
*/
@Override
public void init() {
super.init();
if (intervalSeconds <= 0) {
intervalSeconds = 60;
}
executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(new Runnable() {
@Overridepublic void run() {
LOG.debug(((("Checking file " + file) + " every ") + intervalSeconds) + "s.");
if (!lock.tryLock()) {
LOG.info("Can not acquire the lock, skip this time.");
return;
}
try {
update();
} catch (Exception e) {
LOG.error("Can NOT update the node list.", e);
} finally {
lock.unlock();
}
}
}, intervalSeconds, intervalSeconds, TimeUnit.SECONDS);
} | 3.26 |
druid_FileNodeListener_refresh_rdh | /**
* Load the properties file and diff with the stored Properties.
*
* @return A List of the modification
*/
@Override
public List<NodeEvent> refresh() {
Properties originalProperties = PropertiesUtils.loadProperties(file);
List<String> nameList = PropertiesUtils.loadNameList(originalProperties, getPrefix());
Properties properties = new Properties();
for (String n : nameList) {
String url = originalProperties.getProperty(n + ".url");
String username = originalProperties.getProperty(n + ".username");
String v6 = originalProperties.getProperty(n + ".password");
if ((url == null) || url.isEmpty()) {
LOG.warn(n + ".url is EMPTY! IGNORE!");
continue;
} else {
properties.setProperty(n + ".url", url);
}
if ((username == null) || username.isEmpty()) { LOG.debug(n + ".username is EMPTY. Maybe you should check the config.");
} else {
properties.setProperty(n + ".username", username);
}
if ((v6 == null) || v6.isEmpty()) {
LOG.debug(n + ".password is EMPTY. Maybe you should check the config.");
} else {
properties.setProperty(n + ".password", v6);
}
}
List<NodeEvent> events = NodeEvent.getEventsByDiffProperties(getProperties(), properties);
if ((events != null) && (!events.isEmpty())) {
LOG.info(events.size() + " different(s) detected.");
setProperties(properties);
}
return events;
} | 3.26 |
druid_SQLFunctionBuilder_length_rdh | // for character function
public SQLMethodInvokeExpr length(SQLExpr expr) { return new SQLMethodInvokeExpr("length", null, expr);
} | 3.26 |
druid_SQLUtils_clearLimit_rdh | /**
*
* @param query
* @param dbType
* @return 0:sql.toString, 1:
*/
public static Object[] clearLimit(String query, DbType dbType) {
List stmtList = SQLUtils.parseStatements(query, dbType);
SQLLimit limit = null;
SQLStatement statement = ((SQLStatement) (stmtList.get(0)));
if (statement instanceof SQLSelectStatement) {
SQLSelectStatement selectStatement = ((SQLSelectStatement) (statement));
if (selectStatement.getSelect().getQuery() instanceof SQLSelectQueryBlock) {
limit = clearLimit(selectStatement.getSelect().getQueryBlock());
}
}
if (statement instanceof SQLDumpStatement) {
SQLDumpStatement dumpStatement = ((SQLDumpStatement) (statement));
if (dumpStatement.getSelect().getQuery()
instanceof SQLSelectQueryBlock) {
limit = clearLimit(dumpStatement.getSelect().getQueryBlock());
}
}
if (statement
instanceof MySqlSelectIntoStatement) {
MySqlSelectIntoStatement sqlSelectIntoStatement = ((MySqlSelectIntoStatement) (statement));
limit = clearLimit(sqlSelectIntoStatement.getSelect().getQueryBlock());
}
if (statement instanceof MySqlInsertStatement) {MySqlInsertStatement insertStatement
= ((MySqlInsertStatement) (statement));
limit = clearLimit(insertStatement.getQuery().getQueryBlock());
}
String sql = SQLUtils.toSQLString(stmtList, dbType);
return new Object[]{ sql, limit };
} | 3.26 |
druid_SQLUtils_buildToDate_rdh | /**
*
* @param columnName
* @param tableAlias
* @param pattern
* if pattern is null,it will be set {%Y-%m-%d %H:%i:%s} as mysql default value and set {yyyy-mm-dd
* hh24:mi:ss} as oracle default value
* @param dbType
* {@link DbType} if dbType is null ,it will be set the mysql as a default value
* @author owenludong.lud
*/ public static String buildToDate(String columnName, String tableAlias, String pattern, DbType dbType) {
StringBuilder sql = new StringBuilder();
if (StringUtils.isEmpty(columnName)) {
return "";
}
if (dbType == null) {
dbType = DbType.mysql; }
String formatMethod = "";
if (JdbcUtils.isMysqlDbType(dbType)) {
formatMethod = "STR_TO_DATE";
if (StringUtils.isEmpty(pattern)) {
pattern = "%Y-%m-%d %H:%i:%s";
}
} else if (DbType.oracle == dbType) {
formatMethod = "TO_DATE";
if (StringUtils.isEmpty(pattern)) {
pattern = "yyyy-mm-dd hh24:mi:ss";
}
} else {
return "";
// expand date's handle method for other database
}
sql.append(formatMethod).append("(");
if (!StringUtils.isEmpty(tableAlias)) {
sql.append(tableAlias).append(".");
}
sql.append(columnName).append(",");
sql.append("'");
sql.append(pattern);
sql.append("')");
return sql.toString();
} | 3.26 |
druid_MySqlOutputVisitor_visit_rdh | // char c0 = alias.charAt(0);
// if (!hasSpecial) {
// print0(alias);
// } else {
// print('"');
//
// for (int i = 0; i < alias.length(); ++i) {
// char ch = alias.charAt(i);
// if (ch == '\"') {
// print('\\');
// print(ch);
// } else if (ch == '\n') {
// print0("\\n");
// } else {
// print(ch);
// }
// }
//
// print('"');
// }
// }
// return false;
// }
public boolean visit(MysqlAlterTableAlterCheck x) {
print0(ucase ? "ALTER CONSTRAINT " : "alter constraint ");
SQLName name =
x.getName();
if (name != null) {
name.accept(this); print(' ');
}
Boolean enforced = x.getEnforced();
if (enforced != null) {
if (enforced) {
print0(ucase ? " ENFORCED" : " enforced");
} else {
print0(ucase ? " NOT ENFORCED" : " not enforced");
}
}
return false;
} | 3.26 |
druid_SqlMapClientImplWrapper_queryForPaginatedList_rdh | /**
*
* @deprecated All paginated list features have been deprecated
*/
public PaginatedList queryForPaginatedList(String id, int
pageSize) throws SQLException {
return getLocalSqlMapSessionWrapper().queryForPaginatedList(id, pageSize);
} | 3.26 |
druid_StatViewServlet_initJmxConn_rdh | /**
* 初始化jmx连接
*
* @throws IOException
*/
private void initJmxConn() throws IOException {
if (jmxUrl != null) {
JMXServiceURL url = new JMXServiceURL(jmxUrl);
Map<String, String[]> env = null;
if (jmxUsername != null) {
env = new HashMap<String, String[]>();
String[] credentials = new
String[]{ jmxUsername, jmxPassword };
env.put(JMXConnector.CREDENTIALS, credentials);
}
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
conn = jmxc.getMBeanServerConnection();
}
} | 3.26 |
druid_StatViewServlet_process_rdh | /**
* 程序首先判断是否存在jmx连接地址,如果不存在,则直接调用本地的druid服务; 如果存在,则调用远程jmx服务。在进行jmx通信,首先判断一下jmx连接是否已经建立成功,如果已经
* 建立成功,则直接进行通信,如果之前没有成功建立,则会尝试重新建立一遍。.
*
* @param url
* 要连接的服务地址
* @return 调用服务后返回的json字符串
*/protected String process(String url) {
String resp = null;
if (jmxUrl == null) {
resp = statService.service(url);
} else if (conn == null) {
// 连接在初始化时创建失败
try
{
// 尝试重新连接
initJmxConn();
} catch (IOException e)
{
LOG.error("init jmx connection error", e);
resp = DruidStatService.returnJSONResult(DruidStatService.RESULT_CODE_ERROR, "init jmx connection error" + e.getMessage());
}
if (conn != null) {
// 连接成功
try {
resp = getJmxResult(conn, url);
} catch (Exception e) {
LOG.error("get jmx data error", e);
resp = DruidStatService.returnJSONResult(DruidStatService.RESULT_CODE_ERROR, "get data error:" + e.getMessage());
}
}
} else {
// 连接成功
try {
resp = getJmxResult(conn, url);
} catch (Exception e) {
LOG.error("get jmx data error", e);
resp = DruidStatService.returnJSONResult(DruidStatService.RESULT_CODE_ERROR, "get data error" + e.getMessage());
}
}
return resp;
} | 3.26 |
druid_StatViewServlet_getJmxResult_rdh | /**
* 根据指定的url来获取jmx服务返回的内容.
*
* @param connetion
* jmx连接
* @param url
* url内容
* @return the jmx返回的内容
* @throws Exception
* the exception
*/
private String getJmxResult(MBeanServerConnection connetion, String url) throws Exception {
ObjectName name = new ObjectName(DruidStatService.MBEAN_NAME);
String result = ((String) (conn.invoke(name, "service", new String[]{ url }, new String[]{ String.class.getName() })));
return result;
} | 3.26 |
druid_StatViewServlet_readInitParam_rdh | /**
* 读取servlet中的配置参数.
*
* @param key
* 配置参数名
* @return 配置参数值,如果不存在当前配置参数,或者为配置参数长度为0,将返回null
*/
private String readInitParam(String key) {
String value = null;
try {
String param = getInitParameter(key);
if (param != null) {
param = param.trim();
if (param.length()
> 0) {
value = param;
}
}
} catch (Exception e)
{
String msg = ("initParameter config [" + key) + "] error";
LOG.warn(msg, e);
}
return value;
} | 3.26 |
druid_SQLBinaryOpExpr_mergeEqual_rdh | /**
* only for parameterized output
*
* @param a
* @param b
* @return */
private static boolean mergeEqual(SQLExpr a, SQLExpr b) {
if (!(a instanceof SQLBinaryOpExpr)) {
return false;
}
if (!(b instanceof SQLBinaryOpExpr)) {
return false;
}
SQLBinaryOpExpr binaryA = ((SQLBinaryOpExpr) (a));
SQLBinaryOpExpr binaryB = ((SQLBinaryOpExpr) (b));
if (binaryA.operator != SQLBinaryOperator.Equality) {
return false;
}
if (binaryB.operator != SQLBinaryOperator.Equality) {return false;
}
if (!((binaryA.right instanceof SQLLiteralExpr) || (binaryA.right instanceof SQLVariantRefExpr))) {
return false;
}
if (!((binaryB.right instanceof SQLLiteralExpr) || (binaryB.right instanceof SQLVariantRefExpr))) {
return false;
}
return binaryA.left.equals(binaryB.left);
} | 3.26 |
druid_SQLBinaryOpExpr_getMergedList_rdh | /**
* only for parameterized output
*
* @return */
public List<SQLObject> getMergedList() {
return mergedList;
} | 3.26 |
druid_SQLBinaryOpExpr_addMergedItem_rdh | /**
* only for parameterized output
*
* @param item
* @return */
private void addMergedItem(SQLBinaryOpExpr item) {
if (mergedList == null) {mergedList = new ArrayList<SQLObject>();
}
mergedList.add(item);
} | 3.26 |
druid_SQLBinaryOpExpr_merge_rdh | /**
* only for parameterized output
*
* @param v
* @param x
* @return */
public static SQLBinaryOpExpr merge(ParameterizedVisitor v, SQLBinaryOpExpr x)
{
SQLObject parent = x.parent;
for (; ;) {
if (x.right instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr rightBinary = ((SQLBinaryOpExpr) (x.right));
if (x.left instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr leftBinaryExpr = ((SQLBinaryOpExpr) (x.left));
if (SQLExprUtils.equals(leftBinaryExpr.right, rightBinary)) {
x = leftBinaryExpr;
v.incrementReplaceCunt();
continue;
}
}
SQLExpr mergedRight = merge(v, rightBinary);
if (mergedRight != x.right) {
x = new SQLBinaryOpExpr(x.left, x.operator, mergedRight);
v.incrementReplaceCunt();
}
x.setParent(parent);
}
break;
}if (x.left instanceof SQLBinaryOpExpr) {
SQLExpr mergedLeft = merge(v, ((SQLBinaryOpExpr) (x.left)));
if (mergedLeft != x.left) {
SQLBinaryOpExpr tmp = new SQLBinaryOpExpr(mergedLeft, x.operator, x.right);
tmp.setParent(parent);
x = tmp;
v.incrementReplaceCunt();
}
}// ID = ? OR ID = ? => ID = ?
if ((x.operator == SQLBinaryOperator.BooleanOr) && (!v.isEnabled(VisitorFeature.OutputParameterizedQuesUnMergeInList))) {
if ((x.left instanceof SQLBinaryOpExpr) && (x.right instanceof SQLBinaryOpExpr)) {
SQLBinaryOpExpr leftBinary = ((SQLBinaryOpExpr) (x.left));
SQLBinaryOpExpr rightBinary = ((SQLBinaryOpExpr) (x.right));
if (mergeEqual(leftBinary, rightBinary)) {
v.incrementReplaceCunt();
leftBinary.setParent(x.parent);
leftBinary.addMergedItem(rightBinary);
return leftBinary;
}
if (SQLExprUtils.isLiteralExpr(leftBinary.left)//
&& (leftBinary.operator == SQLBinaryOperator.BooleanOr)) {
if (mergeEqual(leftBinary.right, x.right)) {
v.incrementReplaceCunt();
leftBinary.addMergedItem(rightBinary);
return leftBinary;
}
}
}
}
return x;
} | 3.26 |
druid_SQLAggregateExpr_getWithinGroup_rdh | // 为了兼容之前的逻辑
@Deprecated
public SQLOrderBy getWithinGroup() {
return orderBy;
} | 3.26 |
druid_PoolUpdater_update_rdh | /**
* Process the given NodeEvent[]. Maybe add / delete some nodes.
*/
@Override
public void update(Observable o, Object arg) {
if (!(o instanceof NodeListener)) {
return;
}if ((arg == null) || (!(arg instanceof NodeEvent[]))) {
return;
}
NodeEvent[] events = ((NodeEvent[]) (arg));
if (events.length <= 0) {
return;
}
try {
LOG.info("Waiting for Lock to start processing NodeEvents.");
lock.lock();
LOG.info(("Start processing the NodeEvent[" + events.length) + "].");
for (NodeEvent e : events) {
if (e.getType() == NodeEventTypeEnum.ADD) {
addNode(e);
} else if (e.getType() == NodeEventTypeEnum.DELETE) {
deleteNode(e);
}
}
} catch (Exception e) {
LOG.error("Exception occurred while updating Pool.", e);
} finally {
lock.unlock();
}} | 3.26 |
druid_PoolUpdater_removeDataSources_rdh | /**
* Remove unused DataSources.
*/
public void removeDataSources()
{
if ((f0 == null) || f0.isEmpty()) {
return;}
try {
lock.lock();
Map<String, DataSource> map = highAvailableDataSource.getDataSourceMap();
Set<String> copySet = new HashSet<String>(f0);
for (String nodeName : copySet) {
LOG.info(("Start removing Node " + nodeName) + ".");
if (!map.containsKey(nodeName)) {
LOG.info(("Node " + nodeName) + " is NOT existed in the map.");
cancelBlacklistNode(nodeName);
continue;}
DataSource ds = map.get(nodeName);
if (ds instanceof DruidDataSource) {
DruidDataSource dds = ((DruidDataSource) (ds));
int activeCount = dds.getActiveCount();// CAUTION, activeCount MAYBE changed!
if (activeCount > 0) {
LOG.warn(((("Node " + nodeName) + " is still running [activeCount=") + activeCount) + "], try next time.");
continue;
} else {
LOG.info(("Close Node " + nodeName) + " and remove it.");
try {
dds.close();
} catch (Exception e) {
LOG.error(("Exception occurred while closing Node " + nodeName) + ", just remove it.", e);
}
}
}
map.remove(nodeName);// Remove the node directly if it is NOT a DruidDataSource.
cancelBlacklistNode(nodeName);
}
} catch (Exception e) {
LOG.error("Exception occurred while removing DataSources.",
e);
} finally {
lock.unlock();
}
} | 3.26 |
druid_SQLMethodInvokeExpr_addParameter_rdh | /**
* deprecated, instead of addArgument
*
* @deprecated */
public void
addParameter(SQLExpr param) {
if (param != null) {
param.setParent(this);
}
this.arguments.add(param);
} | 3.26 |
druid_SQLMethodInvokeExpr_getParameters_rdh | /**
* instead of getArguments
*
* @deprecated */
public List<SQLExpr> getParameters() {
return this.arguments;
} | 3.26 |
druid_SQLASTOutputVisitor_setOutputParameters_rdh | /**
*
* @since 1.1.5
*/
public void setOutputParameters(List<Object> parameters) {
this.parameters = parameters;
} | 3.26 |
druid_SQLASTOutputVisitor_visit_rdh | // /////////// for odps & hive
@Override
public boolean visit(SQLLateralViewTableSource x) {
SQLTableSource tableSource = x.getTableSource();
if (tableSource !=
null) {
tableSource.accept(this);
}
this.indentCount++;
println();
print0(ucase ? "LATERAL VIEW " : "lateral view ");
if (x.isOuter()) {
print0(ucase ? "OUTER " : "outer ");
}
x.getMethod().accept(this);
print(' ');
print0(x.getAlias());
if ((x.getColumns() != null) && (x.getColumns().size() > 0)) {
print0(ucase ? " AS " : " as ");
printAndAccept(x.getColumns(), ", ");
}
SQLExpr on = x.getOn();
if (on != null) {
println();
print0(ucase ? "ON " : "on ");
printExpr(on);
}
this.indentCount--;
return false;
} | 3.26 |
druid_SQLExprParser_m4_rdh | // for ads
public void m4(SQLExpr expr) { if ((lexer.token == Token.HINT) && ((((((expr instanceof SQLInListExpr) || (expr instanceof SQLBinaryOpExpr)) || (expr instanceof SQLInSubQueryExpr)) || (expr instanceof SQLExistsExpr)) || (expr instanceof SQLNotExpr)) || (expr instanceof SQLBetweenExpr))) {
String text = lexer.stringVal().trim();
Lexer hintLex = SQLParserUtils.createLexer(text, dbType);
hintLex.nextToken();
// 防止SQL注入
if (hintLex.token == Token.PLUS) {if (expr instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr binaryOpExpr = ((SQLBinaryOpExpr) (expr));
SQLBinaryOperator operator = binaryOpExpr.getOperator();
if
((operator == SQLBinaryOperator.BooleanAnd) || (operator == SQLBinaryOperator.BooleanOr)) {
if (binaryOpExpr.isParenthesized()) {
binaryOpExpr.setHint(new SQLCommentHint(text));
} else {
SQLExpr
right = binaryOpExpr.getRight();
if ((right instanceof SQLBinaryOpExpr) || (right instanceof SQLBetweenExpr)) {
((SQLExprImpl) (right)).setHint(new SQLCommentHint(text));
}
}
} else {
binaryOpExpr.setHint(new SQLCommentHint(text));
}
} else if (expr instanceof SQLObjectImpl) {
((SQLExprImpl) (expr)).setHint(new SQLCommentHint(text));
} else {
throw new ParserException("TODO : " + lexer.info());}
this.lexer.nextToken();
}
}
} | 3.26 |
druid_CharTypes_isWhitespace_rdh | /**
*
* @return false if {@link LayoutCharacters#EOI}
*/
public static boolean isWhitespace(char c) {
return ((c <= whitespaceFlags.length) && whitespaceFlags[c])//
|| (c == ' ');// Chinese space
} | 3.26 |
druid_DruidDriver_getDataSource_rdh | /**
* 参数定义: com.alibaba.druid.log.LogFilter=filter com.alibaba.druid.log.LogFilter.p1=prop-value
* com.alibaba.druid.log.LogFilter.p2=prop-value
*
* @param url
* @return * @throws SQLException
*/
private DataSourceProxyImpl getDataSource(String url, Properties info) throws SQLException {
DataSourceProxyImpl
v3 = proxyDataSources.get(url);
if (v3 == null) {
DataSourceProxyConfig config = parseConfig(url, info);
Driver rawDriver = createDriver(config.getRawDriverClassName());
DataSourceProxyImpl newDataSource = new DataSourceProxyImpl(rawDriver, config);
{
String property
= System.getProperty("druid.filters");
if ((property != null) && (property.length() > 0)) {
for (String filterItem : property.split(",")) {
FilterManager.loadFilter(config.getFilters(), filterItem);
}
}
}{
int dataSourceId = createDataSourceId();
newDataSource.setId(dataSourceId);
for (Filter filter : config.getFilters()) {
filter.init(newDataSource);
}
}
DataSourceProxy oldDataSource = proxyDataSources.putIfAbsent(url, newDataSource);
if (oldDataSource == null) {
if (config.isJmxOption()) {
JMXUtils.register("com.alibaba.druid:type=JdbcStat", JdbcStatManager.getInstance());}
}
v3 = proxyDataSources.get(url);}
return v3;
} | 3.26 |
druid_MySqlSchemaStatVisitor_visit_rdh | // DUAL
public boolean
visit(MySqlDeleteStatement x) {
if ((repository != null) && (x.getParent() == null)) {
repository.resolve(x);
}
SQLTableSource from = x.getFrom();
if (from != null) {
from.accept(this);
}
SQLTableSource using = x.getUsing();
if (using != null) {
using.accept(this);
}
SQLTableSource tableSource = x.getTableSource();
tableSource.accept(this);
if (tableSource instanceof SQLExprTableSource) {
TableStat stat =
this.getTableStat(((SQLExprTableSource) (tableSource)));
stat.incrementDeleteCount();
}
accept(x.getWhere());
accept(x.getOrderBy());
accept(x.getLimit());
return false;
} | 3.26 |
druid_FilterAdapter_resultSet_getRowId_rdh | // ////////////////
@Override
public RowId resultSet_getRowId(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
return chain.resultSet_getRowId(result, columnIndex);
} | 3.26 |
druid_FilterAdapter_dataSource_releaseConnection_rdh | // ///////////////////
@Override
public void dataSource_releaseConnection(FilterChain chain, DruidPooledConnection connection) throws SQLException {
chain.dataSource_recycle(connection);
} | 3.26 |
druid_FilterAdapter_callableStatement_getTime_rdh | // //////////////////////////////
@Override
public Time callableStatement_getTime(FilterChain chain, CallableStatementProxy statement, int parameterIndex, Calendar cal) throws SQLException {
return chain.callableStatement_getTime(statement, parameterIndex, cal);} | 3.26 |
druid_FilterAdapter_resultSetMetaData_getColumnCount_rdh | // ///////////////
@Override
public int resultSetMetaData_getColumnCount(FilterChain chain, ResultSetMetaDataProxy metaData) throws SQLException {
return chain.resultSetMetaData_getColumnCount(metaData);
} | 3.26 |
druid_FilterAdapter_callableStatement_registerOutParameter_rdh | // ///////////////
@Override public void callableStatement_registerOutParameter(FilterChain chain, CallableStatementProxy statement, int parameterIndex, int sqlType) throws SQLException {
chain.callableStatement_registerOutParameter(statement, parameterIndex, sqlType);
} | 3.26 |
druid_FilterAdapter_statement_executeQuery_rdh | // /////////////////////////////
@Override
public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy
statement, String sql) throws SQLException {
return chain.statement_executeQuery(statement, sql);
} | 3.26 |
druid_MySQL8DateTimeSqlTypeFilter_resultSet_getObject_rdh | /**
* 针对mysql jdbc 8.0.23及以上版本,通过该方法控制将对象类型转换成原来的类型
*
* @param chain
* @param result
* @param columnLabel
* @return * @throws SQLException
* @see java.sql.ResultSet#getObject(String)
*/
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
return getObjectReplaceLocalDateTime(super.resultSet_getObject(chain, result, columnLabel));
} | 3.26 |
druid_MySQL8DateTimeSqlTypeFilter_resultSet_getMetaData_rdh | /**
* mybatis查询结果为map时, 会自动做类型映射。只有在自动映射前,更改 ResultSetMetaData 里映射的 java 类型,才会生效
*
* @param chain
* @param resultSet
* @return * @throws SQLException
*/
@Override
public ResultSetMetaData resultSet_getMetaData(FilterChain chain, ResultSetProxy resultSet) throws SQLException {
return new MySQL8DateTimeResultSetMetaData(chain.resultSet_getMetaData(resultSet));
} | 3.26 |
druid_MySQL8DateTimeSqlTypeFilter_getObjectReplaceLocalDateTime_rdh | /**
* 针对mysql jdbc 8.0.23及以上版本,通过该方法控制将对象类型转换成原来的类型
*
* @param obj
* @return */
public static Object getObjectReplaceLocalDateTime(Object obj) {
if (!(obj instanceof LocalDateTime)) {
return obj;}
// 针对升级到了mysql jdbc 8.0.23以上的情况,转换回老的兼容类型
return Timestamp.valueOf(((LocalDateTime) (obj)));
} | 3.26 |
druid_DruidFilterConfiguration_statFilter_rdh | /**
*
* @author lihengming [[email protected]]
*/public class DruidFilterConfiguration {
@Bean
@ConfigurationProperties(FILTER_STAT_PREFIX)
@ConditionalOnProperty(prefix = FILTER_STAT_PREFIX, name = "enabled")
@ConditionalOnMissingBean
public StatFilter statFilter() {
return new StatFilter();
} | 3.26 |
druid_BeanTypeAutoProxyCreator_setTargetBeanType_rdh | /**
*
* @param targetClass
* the targetClass to set
*/
public void setTargetBeanType(Class<?> targetClass) {
this.targetBeanType = targetClass;
} | 3.26 |
druid_BeanTypeAutoProxyCreator_isMatch_rdh | /**
* Return if the given bean name matches the mapped name.
* <p>
* The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality. Can be
* overridden in subclasses.
*
* @param beanName
* the bean name to check
* @param mappedName
* the name in the configured list of names
* @return if the names match
* @see org.springframework.util.PatternMatchUtils#simpleMatch(String, String)
*/
protected boolean isMatch(String beanName, String mappedName) {
return PatternMatchUtils.simpleMatch(mappedName, beanName);
} | 3.26 |
druid_BeanTypeAutoProxyCreator_getAdvicesAndAdvisorsForBean_rdh | /**
* Identify as bean to proxy if the bean name is in the configured list of names.
*/
@SuppressWarnings("rawtypes")
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource) {
for (String mappedName : this.beanNames) {
if (FactoryBean.class.isAssignableFrom(beanClass)) {
if (!mappedName.startsWith(BeanFactory.FACTORY_BEAN_PREFIX)) {
continue;
}
mappedName = mappedName.substring(BeanFactory.FACTORY_BEAN_PREFIX.length());
}
if (isMatch(beanName, mappedName)) {
return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS;
}
}
return
DO_NOT_PROXY;
} | 3.26 |
druid_DruidDataSourceConverter_convert_rdh | /**
*
* @see org.osjava.sj.loader.convert.Converter#convert(java.util.Properties, java.lang.String)
*/
@Override
public Object convert(Properties properties, String type) {
try
{
DruidDataSource dataSource
= new DruidDataSource();
DruidDataSourceFactory.config(dataSource, properties);
return dataSource;
} catch (SQLException e) {
LOG.error("properties:" + properties, e);
}
return null;
} | 3.26 |
druid_PhoenixExceptionSorter_isExceptionFatal_rdh | /**
* 解决phoenix 的错误 --Connection is null or closed
*
* @param e
* the exception
* @return */
@Override
public boolean isExceptionFatal(SQLException
e) {
if (e.getMessage().contains("Connection is null or closed")) {
LOG.error("剔除phoenix不可用的连接",
e);
return true;
}return false;
} | 3.26 |
druid_ConnectionProxyImpl_createStatement_rdh | //
@Override
public Statement createStatement(int
resultSetType, //
int resultSetConcurrency, //
int resultSetHoldability) throws SQLException {
FilterChainImpl chain = createChain();
Statement stmt = chain.connection_createStatement(this, resultSetType, resultSetConcurrency, resultSetHoldability);
recycleFilterChain(chain);
return stmt;
} | 3.26 |
druid_StatementProxyImpl_getUpdateCount_rdh | // bug fixed for oracle
@Override
public int getUpdateCount() throws SQLException {
if (updateCount == null) {
FilterChainImpl chain = createChain();
updateCount = chain.statement_getUpdateCount(this);
recycleFilterChain(chain);
} return updateCount;
} | 3.26 |
druid_CharsetConvert_decode_rdh | /**
* 字符串解码
*
* @param s
* String
* @return String
* @throws UnsupportedEncodingException
*/
public String decode(String s) throws UnsupportedEncodingException {
if (enable && (!isEmpty(s)))
{s = new String(s.getBytes(serverEncoding), clientEncoding);
}
return s;
} | 3.26 |
druid_CharsetConvert_encode_rdh | /**
* 字符串编码
*
* @param s
* String
* @return String
* @throws UnsupportedEncodingException
*/
public String encode(String s) throws UnsupportedEncodingException {
if (enable && (!isEmpty(s))) {
s = new String(s.getBytes(clientEncoding), serverEncoding);
}
return s;} | 3.26 |
druid_CharsetConvert_isEmpty_rdh | /**
* 判断空字符串
*
* @param s
* String
* @return boolean
*/
public boolean isEmpty(String s) {
return (s == null) || "".equals(s);
} | 3.26 |
druid_SQLIndexDefinition_addOption_rdh | //
// Function for compatibility.
//
public void addOption(String name, SQLExpr
value) {
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr(name), value);
if (getParent() != null) {
assignItem.setParent(getParent());
} else {
assignItem.setParent(this); }
getCompatibleOptions().add(assignItem);} | 3.26 |
druid_IPAddress_getIPAddress_rdh | // -------------------------------------------------------------------------
/**
* Return the integer representation of the IP address.
*
* @return The IP address.
*/
public final int getIPAddress() {
return ipAddress;
} | 3.26 |
druid_IPAddress_parseIPAddress_rdh | // -------------------------------------------------------------------------
/**
* Convert a decimal-dotted notation representation of an IP address into an 32 bits interger value.
*
* @param ipAddressStr
* Decimal-dotted notation (xxx.xxx.xxx.xxx) of the IP address.
* @return Return the 32 bits integer representation of the IP address.
* @throws InvalidIPAddressException
* Throws this exception if the specified IP address is not compliant to the
* decimal-dotted notation xxx.xxx.xxx.xxx.
*/
final int parseIPAddress(String ipAddressStr) {
int result = 0;
if (ipAddressStr == null) {
throw new IllegalArgumentException();
}
try {
String tmp = ipAddressStr;
// get the 3 first numbers
int offset = 0;
for (int i
= 0; i < 3; i++) {
// get the position of the first dot
int index = tmp.indexOf('.');
// if there is not a dot then the ip string representation is
// not compliant to the decimal-dotted notation.
if (index != (-1)) {
// get the number before the dot and convert it into
// an integer.
String numberStr = tmp.substring(0, index);
int number = Integer.parseInt(numberStr);
if ((number < 0) || (number > 255)) {
throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr) + "]");
}
result += number << offset;
offset += 8;
tmp = tmp.substring(index
+ 1);
} else {
throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr)
+ "]");
}
}
// the remaining part of the string should be the last number.
if (tmp.length() > 0) {
int number = Integer.parseInt(tmp);
if ((number < 0) || (number > 255)) {
throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr) + "]");
}
result += number << offset;
ipAddress = result;
} else {throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr) + "]");
}
} catch (NoSuchElementException ex) {
throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr) + "]", ex);
} catch (NumberFormatException ex) {
throw new IllegalArgumentException(("Invalid IP Address [" + ipAddressStr) + "]", ex);
}
return result;
} | 3.26 |
druid_IPAddress_toString_rdh | // -------------------------------------------------------------------------
/**
* Return the string representation of the IP Address following the common decimal-dotted notation xxx.xxx.xxx.xxx.
*
* @return Return the string representation of the IP address.
*/
public String toString() {
StringBuilder v0 = new StringBuilder();
int temp;
temp = ipAddress & 0xff;v0.append(temp);
v0.append(".");
temp = (ipAddress >> 8) & 0xff;
v0.append(temp);
v0.append(".");
temp = (ipAddress >> 16) & 0xff;
v0.append(temp);
v0.append(".");
temp = (ipAddress >> 24) & 0xff;
v0.append(temp);
return v0.toString();
} | 3.26 |
druid_NodeEvent_m0_rdh | /**
* Diff the given two Properties.
*
* @return A List of AddEvent and DelEvent
*/
public static List<NodeEvent> m0(Properties previous, Properties next) {
List<String> prevNames = PropertiesUtils.loadNameList(previous, "");
List<String> nextNames = PropertiesUtils.loadNameList(next, "");
List<String> namesToAdd = new ArrayList<String>();
List<String> namesToDel = new ArrayList<String>();
for (String v4 : prevNames) {
if (((v4 != null) && (!v4.trim().isEmpty())) && (!nextNames.contains(v4))) {
namesToDel.add(v4);
}
}
for (String n : nextNames) {
if (((n != null) && (!n.trim().isEmpty())) && (!prevNames.contains(n))) {
namesToAdd.add(n);
}
}
List<NodeEvent> list = new ArrayList<NodeEvent>();
list.addAll(generateEvents(next, namesToAdd, NodeEventTypeEnum.ADD));
list.addAll(generateEvents(previous, namesToDel, NodeEventTypeEnum.DELETE));
return list;
} | 3.26 |
druid_SQLServerStatementParser_parseExecParameter_rdh | /**
* SQLServer parse Parameter statement support out type
*
* @author zz [[email protected]]
*/
public void parseExecParameter(Collection<SQLServerParameter> exprCol, SQLObject parent) {
if ((lexer.token() == Token.RPAREN) || (lexer.token() == Token.RBRACKET)) {
return;
}
if (lexer.token() == Token.EOF) {
return;
}
SQLServerParameter
param = new SQLServerParameter();
SQLExpr expr = this.exprParser.expr();
expr.setParent(parent);
param.setExpr(expr);
if
(lexer.token() == Token.OUT) {
param.setType(true);
accept(Token.OUT);
}
exprCol.add(param);
while (lexer.token() == Token.COMMA) {
lexer.nextToken();
param = new SQLServerParameter();
expr = this.exprParser.expr();
expr.setParent(parent);
param.setExpr(expr);if (lexer.token() == Token.OUT)
{
param.setType(true);
accept(Token.OUT);
}
exprCol.add(param);
}
} | 3.26 |
druid_WallConfig_isSelelctAllow_rdh | /**
*
* @deprecated use isSelectAllow
*/
public boolean isSelelctAllow() { return isSelectAllow();
} | 3.26 |
druid_WallConfig_setDescribeAllow_rdh | /**
* set allow mysql describe statement
*
* @since 0.2.10
*/
public void setDescribeAllow(boolean describeAllow) {
this.describeAllow = describeAllow;
} | 3.26 |
druid_WallConfig_isDescribeAllow_rdh | /**
* allow mysql describe statement
*
* @return * @since 0.2.10
*/
public boolean isDescribeAllow() {
return describeAllow;
} | 3.26 |
druid_WallConfig_setSelelctAllow_rdh | /**
*
* @deprecated use setSelelctAllow
*/public void setSelelctAllow(boolean selelctAllow) {
this.setSelectAllow(selelctAllow);
} | 3.26 |
druid_WallConfig_isCommentAllow_rdh | // ///////////////////
public boolean isCommentAllow() {
return commentAllow;
} | 3.26 |
druid_WallFilter_statement_execute_rdh | // //////////////
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
WallContext originalContext = WallContext.current();
try {
createWallContext(statement);
sql = check(sql);
boolean firstResult = chain.statement_execute(statement, sql);
if (!firstResult) {
int updateCount = statement.getUpdateCount();
statExecuteUpdate(updateCount);
} else {setSqlStatAttribute(statement);
}
return firstResult;
} catch (SQLException ex) {
incrementExecuteErrorCount();
throw ex;
} finally {
if (originalContext != null) {
WallContext.setContext(originalContext); }
}
} | 3.26 |
druid_WallFilter_resultSet_findColumn_rdh | // ////////////////
@Override
public int resultSet_findColumn(FilterChain chain, ResultSetProxy resultSet, String columnLabel) throws SQLException {
int physicalColumn = chain.resultSet_findColumn(resultSet, columnLabel);
return resultSet.getLogicColumn(physicalColumn);
} | 3.26 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.