I am trying to develop some servlets but I have not been successful at fetching my data from mysql database. I keep getting this error
Code:
ERROR: org.hibernate.TransactionException: Transaction not successfully started
This error was caused by the following line of code.
Code:
NewHibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
I have the following in my hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/mydatabase</property>
<property name="hibernate.connection.username">myusername</property>
<property name="hibernate.connection.password">mypassword</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<mapping resource="com/nnews/table1.hbm.xml"/>
<mapping resource="com/nnews/table2.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I have battled with this for the whole week and I need some bit of direction.