Skip to content

Commit f78cdc3

Browse files
authored
解决依赖 APIJSON 4.7.2 + 时对接不上连接池
1 parent 3b05720 commit f78cdc3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

APIJSON-Java-Server/APIJSONDemo-Druid/src/main/java/apijson/demo/DemoSQLExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public class DemoSQLExecutor extends APIJSONSQLExecutor {
3434
public Connection getConnection(SQLConfig config) throws Exception {
3535
// Log.d(TAG, "getConnection config.getDatasource() = " + config.getDatasource());
3636

37-
Connection c = connectionMap.get(config.getDatabase());
37+
String key = config.getDatabase() + "-" + config.getDatasource();
38+
Connection c = connectionMap.get(key);
3839
if (c == null || c.isClosed()) {
3940
try {
4041
DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class);
4142
// 另一种方式是 DruidConfig 初始化获取到 Datasource 后给静态变量 DATA_SOURCE 赋值: ds = DruidConfig.DATA_SOURCE.getConnection();
42-
connectionMap.put(config.getDatabase(), ds == null ? null : ds.getConnection());
43+
connectionMap.put(key, ds == null ? null : ds.getConnection());
4344
} catch (Exception e) {
4445
Log.e(TAG, "getConnection try { "
4546
+ "DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class); .."

0 commit comments

Comments
 (0)