wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes UnsuppotedException..user must supply a jdbc connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "UnsuppotedException..user must supply a jdbc connection" Watch "UnsuppotedException..user must supply a jdbc connection" New topic
Author

UnsuppotedException..user must supply a jdbc connection

anjali thota
Greenhorn

Joined: May 09, 2012
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UnsuppotedException..user must supply a jdbc connection