Tony
Tony

Reputation: 61

Spring boot h2 database error getting driver

I'm trying to use h2 database in a springboot project, and i'm HikariDataSource, and i'm getting the following excepetion:

java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:h2:~/test
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:88) ~[HikariCP-2.4.7.jar:na]
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:298) ~[HikariCP-2.4.7.jar:na]
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:91) ~[HikariCP-2.4.7.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:101) ~[HikariCP-2.4.7.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:94) ~[HikariCP-2.4.7.jar:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProvide...:122) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at...

I think that my pom.xml and my configuration class are correct

url: jdbc:h2:~/test driverClassName: org.h2.Driver

Any clue on what i'm doing wrong?

Upvotes: 1

Views: 3631

Answers (2)

Luis Rocha
Luis Rocha

Reputation: 58

Set the driver class name in the configuration for the pool.

Upvotes: 0

Biswajit Debnath
Biswajit Debnath

Reputation: 43

Add driver in your pom.xml

<dependency>
 <groupId>com.h2database</groupId>
 <artifactId>h2</artifactId>
</dependency>

https://dzone.com/articles/integrate-h2-database-in-your-spring-boot-applicat

Upvotes: 2

Related Questions