Hello all,
I am new to hibernate. I am creating some basic hibernate program to doing some insert into MySql database. The below is the main code I have written. Although I am closing the session after transaction and seeing that " Released JDBC connection" on console, I can see an inactive connection in the database after running the program.Everytime I am runnning the programm a new inactive connection is getting created in the database. I have to click "terminate" button in eclips console to stop that inactive session everytime.
Code:
[color=#404080]
Student s1=new Student();
s1.setName("Monaj");
s1.setRoll(1);
s1.setDate(new Date());
Configuration configuration=new Configuration().configure();
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
sessionFactory = configuration.configure().buildSessionFactory(serviceRegistry);
Session session=sessionFactory.openSession();
Transaction t1=session.beginTransaction();
session.save(s1);
t1.commit();
session.close();[/color]
Console output:-
15:29:08.476 [main] DEBUG o.h.e.j.i.LogicalConnectionImpl - Aggressively releasing JDBC connection
15:29:08.476 [main] DEBUG o.h.e.j.i.LogicalConnectionImpl - Releasing JDBC connection
15:29:08.476 [main] DEBUG o.h.e.j.i.LogicalConnectionImpl - Released JDBC connection
15:29:08.477 [main] DEBUG o.h.e.j.internal.JdbcCoordinatorImpl - HHH000420: Closing un-released batch
15:29:37.323 [pool-1-thread-1] DEBUG o.h.e.j.c.i.DriverManagerConnectionProviderImpl - Connection pool now considered primed; min-size will be maintainedHibernate Configuration:-
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.password">password</property>
<property name="connection.username">admin</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<property name="connection.release_mode">AFTER_TRANSACTION</property>
<property name="connection.autocommit">true</property>
Could anyone please help me on this.