Я работал над проектом гибернации в Eclipse.Я поместил все файлы jars, включая jar коннектора Mysql, в папку lib WEB-INF.Когда я пытаюсь запустить код, он выдает ошибку.
Исключение
org.hibernate.exception.JDBCConnectionException: Не удалось открыть соединение org.hibernate.exception.internal.SQLStateConversionDelegate.convert (SQLStateConversionDelegate.java:131) org.hibernate.exception.internal.StandardSQLExceptionConverter.convert (StandardSQLExceptionConverter.java:49) org.hibernate.engine.jdbc.spi.SqlExceptionHelper.conava.hl. org.h5.engine.jdbc.spi.SqlExceptionHelper.convert (SqlExceptionHelper.java:110) org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection (LogicalConnectionImpl.java:304) org.hibernate.lic.Connect(LogicalConnectionImpl.java:169) org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin (JdbcTransaction.java:67) org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin1.java org..hibernate.internal.SessionImpl.beginTransaction (SessionImpl.java:1363) first.doPost (first.java:37) javax.servlet.http.HttpServlet.service (HttpServlet.java:661) javax.servlet.http.HttpServlet.service (HttpServlet)org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52)
Основная причина
java.sql.SQLException: Не найдено подходящего драйверадля jdbc: mysql: // localhost: 3306 / sample java.sql / java.sql.DriverManager.getConnection (неизвестный источник) java.sql / java.sql.DriverManager.getConnection (неизвестный источник) org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection (DriverManagerConnectionProviderImpl.java:192) org.hibernate.internal.AbstractSessionImpl $ NonContextualJdbcConnectionAccess.obtainConnection (AbstractSessionImpl.jnene.Ign.IvConnect.j.297) org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection (LogicalConnectionImpl.java:169) org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin (JdbcTransaction.java:67) org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin (AbstractTransactionImpl.java:160) org.hibernateIl.SessionImpl.java:1363) first.doPost (first.java:37) javax.servlet.http.HttpServlet.service (HttpServlet.java:661) javax.servlet.http.HttpServlet.service (HttpServlet.java:7: 7).apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52
Вот моя конфигурация:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="factory">
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">jdbc:mysql://localhost:3306/sample</property>
<property name="connection.username">
root
</property>
<property name="connection.password">
root
</property>
<property name="connection.pool_size">5</property>
<!-- SQL dialect -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<!-- Echo all executed SQL to stdout -->
<property name="hbm2ddl.auto">update</property>
<mapping class="user" />
</session-factory>
</hibernate-configuration>