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

Do not pass duplicate parameters to query in getTables()

上级 d22f23f1
...@@ -158,14 +158,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -158,14 +158,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "TYPE_NAME REF_GENERATION, " + "TYPE_NAME REF_GENERATION, "
+ "SQL " + "SQL "
+ "FROM INFORMATION_SCHEMA.TABLES " + "FROM INFORMATION_SCHEMA.TABLES "
+ "WHERE TABLE_CATALOG LIKE ? ESCAPE ? " + "WHERE TABLE_CATALOG LIKE ?1 ESCAPE ?4 "
+ "AND TABLE_SCHEMA LIKE ? ESCAPE ? " + "AND TABLE_SCHEMA LIKE ?2 ESCAPE ?4 "
+ "AND TABLE_NAME LIKE ? ESCAPE ?"; + "AND TABLE_NAME LIKE ?3 ESCAPE ?4";
if (typesLength > 0) { if (typesLength > 0) {
StatementBuilder buff = new StatementBuilder(tableSelect).append(" AND TABLE_TYPE IN("); StatementBuilder buff = new StatementBuilder(tableSelect).append(" AND TABLE_TYPE IN(");
for (int i = 0; i < typesLength; i++) { for (int i = 0; i < typesLength; i++) {
buff.appendExceptFirst(", "); buff.appendExceptFirst(", ");
buff.append('?'); buff.append('?').append(i + 5);
} }
tableSelect = buff.append(')').toString(); tableSelect = buff.append(')').toString();
} }
...@@ -184,9 +184,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -184,9 +184,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "TYPE_NAME REF_GENERATION, " + "TYPE_NAME REF_GENERATION, "
+ "NULL AS SQL " + "NULL AS SQL "
+ "FROM INFORMATION_SCHEMA.SYNONYMS " + "FROM INFORMATION_SCHEMA.SYNONYMS "
+ "WHERE SYNONYM_CATALOG LIKE ? ESCAPE ? " + "WHERE SYNONYM_CATALOG LIKE ?1 ESCAPE ?4 "
+ "AND SYNONYM_SCHEMA LIKE ? ESCAPE ? " + "AND SYNONYM_SCHEMA LIKE ?2 ESCAPE ?4 "
+ "AND SYNONYM_NAME LIKE ? ESCAPE ? " + "AND SYNONYM_NAME LIKE ?3 ESCAPE ?4 "
+ "AND (" + includeSynonyms + ") "; + "AND (" + includeSynonyms + ") ";
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
...@@ -204,19 +204,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -204,19 +204,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+ "FROM (" + synonymSelect + " UNION " + tableSelect + ") " + "FROM (" + synonymSelect + " UNION " + tableSelect + ") "
+ "ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME"); + "ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME");
prep.setString(1, getCatalogPattern(catalogPattern)); prep.setString(1, getCatalogPattern(catalogPattern));
prep.setString(2, "\\"); prep.setString(2, getSchemaPattern(schemaPattern));
prep.setString(3, getSchemaPattern(schemaPattern)); prep.setString(3, getPattern(tableNamePattern));
prep.setString(4, "\\"); prep.setString(4, "\\");
prep.setString(5, getPattern(tableNamePattern));
prep.setString(6, "\\");
prep.setString(7, getCatalogPattern(catalogPattern));
prep.setString(8, "\\");
prep.setString(9, getSchemaPattern(schemaPattern));
prep.setString(10, "\\");
prep.setString(11, getPattern(tableNamePattern));
prep.setString(12, "\\");
for (int i = 0; i < typesLength; i++) { for (int i = 0; i < typesLength; i++) {
prep.setString(13 + i, types[i]); prep.setString(5 + i, types[i]);
} }
return prep.executeQuery(); return prep.executeQuery();
} catch (Exception e) { } catch (Exception e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论