Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Hibernate Basics Persisting Data with Hibernate Saving Data with Hibernate

for MYSQL (it workd )

to connect to MySQL server in hibernate.cj.xml

<hibernate-configuration>
    <session-factory>
        <!-- Database connection setting -->
        <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/nabil</property>
         <property name = "connection.username">root</property>
        <property name = "connection.password">root</property>
        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

        <!-- Update the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

        <!-- Show the queries prepared by Hibernate -->
        <property name="show_sql">true</property>

        <!-- Names the annotated entity classes -->
        <mapping class="com.example.model.Contact" />
    </session-factory>
</hibernate-configuration>

and in build.gradel

dependencies {

    compile 'org.hibernate:hibernate-core:5.4.31.Final'

    compile 'mysql:mysql-connector-java:8.0.24'
}