File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
APIJSON-Java-Server/APIJSONDemo-Druid/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 @@ -34,12 +34,13 @@ public class DemoSQLExecutor extends APIJSONSQLExecutor {
34
34
public Connection getConnection (SQLConfig config ) throws Exception {
35
35
// Log.d(TAG, "getConnection config.getDatasource() = " + config.getDatasource());
36
36
37
- Connection c = connectionMap .get (config .getDatabase ());
37
+ String key = config .getDatabase () + "-" + config .getDatasource ();
38
+ Connection c = connectionMap .get (key );
38
39
if (c == null || c .isClosed ()) {
39
40
try {
40
41
DataSource ds = DemoApplication .getApplicationContext ().getBean (DataSource .class );
41
42
// 另一种方式是 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 ());
43
44
} catch (Exception e ) {
44
45
Log .e (TAG , "getConnection try { "
45
46
+ "DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class); .."
You can’t perform that action at this time.
0 commit comments