Skip to content

Commit cd83f50

Browse files
author
iceewei
committed
获取连接的key增加datasource维度
1 parent 7b6ef60 commit cd83f50

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

APIJSONORM/build.sh

Whitespace-only changes.

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,13 @@ public PreparedStatement setArgument(@NotNull SQLConfig config, @NotNull Prepare
732732
@NotNull
733733
@Override
734734
public Connection getConnection(@NotNull SQLConfig config) throws Exception {
735-
connection = connectionMap.get(config.getDatabase());
735+
String connectionKey = config.getDatasource() + "-" + config.getDatabase()
736+
connection = connectionMap.get(connectionKey);
736737
if (connection == null || connection.isClosed()) {
737738
Log.i(TAG, "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
738739
// PostgreSQL 不允许 cross-database
739740
connection = DriverManager.getConnection(config.getDBUri(), config.getDBAccount(), config.getDBPassword());
740-
connectionMap.put(config.getDatabase(), connection);
741+
connectionMap.put(connectionKey, connection);
741742
}
742743

743744
int ti = getTransactionIsolation();

0 commit comments

Comments
 (0)