diff --git a/pom.xml b/pom.xml index 7790cbb2b68f9..eb88006f6a3df 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ 3.0.0 5.1.47 2.4.2 - 1.4.196 + 2.1.214 6.1.7.jre8-preview 3.4.2 diff --git a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE index fde2f2419ca84..63ccae14aff24 100644 --- a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE +++ b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/release-docs/LICENSE @@ -346,7 +346,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt. logback-classic 1.2.10: https://github.com/qos-ch/logback, EPL 1.0 logback-core 1.2.10: https://github.com/qos-ch/logback, EPL 1.0 mchange-commons-java 0.2.15: https://github.com/swaldman/mchange-commons-java, EPL 1.0 - h2 1.4.196: https://github.com/h2database/h2database, EPL 1.0 + h2 2.1.214: https://github.com/h2database/h2database, EPL 1.0 ======================================================================== MIT licenses diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoader.java index de53acf23ed98..bd7d6e2fdc897 100644 --- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoader.java +++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoader.java @@ -43,7 +43,7 @@ */ public final class H2SchemaMetaDataLoader implements DialectSchemaMetaDataLoader { - private static final String TABLE_META_DATA_NO_ORDER = "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS " + private static final String TABLE_META_DATA_NO_ORDER = "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=?"; private static final String ORDER_BY_ORDINAL_POSITION = " ORDER BY ORDINAL_POSITION"; @@ -52,17 +52,18 @@ public final class H2SchemaMetaDataLoader implements DialectSchemaMetaDataLoader private static final String TABLE_META_DATA_SQL_IN_TABLES = TABLE_META_DATA_NO_ORDER + " AND TABLE_NAME IN (%s)" + ORDER_BY_ORDINAL_POSITION; - private static final String INDEX_META_DATA_SQL = "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES" + private static final String INDEX_META_DATA_SQL = "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES" + " WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND TABLE_NAME IN (%s)"; - private static final String PRIMARY_KEY_META_DATA_SQL = "SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND PRIMARY_KEY = TRUE"; + private static final String PRIMARY_KEY_META_DATA_SQL = "SELECT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=?" + + " AND INDEX_TYPE_NAME = 'PRIMARY KEY'"; private static final String PRIMARY_KEY_META_DATA_SQL_IN_TABLES = PRIMARY_KEY_META_DATA_SQL + " AND TABLE_NAME IN (%s)"; - private static final String GENERATED_INFO_SQL = "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(S.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C" - + " RIGHT JOIN INFORMATION_SCHEMA.SEQUENCES S ON C.SEQUENCE_NAME=S.SEQUENCE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=?"; + private static final String GENERATED_INFO_SQL = "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(I.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C" + + " RIGHT JOIN INFORMATION_SCHEMA.INDEXES I ON C.TABLE_NAME=I.TABLE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=?"; - private static final String GENERATED_INFO_SQL_IN_TABLES = GENERATED_INFO_SQL + " AND TABLE_NAME IN (%s)"; + private static final String GENERATED_INFO_SQL_IN_TABLES = GENERATED_INFO_SQL + " AND C.TABLE_NAME IN (%s)"; @Override public Collection load(final DataSource dataSource, final Collection tables, final String defaultSchemaName) throws SQLException { @@ -104,11 +105,10 @@ private Map> loadColumnMetaDataMap(final Conn private ColumnMetaData loadColumnMetaData(final Map dataTypeMap, final ResultSet resultSet, final Collection primaryKeys, final Map tableGenerated) throws SQLException { String columnName = resultSet.getString("COLUMN_NAME"); - String typeName = resultSet.getString("TYPE_NAME"); + String dataType = resultSet.getString("DATA_TYPE"); boolean primaryKey = primaryKeys.contains(columnName); boolean generated = tableGenerated.getOrDefault(columnName, Boolean.FALSE); - // H2 database case sensitive is always true - return new ColumnMetaData(columnName, dataTypeMap.get(typeName), primaryKey, generated, true, true); + return new ColumnMetaData(columnName, dataTypeMap.get(dataType), primaryKey, generated, false, true); } private String getTableMetaDataSQL(final Collection tables) { @@ -151,9 +151,9 @@ private Map> loadTablePrimaryKeys(final Connection co preparedStatement.setString(2, "PUBLIC"); try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { - String columnName = resultSet.getString("COLUMN_NAME"); + String indexName = resultSet.getString("INDEX_NAME"); String tableName = resultSet.getString("TABLE_NAME"); - result.computeIfAbsent(tableName, k -> new LinkedList<>()).add(columnName); + result.computeIfAbsent(tableName, k -> new LinkedList<>()).add(indexName); } } } diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoaderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoaderTest.java index cb9e532c730f5..fa7ead8b9ff0e 100644 --- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoaderTest.java +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/H2SchemaMetaDataLoaderTest.java @@ -48,21 +48,21 @@ public void assertLoadWithoutTables() throws SQLException { DataSource dataSource = mockDataSource(); ResultSet resultSet = mockTableMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? " + "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? " + "ORDER BY ORDINAL_POSITION") .executeQuery()).thenReturn(resultSet); ResultSet indexResultSet = mockIndexMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND TABLE_NAME IN ('tbl')") + "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND TABLE_NAME IN ('tbl')") .executeQuery()) .thenReturn(indexResultSet); ResultSet primaryKeys = mockPrimaryKeysMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND PRIMARY_KEY = TRUE").executeQuery()).thenReturn(primaryKeys); + "SELECT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND INDEX_TYPE_NAME = 'PRIMARY KEY'").executeQuery()).thenReturn(primaryKeys); ResultSet generatedInfo = mockGeneratedInfoResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(S.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C RIGHT JOIN" - + " INFORMATION_SCHEMA.SEQUENCES S ON C.SEQUENCE_NAME=S.SEQUENCE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=?") + "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(I.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C RIGHT JOIN" + + " INFORMATION_SCHEMA.INDEXES I ON C.TABLE_NAME=I.TABLE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=?") .executeQuery()).thenReturn(generatedInfo); assertTableMetaDataMap(getDialectTableMetaDataLoader().load(dataSource, Collections.emptyList(), "sharding_db")); } @@ -72,22 +72,22 @@ public void assertLoadWithTables() throws SQLException { DataSource dataSource = mockDataSource(); ResultSet resultSet = mockTableMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? " + "SELECT TABLE_CATALOG, TABLE_NAME, COLUMN_NAME, DATA_TYPE, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? " + "AND TABLE_NAME IN ('tbl') ORDER BY ORDINAL_POSITION") .executeQuery()).thenReturn(resultSet); ResultSet indexResultSet = mockIndexMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND TABLE_NAME IN ('tbl')") + "SELECT TABLE_CATALOG, TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND TABLE_NAME IN ('tbl')") .executeQuery()).thenReturn(indexResultSet); ResultSet primaryKeys = mockPrimaryKeysMetaDataResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND PRIMARY_KEY = TRUE AND TABLE_NAME IN ('tbl')") + "SELECT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_CATALOG=? AND TABLE_SCHEMA=? AND INDEX_TYPE_NAME = 'PRIMARY KEY' AND TABLE_NAME IN ('tbl')") .executeQuery()) .thenReturn(primaryKeys); ResultSet generatedInfo = mockGeneratedInfoResultSet(); when(dataSource.getConnection().prepareStatement( - "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(S.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C" - + " RIGHT JOIN INFORMATION_SCHEMA.SEQUENCES S ON C.SEQUENCE_NAME=S.SEQUENCE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=? AND TABLE_NAME IN ('tbl')") + "SELECT C.TABLE_NAME TABLE_NAME, C.COLUMN_NAME COLUMN_NAME, COALESCE(I.IS_GENERATED, FALSE) IS_GENERATED FROM INFORMATION_SCHEMA.COLUMNS C" + + " RIGHT JOIN INFORMATION_SCHEMA.INDEXES I ON C.TABLE_NAME=I.TABLE_NAME WHERE C.TABLE_CATALOG=? AND C.TABLE_SCHEMA=? AND C.TABLE_NAME IN ('tbl')") .executeQuery()) .thenReturn(generatedInfo); assertTableMetaDataMap(getDialectTableMetaDataLoader().load(dataSource, Collections.singletonList("tbl"), "sharding_db")); @@ -113,7 +113,7 @@ private ResultSet mockTableMetaDataResultSet() throws SQLException { when(result.next()).thenReturn(true, true, false); when(result.getString("TABLE_NAME")).thenReturn("tbl"); when(result.getString("COLUMN_NAME")).thenReturn("id", "name"); - when(result.getString("TYPE_NAME")).thenReturn("int", "varchar"); + when(result.getString("DATA_TYPE")).thenReturn("int", "varchar"); when(result.getString("COLUMN_KEY")).thenReturn("PRI", ""); when(result.getString("EXTRA")).thenReturn("auto_increment", ""); when(result.getString("COLLATION_NAME")).thenReturn("utf8_general_ci", "utf8"); @@ -124,7 +124,7 @@ private ResultSet mockPrimaryKeysMetaDataResultSet() throws SQLException { ResultSet result = mock(ResultSet.class); when(result.next()).thenReturn(true, false); when(result.getString("TABLE_NAME")).thenReturn("tbl"); - when(result.getString("COLUMN_NAME")).thenReturn("id"); + when(result.getString("INDEX_NAME")).thenReturn("id"); return result; } @@ -156,8 +156,8 @@ private void assertTableMetaDataMap(final Collection schemaMetaD TableMetaData actualTableMetaData = schemaMetaDataList.iterator().next().getTables().iterator().next(); assertThat(actualTableMetaData.getColumns().size(), is(2)); Iterator columnsIterator = actualTableMetaData.getColumns().iterator(); - assertThat(columnsIterator.next(), is(new ColumnMetaData("id", 4, true, false, true, true))); - assertThat(columnsIterator.next(), is(new ColumnMetaData("name", 12, false, false, true, true))); + assertThat(columnsIterator.next(), is(new ColumnMetaData("id", 4, true, false, false, true))); + assertThat(columnsIterator.next(), is(new ColumnMetaData("name", 12, false, false, false, true))); assertThat(actualTableMetaData.getIndexes().size(), is(1)); Iterator indexesIterator = actualTableMetaData.getIndexes().iterator(); assertThat(indexesIterator.next(), is(new IndexMetaData("id"))); diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java index fbe2700f5aa35..040c66fcd3aa1 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptPreparedStatementTest.java @@ -164,7 +164,7 @@ public void assertSelectWithMetaData() throws SQLException { assertThat(metaData.getColumnCount(), is(2)); for (int i = 0; i < metaData.getColumnCount(); i++) { assertThat(metaData.getColumnLabel(1), is("id")); - assertThat(metaData.getColumnLabel(2), is("PWD")); + assertThat(metaData.getColumnLabel(2), is("pwd")); } } } @@ -219,7 +219,7 @@ public void assertSelectWithInOperator() throws SQLException { assertThat(metaData.getColumnCount(), is(2)); for (int i = 0; i < metaData.getColumnCount(); i++) { assertThat(metaData.getColumnLabel(1), is("id")); - assertThat(metaData.getColumnLabel(2), is("PWD")); + assertThat(metaData.getColumnLabel(2), is("pwd")); } } } @@ -232,8 +232,8 @@ public void assertSelectWithPlainColumnForContainsColumn() throws SQLException { assertThat(metaData.getColumnCount(), is(3)); for (int i = 0; i < metaData.getColumnCount(); i++) { assertThat(metaData.getColumnLabel(1), is("id")); - assertThat(metaData.getColumnLabel(2), is("PLAIN_PWD")); - assertThat(metaData.getColumnLabel(3), is("PLAIN_PWD2")); + assertThat(metaData.getColumnLabel(2), is("plain_pwd")); + assertThat(metaData.getColumnLabel(3), is("plain_pwd2")); } } } diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java index a2958da831035..9a300aae97c72 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/EncryptStatementTest.java @@ -131,7 +131,7 @@ public void assertSelectWithMetaData() throws SQLException { assertThat(metaData.getColumnCount(), is(2)); for (int i = 0; i < metaData.getColumnCount(); i++) { assertThat(metaData.getColumnLabel(1), is("id")); - assertThat(metaData.getColumnLabel(2), is("PWD")); + assertThat(metaData.getColumnLabel(2), is("pwd")); } } } diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java index 8305615aafd11..e7449eef8ed1b 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatementTest.java @@ -430,7 +430,7 @@ public void assertAddOnDuplicateKey() throws SQLException { preparedStatement.setString(8, status); preparedStatement.setString(9, updatedStatus); int result = preparedStatement.executeUpdate(); - assertThat(result, is(2)); + assertThat(result, is(4)); queryStatement.setInt(1, orderId); queryStatement.setInt(2, userId1); try (ResultSet resultSet = queryStatement.executeQuery()) { diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java index f944ee4159e4b..4e347be7757a0 100644 --- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java +++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatementTest.java @@ -58,7 +58,7 @@ public void assertGetGeneratedKeys() throws SQLException { generatedKeysResultSet = statement.getGeneratedKeys(); assertTrue(generatedKeysResultSet.next()); assertThat(generatedKeysResultSet.getLong(1), is(6L)); - assertFalse(statement.execute(String.format(sql, 1, 1, "init"), new String[]{"no"})); + assertFalse(statement.execute(String.format(sql, 1, 1, "init"), new String[]{"status"})); generatedKeysResultSet = statement.getGeneratedKeys(); assertTrue(generatedKeysResultSet.next()); assertThat(generatedKeysResultSet.getLong(1), is(7L)); diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java index 02f6747724e65..beeb66c069248 100644 --- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java +++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java @@ -139,7 +139,8 @@ private List getActualColumns(final Connection connection, final while (resultSet.next()) { DataSetColumn each = new DataSetColumn(); each.setName(resultSet.getString("COLUMN_NAME")); - each.setType(resultSet.getString("TYPE_NAME").toLowerCase()); + String typeName = resultSet.getString("TYPE_NAME"); + each.setType("CHARACTER VARYING".equals(typeName) ? "VARCHAR".toLowerCase() : typeName.toLowerCase()); result.add(each); } return result;