Database connection pool[Hikari] initialize error

后端 未结 2 1208
温柔的废话
温柔的废话 2021-01-13 17:51

I am trying to configure HikariCP for my web application. I am not using any frameworks, it is a plain simple java web app. When I tried to establish a connection through no

相关标签:
2条回答
  • 2021-01-13 18:14

    I was hitting the same problem, and I just figured it out.

    I'm on a Mac, and somehow I had postgresql-9.0-802.jdbc3.jar installed in my /Library/Java/Extensions directory. DriverManager would pick this up as the preferred way of connecting to a jdbc:posgresql:// URL. It's a JDBC3 driver, so there's no isValid method.

    Even when I put a JDBC4 Driver on my classpath, whether that was org.prosgreql.Driver or com.impossibl.postgres.jdbc.PGDriver, the JDBC3 driver would supersede it.

    So I deleted /Library/Java/Extensions/postgresql* and all is well.

    0 讨论(0)
  • 2021-01-13 18:25

    Actually I got the answer, Hikari needs to set a connection test query, if thats done JDBC4 isValid will not get called.

    so just by adding property, I was able to make it work.

    mConfig.setConnectionTestQuery("show tables");
    
    0 讨论(0)
提交回复
热议问题