提交 2e7bcedb 编写于 作者: T terrymanu

Merge remote-tracking branch 'origin/1.5.4-SNAPSHOT' into 2.0.0.M1

......@@ -6,6 +6,7 @@
1. [ISSUE #362](https://github.com/dangdangdotcom/sharding-jdbc/issues/362) 读写分离使用PreparedStatement并未调用setParameter方法导致出错
1. [ISSUE #370](https://github.com/dangdangdotcom/sharding-jdbc/issues/370) 使用原生自增主键调用getGeneratedKeys出错
1. [ISSUE #375](https://github.com/dangdangdotcom/sharding-jdbc/issues/375) 路由至单节点的分页第二页以后的查询取不到数据
1. [ISSUE #379](https://github.com/dangdangdotcom/sharding-jdbc/issues/379) 使用Mybatis时框架调用Connection.getMetaData()时释放连接不正确
## 1.5.3
......
......@@ -46,6 +46,8 @@ public final class MasterSlaveConnection extends AbstractConnectionAdapter {
private final MasterSlaveDataSource masterSlaveDataSource;
private SQLType cachedSQLType;
/**
* Get database connections via SQL type.
*
......@@ -56,6 +58,7 @@ public final class MasterSlaveConnection extends AbstractConnectionAdapter {
* @throws SQLException SQL exception
*/
public Collection<Connection> getConnections(final SQLType sqlType) throws SQLException {
cachedSQLType = sqlType;
Map<String, DataSource> dataSources = SQLType.DDL == sqlType ? masterSlaveDataSource.getAllDataSources() : masterSlaveDataSource.getDataSource(sqlType).toMap();
Collection<Connection> result = new LinkedList<>();
for (Entry<String, DataSource> each : dataSources.entrySet()) {
......@@ -74,7 +77,7 @@ public final class MasterSlaveConnection extends AbstractConnectionAdapter {
@Override
public DatabaseMetaData getMetaData() throws SQLException {
return masterSlaveDataSource.getDataSource(SQLType.DML).getDataSource().getConnection().getMetaData();
return getConnections(null == cachedSQLType ? SQLType.DML : cachedSQLType).iterator().next().getMetaData();
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册