Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDBC driver type used in Hibernate

Assuming that I am using Hibernate for a Java web application talking to MySQL database, what is the driver type that Hibernate is using.

like image 400
oneworld Avatar asked Dec 12 '22 08:12

oneworld


2 Answers

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/J release is a JDBC type 4 compatible driver.

like image 187
BalusC Avatar answered Dec 14 '22 21:12

BalusC


<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

like image 21
aswininayak Avatar answered Dec 14 '22 20:12

aswininayak