public String toUpperCase(final Object target) { if (target == null) { return null; } return StringUtils.toUpperCase(target, this.locale); }
@SuppressWarnings("unchecked") public T setColumnName(String theColumnName) { myColumnName = StringUtils.toUpperCase(theColumnName, Locale.US); return (T) this; }
public void setIndexName(String theIndexName) { myIndexName = StringUtils.toUpperCase(theIndexName, Locale.US); }
/** * Retrieve all index names */ public static Set<String> getColumnNames(DriverTypeEnum.ConnectionProperties theConnectionProperties, String theTableName) throws SQLException { DataSource dataSource = Objects.requireNonNull(theConnectionProperties.getDataSource()); try (Connection connection = dataSource.getConnection()) { return theConnectionProperties.getTxTemplate().execute(t -> { DatabaseMetaData metadata; try { metadata = connection.getMetaData(); ResultSet indexes = metadata.getColumns(connection.getCatalog(), connection.getSchema(), massageIdentifier(metadata, theTableName), null); Set<String> columnNames = new HashSet<>(); while (indexes.next()) { String tableName = toUpperCase(indexes.getString("TABLE_NAME"), Locale.US); if (!theTableName.equalsIgnoreCase(tableName)) { continue; } String columnName = indexes.getString("COLUMN_NAME"); columnName = toUpperCase(columnName, Locale.US); columnNames.add(columnName); } return columnNames; } catch (SQLException e) { throw new InternalErrorException(e); } }); } }
public static Set<String> getTableNames(DriverTypeEnum.ConnectionProperties theConnectionProperties) throws SQLException { DataSource dataSource = Objects.requireNonNull(theConnectionProperties.getDataSource()); try (Connection connection = dataSource.getConnection()) { return theConnectionProperties.getTxTemplate().execute(t -> { DatabaseMetaData metadata; try { metadata = connection.getMetaData(); ResultSet tables = metadata.getTables(connection.getCatalog(), connection.getSchema(), null, null); Set<String> columnNames = new HashSet<>(); while (tables.next()) { String tableName = tables.getString("TABLE_NAME"); tableName = toUpperCase(tableName, Locale.US); String tableType = tables.getString("TABLE_TYPE"); if ("SYSTEM TABLE".equalsIgnoreCase(tableType)) { continue; } columnNames.add(tableName); } return columnNames; } catch (SQLException e) { throw new InternalErrorException(e); } }); } }
String tableName = toUpperCase(indexes.getString("PKTABLE_NAME"), Locale.US); if (!theTableName.equalsIgnoreCase(tableName)) { continue; tableName = toUpperCase(indexes.getString("FKTABLE_NAME"), Locale.US); if (!theForeignTable.equalsIgnoreCase(tableName)) { continue; fkName = toUpperCase(fkName, Locale.US); columnNames.add(fkName);
String tableName = toUpperCase(tables.getString("TABLE_NAME"), Locale.US); if (!theTableName.equalsIgnoreCase(tableName)) { continue;
/** * Retrieve all index names */ public static Set<String> getIndexNames(DriverTypeEnum.ConnectionProperties theConnectionProperties, String theTableName) throws SQLException { DataSource dataSource = Objects.requireNonNull(theConnectionProperties.getDataSource()); try (Connection connection = dataSource.getConnection()) { return theConnectionProperties.getTxTemplate().execute(t -> { DatabaseMetaData metadata; try { metadata = connection.getMetaData(); ResultSet indexes = metadata.getIndexInfo(connection.getCatalog(), connection.getSchema(), massageIdentifier(metadata, theTableName), false, true); Set<String> indexNames = new HashSet<>(); while (indexes.next()) { ourLog.debug("*** Next index: {}", new ColumnMapRowMapper().mapRow(indexes, 0)); String indexName = indexes.getString("INDEX_NAME"); indexName = toUpperCase(indexName, Locale.US); indexNames.add(indexName); } return indexNames; } catch (SQLException e) { throw new InternalErrorException(e); } }); } }
String tableName = toUpperCase(indexes.getString("TABLE_NAME"), Locale.US); if (!theTableName.equalsIgnoreCase(tableName)) { continue; String columnName = toUpperCase(indexes.getString("COLUMN_NAME"), Locale.US); if (!theColumnName.equalsIgnoreCase(columnName)) { continue;
public String toUpperCase(final Object target) { return StringUtils.toUpperCase(target, this.locale); }