File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HIbernate-UnsupportedoperationException

 
syruss kumar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • 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: 104
  • 0
  • Mark post as helpful
  • send pies
  • 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]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic