|
2 | 2 |
|
3 | 3 | import com.google.common.util.concurrent.ThreadFactoryBuilder; |
4 | 4 | import com.mysql.cj.core.conf.PropertyDefinitions; |
5 | | -import com.mysql.cj.jdbc.MysqlDataSource; |
6 | 5 | import com.zaxxer.hikari.HikariConfig; |
7 | 6 | import com.zaxxer.hikari.HikariDataSource; |
| 7 | +import de.rwth.idsg.steve.SteveConfiguration; |
8 | 8 | import de.rwth.idsg.steve.service.DummyReleaseCheckService; |
9 | 9 | import de.rwth.idsg.steve.service.GithubReleaseCheckService; |
10 | 10 | import de.rwth.idsg.steve.service.ReleaseCheckService; |
@@ -58,24 +58,23 @@ public class BeanConfiguration implements WebMvcConfigurer { |
58 | 58 | * https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration |
59 | 59 | */ |
60 | 60 | private void initDataSource() { |
61 | | - MysqlDataSource ds = new MysqlDataSource(); |
| 61 | + SteveConfiguration.DB dbConfig = CONFIG.getDb(); |
| 62 | + |
| 63 | + HikariConfig hc = new HikariConfig(); |
62 | 64 |
|
63 | 65 | // set standard params |
64 | | - ds.setServerName(CONFIG.getDb().getIp()); |
65 | | - ds.setPort(CONFIG.getDb().getPort()); |
66 | | - ds.setDatabaseName(CONFIG.getDb().getSchema()); |
67 | | - ds.setUser(CONFIG.getDb().getUserName()); |
68 | | - ds.setPassword(CONFIG.getDb().getPassword()); |
| 66 | + hc.setJdbcUrl("jdbc:mysql://" + dbConfig.getIp() + ":" + dbConfig.getPort() + "/" + dbConfig.getSchema()); |
| 67 | + hc.setUsername(dbConfig.getUserName()); |
| 68 | + hc.setPassword(dbConfig.getPassword()); |
69 | 69 |
|
70 | 70 | // set non-standard params |
71 | | - ds.getModifiableProperty(PropertyDefinitions.PNAME_cachePrepStmts).setValue(true); |
72 | | - ds.getModifiableProperty(PropertyDefinitions.PNAME_prepStmtCacheSize).setValue(250); |
73 | | - ds.getModifiableProperty(PropertyDefinitions.PNAME_prepStmtCacheSqlLimit).setValue(2048); |
74 | | - ds.getModifiableProperty(PropertyDefinitions.PNAME_characterEncoding).setValue("utf8"); |
75 | | - ds.getModifiableProperty(PropertyDefinitions.PNAME_serverTimezone).setValue(CONFIG.getTimeZoneId()); |
76 | | - |
77 | | - HikariConfig hc = new HikariConfig(); |
78 | | - hc.setDataSource(ds); |
| 71 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_cachePrepStmts, true); |
| 72 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_useServerPrepStmts, true); |
| 73 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_prepStmtCacheSize, 250); |
| 74 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_prepStmtCacheSqlLimit, 2048); |
| 75 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_characterEncoding, "utf8"); |
| 76 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_serverTimezone, CONFIG.getTimeZoneId()); |
| 77 | + hc.addDataSourceProperty(PropertyDefinitions.PNAME_useSSL, true); |
79 | 78 |
|
80 | 79 | dataSource = new HikariDataSource(hc); |
81 | 80 | } |
|
0 commit comments