Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HIbernate-UnsupportedoperationException

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have created a simple java application with hibernate. while i am trying to execute i got this error

Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection

I have added these jars with my application.
1.hibernate3.jar
2.hsqldb.jar
3.jta.jar
4.commons-logging.jar
5.cglib.jar
6.commons-beanutils.jar
7.commons-collections.jar
8.commons-chain.jar
9.commons-dbcp.jar
10.odbc.jar
11.mysql-connector-java-5.0.jar
12.commons-digester.jar
13.commons-lang.jar
13.dom.jar


Can anyone help me to resolve this error.

Thanks in advance
 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my UserLoginDAO
code] package com.DAO;

import java.awt.List;

import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import com.VO.UserLogin;

public class UserLoginDAO {
configuration config;
public UserLoginDAO(){
config=configuration.getConfiguration();

}
public java.util.List getUser() {
java.util.List userList;
Session session=config.getSession();
Transaction tx=(Transaction) session.beginTransaction();
Criteria userCriteria=session.createCriteria(UserLogin.class);
userCriteria.add(Restrictions.like("username",new String("Navin")));
userList=userCriteria.list();
try {
tx.commit();
} catch (SecurityException e) {

e.printStackTrace();
} catch (IllegalStateException e) {

e.printStackTrace();
} catch (RollbackException e) {

e.printStackTrace();
} catch (HeuristicMixedException e) {

e.printStackTrace();
} catch (HeuristicRollbackException e) {

e.printStackTrace();
} catch (SystemException e) {

e.printStackTrace();
}
UserLogin user=(UserLogin) userList.get(0);
System.out.println("UserName :"+user.getUsername());
System.out.println("Password :"+user.getPassword());
return userList;

}
public static void main(String[] args) {
new UserLoginDAO().getUser();
}

}

This is my configuration class

package com.DAO;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class configuration {
private static configuration config;
private configuration(){

}
public static configuration getConfiguration(){
if(config ==null){
synchronized (configuration.class) {
if(config==null)
config=new configuration();

}
}
return config;
}

public Session getSession(){
SessionFactory factory=new Configuration().configure().buildSessionFactory();
Session session=factory.openSession();
return session;
}

}
This is my 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="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="Connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="Connection.Url">jdbc:mysql/192.168.0.112:3306/navin</property>
<property name="username">root</property>
<property name="password"></property>
<property name="pool_size">5</property>
<property name="showsql">true</property>

<mapping resource="com/mapping/UserLogin.hbm.xml"/>
</session-factory>
</hibernate-configuration>
[/code]
 
Well THAT's new! Comfort me, reliable tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic