Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Book</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="book.hbm.xml" />
Copy link

vahidsaneei commented Feb 25, 2018

thanks, but it is better that you set the hbm2ddl property

Copy link

Savotii commented Apr 16, 2018

Thanks a lot!

Copy link

Chinna14320 commented Apr 23, 2018


Copy link

Chinna14320 commented Apr 23, 2018

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.jdbc.ConnectionManager.openConnection(
at org.hibernate.jdbc.ConnectionManager.getConnection(
at org.hibernate.jdbc.JDBCContext.connection(
at org.hibernate.transaction.JDBCTransaction.begin(
at org.hibernate.impl.SessionImpl.beginTransaction(
at StoreData.main(
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql:localhost:3306/test
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(
at org.hibernate.jdbc.ConnectionManager.openConnection(
... 5 more
iam getting error like this can you help to learn hibernate

Copy link

RobertoBlanco84 commented Apr 26, 2018

Thanks a lot!

Copy link

GabSC commented Apr 27, 2018

Thank you!! :D

Copy link

Chandrakanth339 commented Aug 12, 2018

HI . Thank you for the configuration file. Small addition..
In case if we are using @entity annotation style of mapping + xml style of hibernate configuration, then, we can include the resource of that class as <mapping class="<FULLY_QUALIFIED_CLASSNAME_ANNOTATED_WITH_ENTITY>" instead of <mapping resource="<CONFIG_FILE_NAME_IN_src/main/resources>"

Thank You

Copy link

sk1ter commented Jan 1, 2019


Copy link

FromSi commented Mar 24, 2019


Copy link

deenjohn commented Apr 24, 2019


Copy link

swissiKarim commented Oct 22, 2019


Copy link

yahyafati commented Aug 30, 2020


Copy link

bykl61 commented Nov 29, 2020

teşekkür ederim:)

Copy link

ShridharMP commented Feb 20, 2021

why always hibernae.cfg,xml file will be for Mysql DB, is there any internal relationship between particular DB.

Copy link

metogpc commented Apr 7, 2021


Copy link

sarath123gorli commented Jan 1, 2022


above Book name where we get? why we give Book there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment