[Logo]
Forums Register Login
UnsuppotedException..user must supply a jdbc connection
Hai am getting the above exception in hibernate
here is my code
TestClient.java::


import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.Session;
import org.hibernate.HibernateException;
import java.io.*;

public class TestClient

{
public static void main(String[] args)
{

Session session=null;

try
{
Configuration cfg=new Configuration();
Configuration cf=cfg.configure("hibernate.cfg.xml");
//create sessionfactory object
SessionFactory factory=cf.buildSessionFactory();
Session ses=factory.openSession();
//persistent logic
JavaBean jb=new JavaBean();
jb.setSno(101);
jb.setFname("aaa");
jb.setLname("bbb");
jb.setMail("s@gmail.com");

Transaction tx=ses.beginTransaction();
below jb is in persistent state
Integer idval=(Integer)ses.save(jb);
System.out.println("id value"+idval);
tx.commit();

ses.close();
factory.close();


}
catch(HibernateException e)
{
e.printStackTrace();
}
}
}
hibernate.cfg.xml::

<?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.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hbernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="hibernate.connection.username">system</property>
<property name="hibernate.connection.password">hai</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<mapping resource="emp.hbm.xml"/>
</session-factory>
</hibernate-configuration>

emp.hbm.xml::

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="JavaBean" table="employee3">
<id name="sno" column="SNO"/>
<property name="fname" column="FNAME"/>
<property name="lname" column="LNAME"/>
<property name="mail" column="MAIL"/>
</class>
</hibernate-mapping>


I am working in standalone apps
can anyone help me to sortout this problem

This thread has been viewed 920 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 24, 2018 16:06:13.