Skip to content

Instantly share code, notes, and snippets.

@yusufcakmak
Last active January 26, 2024 07:43
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save yusufcakmak/aefef12a7fe4518043ec to your computer and use it in GitHub Desktop.
Save yusufcakmak/aefef12a7fe4518043ec to your computer and use it in GitHub Desktop.
<?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>
<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" />
</session-factory>
</hibernate-configuration>
@vahidsaneei
Copy link

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

@Savotii
Copy link

Savotii commented Apr 16, 2018

Thanks a lot!

@Chinna14320
Copy link

``

@Chinna14320
Copy link

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(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at StoreData.main(StoreData.java:16)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql:localhost:3306/test
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
... 5 more
iam getting error like this can you help to learn hibernate

@RobertoBlanco84
Copy link

Thanks a lot!

@GabSC
Copy link

GabSC commented Apr 27, 2018

Thank you!! :D

@Chandrakanth339
Copy link

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

@sk1ter
Copy link

sk1ter commented Jan 1, 2019

Thanks!!

@FromSi
Copy link

FromSi commented Mar 24, 2019

Thanks!

@deenjohn
Copy link

THANKS

@swissiKarim
Copy link

Thanks!

@yahyafati
Copy link

Thanks

@bykl61
Copy link

bykl61 commented Nov 29, 2020

teşekkür ederim:)

@ShridharMP
Copy link

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

@metogpc
Copy link

metogpc commented Apr 7, 2021

teşekkürler

@sarath123gorli
Copy link

jdbc:mysql://localhost:3306/Book

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

@Mechatron00
Copy link

👍👍👍Thanks

@ugurhdml
Copy link

thanks

@ElronAlp
Copy link

ElronAlp commented Dec 5, 2022

thanks

@thundergokhan
Copy link

Thank you!!!

@hanmantholgir
Copy link

thanks

@Y-S-A-byte
Copy link

Thanks!

@Tulat2002
Copy link

thanks

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