File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
APIJSON-Java-Server/APIJSONDemo-HikariCP/src/main/java/apijson/demo Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,13 @@ public class DemoSQLExecutor extends APIJSONSQLExecutor {
40
40
public Connection getConnection (SQLConfig config ) throws Exception {
41
41
// Log.d(TAG, "getConnection config.getDatasource() = " + config.getDatasource());
42
42
43
- Connection c = connectionMap .get (config .getDatabase ());
43
+ String key = config .getDatasource () + "-" + config .getDatabase ();
44
+ Connection c = connectionMap .get (key );
44
45
if (c == null || c .isClosed ()) {
45
46
try {
46
47
DataSource ds = DemoApplication .getApplicationContext ().getBean (DataSource .class );
47
48
// 另一种方式是 DruidConfig 初始化获取到 Datasource 后给静态变量 DATA_SOURCE 赋值: ds = DruidConfig.DATA_SOURCE.getConnection();
48
- connectionMap .put (config . getDatabase () , ds == null ? null : ds .getConnection ());
49
+ connectionMap .put (key , ds == null ? null : ds .getConnection ());
49
50
} catch (Exception e ) {
50
51
Log .e (TAG , "getConnection try { "
51
52
+ "DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class); .."
You can’t perform that action at this time.
0 commit comments