我正在尝试在 postgresql 中使用 HikariCP,但在任何地方都找不到 postgresql 的配置。
请给我指出带有 HikariCP 的 postgresql 的任何示例或任何相同的配置教程。
我尝试像下面那样使用它,但它不起作用,然后我意识到它是为 MySQL 设计的
public static DataSource getDataSource()
{
if(datasource == null)
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost/test");
config.setUsername("root");
config.setPassword("password");
config.setMaximumPoolSize(10);
config.setAutoCommit(false);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
datasource = new HikariDataSource(config);
}
return datasource;
}
你有例子HikariCP 配置 https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby维基页面
Properties props = new Properties();
props.setProperty("dataSourceClassName", "org.postgresql.ds.PGSimpleDataSource");
props.setProperty("dataSource.user", "test");
props.setProperty("dataSource.password", "test");
props.setProperty("dataSource.databaseName", "mydb");
props.put("dataSource.logWriter", new PrintWriter(System.out));
HikariConfig config = new HikariConfig(props);
HikariDataSource ds = new HikariDataSource(config);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)