-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Not able to obtain connection
PostPosted: Thu Dec 15, 2005 9:11 am 
Newbie

Joined: Tue Nov 29, 2005 6:33 am
Posts: 6
Error Stack:
Code:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.HibernateException: Not able to obtain connection
   at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:117)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
   at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:169)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2047)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2426)
   at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:877)
   at revised.Main.main(Main.java:30)

IDE :Exadel studio pro 2.5 & MySQL 4

Database Schema
1.Logindetails(userid,password).
2.Psersonaldetails(userid,name)-'userid' is a foregien key ref .of 'logindetails'.

Mapping file 'logindetails':

Code:
<?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 package="revised">
  <class name="Logindetails" table="logindetails" optimistic-lock="none">
    <id name="userId" type="string" unsaved-value="null" column="UserId" length="40">
      <generator class="hilo"/>
    </id>
    <property name="password" type="string" column="Password" length="40"/>
    <one-to-one name="personaldetails" entity-name="revised.Personaldetails" cascade="save-update" foreign-key="personaldetails_ibfk_1" property-ref="userIdPersonal"/>
  </class>
</hibernate-mapping>


Mapping file personaldetails
Code:
<?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 package="revised">
  <class name="Personaldetails" table="personaldetails" optimistic-lock="none">
    <id name="uniq" type="integer" unsaved-value="null" column="uniq">
      <generator class="assigned"/>
    </id>
    <property name="name" type="string" column="Name" length="40"/>
    <many-to-one name="userIdPersonal" entity-name="revised.Logindetails" cascade="save-update" foreign-key="personaldetails_ibfk_1">
      <column name="UserId_Personal" unique="true" index="IDX_personalDetails1" length="40"/>
    </many-to-one>
  </class>
</hibernate-mapping>


My Main Class file:
Code:
package revised;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.Transaction;
import revised.Personaldetails;

public class Main {

   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      Session session=null;
      try
      {
            Configuration cfg=new Configuration();
            cfg.configure();
            SessionFactory factory = cfg.buildSessionFactory();
            session=factory.openSession();
            Transaction tx=session.beginTransaction();
            Personaldetails ps=new Personaldetails();
            ps.setUniq(new Integer(10));
            ps.setUserIdPersonal(ps.getUserIdPersonal());
            ps.setName("deva");
            tx.commit();
            session.save(ps);
            session.flush();
            session.close();
            System.out.println("Completed");
            
      }
         catch(Exception e)
         {
            e.printStackTrace(System.out);
            
         }
   }

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.