使用Hikaricp正确设置Jaybird/Firebird DataSource



我正在尝试使用Spring Data JPA,Hibernate和Hikaricp Connection池在Windows上成功建立一个成功的连接。我已经可以在其他符合JDBC的DB(H2,Derby,MySQL等(上正确运行所有内容

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.application.Application: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
    at com.application.Application.main(Application.java:43)
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:267)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:231)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:858)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 11 more
Caused by: org.hibernate.HibernateException: java.lang.RuntimeException: Property url does not exist on target class org.firebirdsql.ds.FBSimpleDataSource

这是我的春季应用程序的摘录。

spring.jpa.properties.javax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider
spring.jpa.properties.hibernate.hikari.dataSourceClassName=org.firebirdsql.ds.FBSimpleDataSource
spring.jpa.properties.hibernate.hikari.dataSource.url=jdbc:firebirdsql:server:/db/test123.GDB?charSet=UTF-8&amp;roleName=USER;
spring.jpa.properties.hibernate.hikari.dataSource.user=SYSDBA
spring.jpa.properties.hibernate.hikari.dataSource.password=password
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.FirebirdDialect
spring.jpa.properties.hibernate.hikari.minimumIdle=5
spring.jpa.properties.hibernate.hikari.maximumPoolSize=10
spring.jpa.properties.hibernate.hikari.idleTimeout=30000
spring.jpa.properties.hibernate.connection.handling_mode=delayed_acquisition_and_hold
spring.jpa.properties.hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider

我已经使用了似乎实现Javax.sql.datasource的Spring.jpa.jpa.properties.hibernate.hikari.hikari.datasourceclassname属性的其他一些Firebird类测试>

note :此答案涉及Spring Boot中的非标准配置;正常配置应通过spring.datasource.*属性完成(请参阅Spring Boot文档中的SQL数据库(。

dataSource下的HikarICP配置属性必须与目标数据源上可用的属性匹配,并且org.firebirdsql.ds.FBSimpleDataSource类没有属性url(如错误; em quot 报道'属性URL不存在于目标类org.fire.fire.firebirdsql上.ds.fbsimpledatasource" (

有关可用属性列表,请参见org.firebirdsql.ds.FBSimpleDataSource Javadoc。具体来说,您需要配置databasecharSetroleName

spring.jpa.properties.hibernate.hikari.dataSource.database=server:/db/test123.GDB
spring.jpa.properties.hibernate.hikari.dataSource.charSet=UTF-8
spring.jpa.properties.hibernate.hikari.dataSource.roleName=USER

必须在数据源上明确设置连接属性:您无法在database属性中提供这些属性(本质上是没有jdbc:firebirdsql:前缀的JDBC URL,而没有属性(。

(。

我创建了改进票JDBC-521来添加url(或可能是jdbcUrl(属性,该属性接受了未来版本中的完整JDBC URL。


对于感兴趣的人,请参见Hikaricp连接池上的后续讨论,无法连接到Firebird DataSource

相关内容

  • 没有找到相关文章

最新更新