【问题标题】:How to configure HikariCP with PostgreSQL如何使用 PostgreSQL 配置 HikariCP
【发布时间】:2017-01-25 05:35:48
【问题描述】:

我正在尝试在我的 Web 应用程序中将 HikariCP 与 PostgreSQL 集成,我正在使用 postgresql 驱动程序和这个 DataSource 类:org.postgresql.ds.PGSimpleDataSource 和我的休眠配置文件是这样的:

<property name ="hibernate.connection.provider_class"> com.zaxxer.hikari.hibernate.HikariConnectionProvider</property>
 <property name ="hibernate.hikari.dataSourceClassName"> org.postgresql.ds.PGSimpleDataSource</property>
 <property name ="hibernate.hikari.dataSource.url">jdbc:postgresql:// localhost:5432/database</property>
 <property name ="hibernate.hikari.dataSource.user">user</property>
 <property name ="hibernate.hikari.dataSource.password">passwd</property>
 <property name ="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
 <property name="hibernate.current_session_context_class">thread</property>

当我运行我的应用程序时,我遇到了这个异常:

org.hibernate.HibernateException: java.lang.RuntimeException: 目标类 org.postgresql.ds.PGSimpleDataSource 上不存在属性 url `

【问题讨论】:

  • 您为什么要通过PGSimpleDataSource 使用数据源? Hikari 不应该负责提供数据源吗?
  • 使用 Hibernate 提供的 org.hibernate.hikaricp.internal.HikariCPConnectionProvider,HikariCP 中的那个已经被弃用了。此外,使用 PostgreSQL 数据源,您不需要 URL,只需设置数据库名称即可。

标签: java postgresql hibernate jdbc hikaricp


【解决方案1】:

我阅读了有关此的相关信息,我所做的是使用 postgresql-9.4.1208 驱动程序和 hikaricp 2.4.6 替换版本。

【讨论】:

    猜你喜欢
    • 2018-10-17
    • 1970-01-01
    • 2018-12-26
    • 2014-01-20
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 2014-10-05
    • 1970-01-01
    相关资源
    最近更新 更多