HIbernate Configuration for Mysql Server in Maven project

Configuration Hibernate for Mysql in Maven project:

in pom.xml:

dependency For mysql server
<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.48</version>
  </dependency>
     
Hibernate dependecies:
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.10.Final</version>
 </dependency>
       
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.1.0.Final</version>
</dependency>

we add hibernate.cfg.xml document in Other Sources->src/main/resources

in hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <!-- JDBC Database connection settings -->

        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

        <property name="connection.url">jdbc:mysql://localhost:3306/hiberEx1?useSSL=false</property>

        <property name="connection.username">root</property>

        <property name="connection.password">root12345</property>

        <!-- JDBC connection pool settings ... using built-in test pool -->

        <property name="connection.pool_size">1</property>

        <!-- Select our SQL dialect -->

        <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

        <!-- Echo the SQL to stdout -->

        <property name="show_sql">true</property>

        <!-- Set the current session context -->

        <property name="current_session_context_class">thread</property>

        <!-- Drop and re-create the database schema on startup -->

        <property name="hbm2ddl.auto">create-drop</property>

        <!-- dbcp connection pool configuration -->

        <property name="hibernate.dbcp.initialSize">5</property>

        <property name="hibernate.dbcp.maxTotal">20</property>

        <property name="hibernate.dbcp.maxIdle">10</property>

        <property name="hibernate.dbcp.minIdle">5</property>

        <property name="hibernate.dbcp.maxWaitMillis">-1</property>


    </session-factory>
</hibernate-configuration>









Comments

Popular posts from this blog

Installation instructions for some programs on linux ubuntu

Hibernate and Application Performance

timezone ile bagli Jackson deserializableda problem