# HG changeset patch # User matthias42@netbeans.org # Date 1327748563 -3600 # Node ID 6d8a29d94e67960fcb356700f40d228a01485f28 # Parent da3750f312e018d566e1a72dbb63699fa51f3258 Don't assume '.' is the catalog seperator instead use the DatabaseMetaData and only fallback to '.' if the alternative is not viable (null or empty string) diff --git a/db/src/org/netbeans/modules/db/explorer/action/QueryAction.java b/db/src/org/netbeans/modules/db/explorer/action/QueryAction.java --- a/db/src/org/netbeans/modules/db/explorer/action/QueryAction.java +++ b/db/src/org/netbeans/modules/db/explorer/action/QueryAction.java @@ -113,10 +113,15 @@ SQLIdentifiers.Quoter quoter, String name, String authenticatedName, - boolean tableIsQualified) { + boolean tableIsQualified, + String seperator) { if (name != null && (tableIsQualified || !name.equals(authenticatedName))) { tableNameBuilder.append(quoter.quoteIfNeeded(name)); - tableNameBuilder.append('.'); + if(seperator == null || seperator.trim().isEmpty()) { + tableNameBuilder.append( "." ); + } else { + tableNameBuilder.append(seperator); + } return true; } else { return tableIsQualified; @@ -141,19 +146,20 @@ * @param connection valid database connection that SQL will be run under using the given table. * @param provider gives the catalog and the schema names that the given table name is referenced under. * @param quoter puts SQL identifiers is quotes when needed. + * @param dmd DatabaseMetaData to determine catalog seperator * @return table name that is sufficiently qualified to execute against the given catalog and schema. * @throws SQLException failed to identify the default catalog for this database connection */ - private String getQualifiedTableName(String simpleTableName, DatabaseConnection connection, SchemaNameProvider provider, SQLIdentifiers.Quoter quoter) throws SQLException { + private String getQualifiedTableName(String simpleTableName, DatabaseConnection connection, SchemaNameProvider provider, SQLIdentifiers.Quoter quoter, DatabaseMetaData dmd) throws SQLException { final String schemaName = provider.getSchemaName(); final String catName = provider.getCatalogName(); StringBuilder fullTableName = new StringBuilder(); boolean tableIsQualified = false; - tableIsQualified = appendQualifiedName(fullTableName, quoter, catName, connection.getConnection().getCatalog(), tableIsQualified); + tableIsQualified = appendQualifiedName(fullTableName, quoter, catName, connection.getConnection().getCatalog(), tableIsQualified, dmd.getCatalogSeparator()); // add schema always if possible - tableIsQualified = appendQualifiedName(fullTableName, quoter, schemaName, null, tableIsQualified); + tableIsQualified = appendQualifiedName(fullTableName, quoter, schemaName, null, tableIsQualified, null); fullTableName.append(quoter.quoteIfNeeded(simpleTableName)); return fullTableName.toString(); @@ -175,12 +181,12 @@ String onome; if (!isColumn) { - onome = getQualifiedTableName(activatedNodes[0].getName(), connection, provider, quoter); + onome = getQualifiedTableName(activatedNodes[0].getName(), connection, provider, quoter, dmd); return "select * from " + onome; // NOI18N } else { String parentName = activatedNodes[0].getLookup().lookup(ColumnNameProvider.class).getParentName(); - onome = getQualifiedTableName(parentName, connection, provider, quoter); + onome = getQualifiedTableName(parentName, connection, provider, quoter, dmd); StringBuilder cols = new StringBuilder(); for (Node node : activatedNodes) {