Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Bean
- public DataSource ds() {
- HikariConfig hc = new HikariConfig();
- hc.setJdbcUrl("jdbc:mysql://localhost(lub adres serwera/nazwa)");
- hc.addDataSourceProperty("serverName", "nazwa_serwera");
- hc.addDataSourceProperty("databaseName", "nazwa_bazy");
- hc.addDataSourceProperty("user", "nazwa_uzytkownika");
- hc.addDataSourceProperty("password", "haslo");
- hc.setDriverClassName("com.mysql.jdbc.Driver");
- //te nizej sa zwykle niepotrzebne, dotyczą struktury samej bazy i pamięci
- hc.addDataSourceProperty("cachePrepStmts", "true");
- hc.addDataSourceProperty("prepStmtCacheSize", "250");
- hc.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
- hc.addDataSourceProperty("useUnicode", "yes");
- hc.addDataSourceProperty("characterEncoding", "utf8");
- return new HikariDataSource(hc);
- }
- przykładowe dependencje do springa
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.39</version>
- </dependency>
- <dependency>
- <groupId>com.zaxxer</groupId>
- <artifactId>HikariCP</artifactId>
- <version>2.6.1</version>
- <scope>compile</scope>
- </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement