本文整理汇总了Java中com.alibaba.druid.sql.SQLUtils类的典型用法代码示例。如果您正苦于以下问题:Java SQLUtils类的具体用法?Java SQLUtils怎么用?Java SQLUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLUtils类属于com.alibaba.druid.sql包,在下文中一共展示了SQLUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLimitIFChange
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
protected void setLimitIFChange(SQLStatement stmt, RouteResultset rrs, SchemaConfig schema, SQLBinaryOpExpr one, int firstrownum, int lastrownum)
{
rrs.setLimitStart(firstrownum);
rrs.setLimitSize(lastrownum - firstrownum);
LayerCachePool tableId2DataNodeCache = (LayerCachePool) MycatServer.getInstance().getCacheService().getCachePool("TableID2DataNodeCache");
try
{
tryRoute(schema, rrs, tableId2DataNodeCache);
} catch (SQLNonTransientException e)
{
throw new RuntimeException(e);
}
if (isNeedChangeLimit(rrs))
{
one.setRight(new SQLIntegerExpr(0));
String curentDbType ="db2".equalsIgnoreCase(this.getCurentDbType())?"oracle":getCurentDbType();
String sql = SQLUtils.toSQLString(stmt, curentDbType);;
rrs.changeNodeSqlAfterAddLimit(schema,getCurentDbType(), sql,0,lastrownum, false);
//设置改写后的sql
getCtx().setSql(sql);
}
}
示例2: isUNI
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
/**
* only for show columns
*/
public boolean isUNI(String columnName) {
for (SQLTableElement element : this.tableElementList) {
if (element instanceof MySqlUnique) {
MySqlUnique unique = (MySqlUnique) element;
if (unique.getColumns().size() == 0) {
continue;
}
SQLExpr column = unique.getColumns().get(0).getExpr();
if (column instanceof SQLIdentifierExpr
&& SQLUtils.nameEquals(columnName, ((SQLIdentifierExpr) column).getName())) {
return unique.columns.size() == 1;
} else if (column instanceof SQLMethodInvokeExpr
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) column).getMethodName(), columnName)) {
return true;
}
}
}
return false;
}
示例3: isReferenced
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean isReferenced(String tableName) {
if (tableName == null) {
return false;
}
tableName = SQLUtils.normalize(tableName);
for (SQLTableElement element : this.tableElementList) {
if (element instanceof SQLForeignKeyConstraint) {
SQLForeignKeyConstraint fk = (SQLForeignKeyConstraint) element;
String refTableName = fk.getReferencedTableName().getSimpleName();
if (SQLUtils.nameEquals(tableName, refTableName)) {
return true;
}
}
}
return false;
}
示例4: apply
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean apply(SQLDropIndexStatement x) {
long indexNameHashCode64 = x.getIndexName().nameHashCode64();
for (int i = tableElementList.size() - 1; i >= 0; i--) {
SQLTableElement e = tableElementList.get(i);
if (e instanceof SQLUniqueConstraint) {
SQLUniqueConstraint unique = (SQLUniqueConstraint) e;
if (unique.getName().nameHashCode64() == indexNameHashCode64) {
tableElementList.remove(i);
return true;
}
} else if (e instanceof MySqlTableIndex) {
MySqlTableIndex tableIndex = (MySqlTableIndex) e;
if (SQLUtils.nameEquals(tableIndex.getName(), x.getIndexName())) {
tableElementList.remove(i);
return true;
}
}
}
return false;
}
示例5: columnIndexOf
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
protected int columnIndexOf(SQLName column) {
if (column == null) {
return -1;
}
String columnName = column.getSimpleName();
for (int i = tableElementList.size() - 1; i >= 0; --i) {
SQLTableElement e = tableElementList.get(i);
if (e instanceof SQLColumnDefinition) {
if (SQLUtils.nameEquals(columnName, ((SQLColumnDefinition) e).getName().getSimpleName())) {
return i;
}
}
}
return -1;
}
示例6: applyDropColumn
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean applyDropColumn(SQLName columnName) {
for (int i = columns.size() - 1; i >= 0; i--) {
SQLExpr expr = columns.get(i).getExpr();
if (expr instanceof SQLName
&& SQLUtils.nameEquals((SQLName) expr, columnName)) {
columns.remove(i);
return true;
}
if (expr instanceof SQLMethodInvokeExpr
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) expr).getMethodName(), columnName.getSimpleName())) {
columns.remove(i);
return true;
}
}
return false;
}
示例7: match
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean match(String owner, String function) {
if (function == null) {
return false;
}
if (!SQLUtils.nameEquals(function, name)) {
return false;
}
if (owner == null && this.owner == null) {
return true;
}
if (owner == null || this.owner == null) {
return false;
}
if (this.owner instanceof SQLIdentifierExpr) {
return SQLUtils.nameEquals(((SQLIdentifierExpr) this.owner).name, owner);
}
return false;
}
示例8: computeDataType
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public SQLDataType computeDataType() {
if (SQLUtils.nameEquals("to_date", name)
|| SQLUtils.nameEquals("add_months", name)) {
return SQLDateExpr.DEFAULT_DATA_TYPE;
}
if (parameters.size() == 1) {
if (SQLUtils.nameEquals("trunc", name)) {
return parameters.get(0).computeDataType();
}
} else if (parameters.size() == 2) {
SQLExpr param0 = parameters.get(0);
SQLExpr param1 = parameters.get(1);
if (SQLUtils.nameEquals("nvl", name) || SQLUtils.nameEquals("ifnull", name)) {
SQLDataType dataType = param0.computeDataType();
if (dataType != null) {
return dataType;
}
return param1.computeDataType();
}
}
return null;
}
示例9: applyDropColumn
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean applyDropColumn(SQLName columnName) {
for (int i = columns.size() - 1; i >= 0; i--) {
SQLExpr expr = columns.get(i).getExpr();
if (expr instanceof SQLName
&& SQLUtils.nameEquals((SQLName) expr, columnName)) {
columns.remove(i);
return true;
}
if (expr instanceof SQLMethodInvokeExpr
&& SQLUtils.nameEquals(((SQLMethodInvokeExpr) expr).getMethodName(), columnName.getSimpleName())) {
columns.remove(i);
return true;
}
}
return false;
}
示例10: computeName
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public String computeName() {
if (tableSource == null) {
return null;
}
SQLExpr expr = tableSource.getExpr();
if (expr instanceof SQLName) {
String name = ((SQLName) expr).getSimpleName();
return SQLUtils.normalize(name);
}
return null;
}
示例11: computeAlias
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public String computeAlias() {
String alias = this.getAlias();
if (alias == null) {
if (expr instanceof SQLIdentifierExpr) {
alias = ((SQLIdentifierExpr) expr).getName();
} else if (expr instanceof SQLPropertyExpr) {
alias = ((SQLPropertyExpr) expr).getName();
}
}
return SQLUtils.normalize(alias);
}
示例12: computeAlias
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public String computeAlias() {
String alias = null;
if (name instanceof SQLIdentifierExpr) {
alias = ((SQLIdentifierExpr) name).getName();
} else if (name instanceof SQLPropertyExpr) {
alias = ((SQLPropertyExpr) name).getName();
}
return SQLUtils.normalize(alias);
}
示例13: simplify
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public void simplify() {
enable = null;
validate = null;
rely = null;
if (this.name instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) this.name;
String columnName = identExpr.getName();
String normalized = SQLUtils.normalize(columnName, dbType);
if (normalized != columnName) {
this.setName(normalized);
}
}
}
示例14: containsAlias
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public boolean containsAlias(String alias) {
if (SQLUtils.nameEquals(this.alias, alias)) {
return true;
}
if (left != null && left.containsAlias(alias)) {
return true;
}
if (right != null && right.containsAlias(alias)) {
return true;
}
return false;
}
示例15: simplify
import com.alibaba.druid.sql.SQLUtils; //导入依赖的package包/类
public void simplify() {
if (this.name instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) this.name;
String columnName = identExpr.getName();
String normalized = SQLUtils.normalize(columnName, dbType);
if (columnName != normalized) {
this.setName(normalized);
}
}
}