Lines 113-122
Link Here
|
113 |
SQLIdentifiers.Quoter quoter, |
113 |
SQLIdentifiers.Quoter quoter, |
114 |
String name, |
114 |
String name, |
115 |
String authenticatedName, |
115 |
String authenticatedName, |
116 |
boolean tableIsQualified) { |
116 |
boolean tableIsQualified, |
|
|
117 |
String seperator) { |
117 |
if (name != null && (tableIsQualified || !name.equals(authenticatedName))) { |
118 |
if (name != null && (tableIsQualified || !name.equals(authenticatedName))) { |
118 |
tableNameBuilder.append(quoter.quoteIfNeeded(name)); |
119 |
tableNameBuilder.append(quoter.quoteIfNeeded(name)); |
119 |
tableNameBuilder.append('.'); |
120 |
if(seperator == null || seperator.trim().isEmpty()) { |
|
|
121 |
tableNameBuilder.append( "." ); |
122 |
} else { |
123 |
tableNameBuilder.append(seperator); |
124 |
} |
120 |
return true; |
125 |
return true; |
121 |
} else { |
126 |
} else { |
122 |
return tableIsQualified; |
127 |
return tableIsQualified; |
Lines 141-159
Link Here
|
141 |
* @param connection valid database connection that SQL will be run under using the given table. |
146 |
* @param connection valid database connection that SQL will be run under using the given table. |
142 |
* @param provider gives the catalog and the schema names that the given table name is referenced under. |
147 |
* @param provider gives the catalog and the schema names that the given table name is referenced under. |
143 |
* @param quoter puts SQL identifiers is quotes when needed. |
148 |
* @param quoter puts SQL identifiers is quotes when needed. |
|
|
149 |
* @param dmd DatabaseMetaData to determine catalog seperator |
144 |
* @return table name that is sufficiently qualified to execute against the given catalog and schema. |
150 |
* @return table name that is sufficiently qualified to execute against the given catalog and schema. |
145 |
* @throws SQLException failed to identify the default catalog for this database connection |
151 |
* @throws SQLException failed to identify the default catalog for this database connection |
146 |
*/ |
152 |
*/ |
147 |
private String getQualifiedTableName(String simpleTableName, DatabaseConnection connection, SchemaNameProvider provider, SQLIdentifiers.Quoter quoter) throws SQLException { |
153 |
private String getQualifiedTableName(String simpleTableName, DatabaseConnection connection, SchemaNameProvider provider, SQLIdentifiers.Quoter quoter, DatabaseMetaData dmd) throws SQLException { |
148 |
final String schemaName = provider.getSchemaName(); |
154 |
final String schemaName = provider.getSchemaName(); |
149 |
final String catName = provider.getCatalogName(); |
155 |
final String catName = provider.getCatalogName(); |
150 |
|
156 |
|
151 |
StringBuilder fullTableName = new StringBuilder(); |
157 |
StringBuilder fullTableName = new StringBuilder(); |
152 |
boolean tableIsQualified = false; |
158 |
boolean tableIsQualified = false; |
153 |
|
159 |
|
154 |
tableIsQualified = appendQualifiedName(fullTableName, quoter, catName, connection.getConnection().getCatalog(), tableIsQualified); |
160 |
tableIsQualified = appendQualifiedName(fullTableName, quoter, catName, connection.getConnection().getCatalog(), tableIsQualified, dmd.getCatalogSeparator()); |
155 |
// add schema always if possible |
161 |
// add schema always if possible |
156 |
tableIsQualified = appendQualifiedName(fullTableName, quoter, schemaName, null, tableIsQualified); |
162 |
tableIsQualified = appendQualifiedName(fullTableName, quoter, schemaName, null, tableIsQualified, null); |
157 |
fullTableName.append(quoter.quoteIfNeeded(simpleTableName)); |
163 |
fullTableName.append(quoter.quoteIfNeeded(simpleTableName)); |
158 |
|
164 |
|
159 |
return fullTableName.toString(); |
165 |
return fullTableName.toString(); |
Lines 175-186
Link Here
|
175 |
|
181 |
|
176 |
String onome; |
182 |
String onome; |
177 |
if (!isColumn) { |
183 |
if (!isColumn) { |
178 |
onome = getQualifiedTableName(activatedNodes[0].getName(), connection, provider, quoter); |
184 |
onome = getQualifiedTableName(activatedNodes[0].getName(), connection, provider, quoter, dmd); |
179 |
|
185 |
|
180 |
return "select * from " + onome; // NOI18N |
186 |
return "select * from " + onome; // NOI18N |
181 |
} else { |
187 |
} else { |
182 |
String parentName = activatedNodes[0].getLookup().lookup(ColumnNameProvider.class).getParentName(); |
188 |
String parentName = activatedNodes[0].getLookup().lookup(ColumnNameProvider.class).getParentName(); |
183 |
onome = getQualifiedTableName(parentName, connection, provider, quoter); |
189 |
onome = getQualifiedTableName(parentName, connection, provider, quoter, dmd); |
184 |
|
190 |
|
185 |
StringBuilder cols = new StringBuilder(); |
191 |
StringBuilder cols = new StringBuilder(); |
186 |
for (Node node : activatedNodes) { |
192 |
for (Node node : activatedNodes) { |