فهرست منبع

Fixed databsource resource allocation bug

Martijn Dashorst 9 سال پیش
والد
کامیت
8e3ca7d512
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      frameworks/Java/wicket/src/main/java/hellowicket/WicketApplication.java

+ 5 - 1
frameworks/Java/wicket/src/main/java/hellowicket/WicketApplication.java

@@ -85,8 +85,12 @@ public class WicketApplication extends WebApplication
 				InitialContext jndiContext = new InitialContext();
 				dataSource = (DataSource) jndiContext.lookup("java:comp/env/jdbc/hello_world");
 			}
-			else try(HikariDataSource ds = new HikariDataSource();)
+			else 
 			{
+				// allocating a resource for future use should not (auto) close the resource 
+				@SuppressWarnings("resource")
+				HikariDataSource ds = new HikariDataSource();
+
 				// use faster DataSource impl
 				ds.setJdbcUrl("jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true");
 				ds.setDriverClassName("com.mysql.jdbc.Driver");