Project vaadin + h2 + hibernate + tomcat trying to access the database, but at the configuration stage gives an error

private static SessionFactory buildSessionFactory (Class paramClass) { return new Configuration() .configure("hibernate.cfg.xml") .addAnnotatedClass(paramClass) .buildSessionFactory(); } 

apparently, somehow connected with the wrong jdbc: url

 ##URL for connection to DB hibernate.connection.url = jdbc:h2:tcp://localhost:8080/~/public 

Errors:

 org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] ... Caused by: org.hibernate.exception.JDBCConnectionException: Error calling DriverManager#getConnection ... Caused by: java.sql.SQLException: No suitable driver found for jdbc:h2:tcp://localhost:8080/~/public 

The problem is not exactly that there is no PUBLIC database, as migrations through flyway work correctly

Apparently, I do not understand something in the very foundation of interaction with the database, because no matter how I tried to google it I did not find the solution.

  • Have you tried to translate the error "No suitable driver found for"? - Sergey Gornostaev
  • so the driver has logs: org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user = sa, password = ****, driver = org.h2.Driver} - Armand
  • although here is the line: org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [null] at URL [jdbc: h2: tcp: // localhost: 8080 / ~ / public] And how do you connect the driver? - Armand

1 answer 1

Download the jdbc driver , copy it to the lib directory of the Tomcat server. This should solve the problem.