提交 d22f23f1 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Simplify TABLES part of query in getTables()

上级 1e6db840
......@@ -143,18 +143,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
", " + quoteArray(types) + ");");
}
checkClosed();
String tableType;
int typesLength = types != null ? types.length : 0;
if (typesLength > 0) {
StatementBuilder buff = new StatementBuilder("TABLE_TYPE IN(");
for (int i = 0; i < typesLength; i++) {
buff.appendExceptFirst(", ");
buff.append('?');
}
tableType = buff.append(')').toString();
} else {
tableType = "TRUE";
}
String tableSelect = "SELECT "
+ "TABLE_CATALOG TABLE_CAT, "
......@@ -171,8 +160,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "FROM INFORMATION_SCHEMA.TABLES "
+ "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
+ "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
+ "AND TABLE_NAME LIKE ? ESCAPE ? "
+ "AND (" + tableType + ") ";
+ "AND TABLE_NAME LIKE ? ESCAPE ?";
if (typesLength > 0) {
StatementBuilder buff = new StatementBuilder(tableSelect).append(" AND TABLE_TYPE IN(");
for (int i = 0; i < typesLength; i++) {
buff.appendExceptFirst(", ");
buff.append('?');
}
tableSelect = buff.append(')').toString();
}
boolean includeSynonyms = types == null || Arrays.asList(types).contains("SYNONYM");
String synonymSelect = "SELECT "
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论