Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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

This comment has been minimized.

Copy link

commented Feb 25, 2018

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

@Savotii

This comment has been minimized.

Copy link

commented Apr 16, 2018

Thanks a lot!

@Chinna14320

This comment has been minimized.

Copy link

commented Apr 23, 2018

``

@Chinna14320

This comment has been minimized.

Copy link

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(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

This comment has been minimized.

Copy link

commented Apr 26, 2018

Thanks a lot!

@GabSC

This comment has been minimized.

Copy link

commented Apr 27, 2018

Thank you!! :D

@Chandrakanth339

This comment has been minimized.

Copy link

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

@javlonbek-sharipov

This comment has been minimized.

Copy link

commented Jan 1, 2019

Thanks!!

@FromSi

This comment has been minimized.

Copy link

commented Mar 24, 2019

Thanks!

@deenjohn

This comment has been minimized.

Copy link

commented Apr 24, 2019

THANKS

@swissiKarim

This comment has been minimized.

Copy link

commented Oct 22, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.