Skip to content

Commit

Permalink
fix #88
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 31, 2016
1 parent c08be4c commit 7ecbd2a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public enum DatabaseType {

H2, MySQL, Oracle, SQLServer, DB2;
H2, MySQL, Oracle, SQLServer, DB2, PostgreSQL;

/**
* 获取数据库类型枚举.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private String getDatabaseProductName(final ShardingRule shardingRule) throws SQ
databaseProductName = ((MasterSlaveDataSource) each).getDatabaseProductName();
} else {
try (Connection connection = each.getConnection()) {
databaseProductName = connection.getMetaData().getDatabaseProductName();
databaseProductName = connection.getMetaData().getDatabaseProductName();
}
}
Preconditions.checkState(null == result || result.equals(databaseProductName), String.format("Database type inconsistent with '%s' and '%s'", result, databaseProductName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,41 @@ public final class SQLVisitorRegistry {
private static void registerSelectVistor() {
SELECT_REGISTRY.put(DatabaseType.H2, MySQLSelectVisitor.class);
SELECT_REGISTRY.put(DatabaseType.MySQL, MySQLSelectVisitor.class);
// TODO 其他数据库
// TODO 其他数据库先使用MySQL, 只能使用标准SQL
SELECT_REGISTRY.put(DatabaseType.Oracle, MySQLSelectVisitor.class);
SELECT_REGISTRY.put(DatabaseType.SQLServer, MySQLSelectVisitor.class);
SELECT_REGISTRY.put(DatabaseType.DB2, MySQLSelectVisitor.class);
SELECT_REGISTRY.put(DatabaseType.PostgreSQL, MySQLSelectVisitor.class);
}

private static void registerInsertVistor() {
INSERT_REGISTRY.put(DatabaseType.H2, MySQLInsertVisitor.class);
INSERT_REGISTRY.put(DatabaseType.MySQL, MySQLInsertVisitor.class);
// TODO 其他数据库
// TODO 其他数据库先使用MySQL, 只能使用标准SQL
INSERT_REGISTRY.put(DatabaseType.Oracle, MySQLInsertVisitor.class);
INSERT_REGISTRY.put(DatabaseType.SQLServer, MySQLInsertVisitor.class);
INSERT_REGISTRY.put(DatabaseType.DB2, MySQLInsertVisitor.class);
INSERT_REGISTRY.put(DatabaseType.PostgreSQL, MySQLInsertVisitor.class);
}

private static void registerUpdateVistor() {
UPDATE_REGISTRY.put(DatabaseType.H2, MySQLUpdateVisitor.class);
UPDATE_REGISTRY.put(DatabaseType.MySQL, MySQLUpdateVisitor.class);
// TODO 其他数据库
// TODO 其他数据库先使用MySQL, 只能使用标准SQL
INSERT_REGISTRY.put(DatabaseType.Oracle, MySQLUpdateVisitor.class);
INSERT_REGISTRY.put(DatabaseType.SQLServer, MySQLUpdateVisitor.class);
INSERT_REGISTRY.put(DatabaseType.DB2, MySQLUpdateVisitor.class);
INSERT_REGISTRY.put(DatabaseType.PostgreSQL, MySQLUpdateVisitor.class);
}

private static void registerDeleteVistor() {
DELETE_REGISTRY.put(DatabaseType.H2, MySQLDeleteVisitor.class);
DELETE_REGISTRY.put(DatabaseType.MySQL, MySQLDeleteVisitor.class);
// TODO 其他数据库
// TODO 其他数据库先使用MySQL, 只能使用标准SQL
INSERT_REGISTRY.put(DatabaseType.Oracle, MySQLDeleteVisitor.class);
INSERT_REGISTRY.put(DatabaseType.SQLServer, MySQLDeleteVisitor.class);
INSERT_REGISTRY.put(DatabaseType.DB2, MySQLDeleteVisitor.class);
INSERT_REGISTRY.put(DatabaseType.PostgreSQL, MySQLDeleteVisitor.class);
}

/**
Expand Down
1 change: 1 addition & 0 deletions sharding-jdbc-doc/content/post/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ weight = 1
### 功能提升

1. [ISSUE #82](https://github.com/dangdangdotcom/sharding-jdbc/issues/82) TableRule可传入dataSourceName属性,用于指定该TableRule对应的数据源
1. [ISSUE #88](https://github.com/dangdangdotcom/sharding-jdbc/issues/88) 放开对其他数据库的限制,可支持标准SQL, 对个性化分页等语句不支持

### 缺陷修正

Expand Down

0 comments on commit 7ecbd2a

Please sign in to comment.