使用休眠模式找不到合适的驱动程序

时间:2018-10-25 10:18:34

标签: java hibernate jdbc

我正在用eclipse进行休眠项目。我将所有的jar文件(包括Mysql连接器jar)放在WEB-INF lib文件夹中。当我尝试运行代码时,它将引发错误。

例外

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.convert(SqlExceptionHelper.java:125)org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)org.hibernate.engine.jdbc.internal .LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)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.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1363)first.doPost(first.java:37)javax .servlet.http.HttpSer vlet.service(HttpServlet.java:661)javax.servlet.http.HttpServlet.service(HttpServlet.java:742)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

根本原因

java.sql.SQLException:找不到适用于jdbc:mysql:// localhost:3306 / sample java.sql / java.sql.DriverManager.getConnection(Unknown Source)java.sql / java.sql.DriverManager的驱动程序。 getConnection(未知源)org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:192)org.hibernate.internal.AbstractSessionImpl $ NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:278)org.hibernate.engine .jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java: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.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1363)first.doPost(first.java) :37)javax.ser vlet.http.HttpServlet.service(HttpServlet.java:661)javax.servlet.http.HttpServlet.service(HttpServlet.java:742)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52 < / p>

enter image description here

这是我的配置:

“-//休眠/休眠配置DTD 3.0 // EN”

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”>

<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>

Java

0 个答案:

没有答案