File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/main/java/com/btk5h/skriptdb/skript Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 44
55import org .bukkit .event .Event ;
66
7+ import java .util .HashMap ;
8+ import java .util .Map ;
9+
710import ch .njol .skript .Skript ;
811import ch .njol .skript .lang .Expression ;
912import ch .njol .skript .lang .ExpressionType ;
@@ -30,6 +33,8 @@ public class ExprDataSource extends SimpleExpression<HikariDataSource> {
3033 ExpressionType .COMBINED , "[the] data(base|[ ]source) [(of|at)] %string%" );
3134 }
3235
36+ private static Map <String , HikariDataSource > connectionCache = new HashMap <>();
37+
3338 private Expression <String > url ;
3439
3540 @ Override
@@ -43,9 +48,15 @@ protected HikariDataSource[] get(Event e) {
4348 jdbcUrl = "jdbc:" + jdbcUrl ;
4449 }
4550
51+ if (connectionCache .containsKey (jdbcUrl )) {
52+ return new HikariDataSource []{connectionCache .get (jdbcUrl )};
53+ }
54+
4655 HikariDataSource ds = new HikariDataSource ();
4756 ds .setJdbcUrl (jdbcUrl );
4857
58+ connectionCache .put (jdbcUrl , ds );
59+
4960 return new HikariDataSource []{ds };
5061 }
5162
You can’t perform that action at this time.
0 commit comments