java Hibernate中使用的JDBC驱动类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7876282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JDBC driver type used in Hibernate
提问by oneworld
Assuming that I am using Hibernate for a Java web application talking to MySQL database, what is the driver type that Hibernate is using.
假设我将 Hibernate 用于与 MySQL 数据库通信的 Java Web 应用程序,那么 Hibernate 使用的驱动程序类型是什么。
回答by BalusC
Hibernate won't pick a specific JDBC driver type by itself. It depends all on the JDBC driver class you're providing yourself and the JRE version of the runtime environment. JDBC type 4 is introduced in Java 1.6 and the latest MySQL Connector/Jrelease is a JDBC type 4 compatible driver.
Hibernate 不会自行选择特定的 JDBC 驱动程序类型。这完全取决于您自己提供的 JDBC 驱动程序类和运行时环境的 JRE 版本。JDBC type 4 是在 Java 1.6 中引入的,最新的MySQL Connector/J版本是一个 JDBC type 4 兼容的驱动程序。
回答by aswininayak
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/databaseName</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hbm2ddl.auto">update</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">false</property>
</session-factory>
You should add these in your configuration file. Add the mysql-connector-java-5.1.0-bin.jar file to your classpath. Then try to run
您应该将这些添加到您的配置文件中。将 mysql-connector-java-5.1.0-bin.jar 文件添加到您的类路径中。然后尝试运行
回答by Shivan Dragon
driverClassName="com.mysql.jdbc.Driver"
And you need the actual driver jar which you can get from here:
并且您需要可以从此处获取的实际驱动程序 jar:
回答by Yagnesh Agola
Its depends on the jar file which you are provide for JDBC connection for MySql or otther database.
它取决于您为 MySql 或其他数据库的 JDBC 连接提供的 jar 文件。