• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

data not inserting into oracle database?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends
i came out of last posted query
i can able run the program but in database no records found
this is my java file
------------------------------
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import java.io.*;

public class FirstExample {
public static void main(String[] args) {
Session session = null;
try{

SessionFactory sessionFactory =new Configuration().configure(new File("hibernate.cfg.xml")).buildSessionFactory();

System.out.println("Inserting Record");
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("[email protected]");
session.save(contact);
System.out.println("Done");

}catch(Exception e){
System.out.println(e.getMessage());
}finally{
session.flush();
session.close();
}
}
}

-----------------------------------
why this is happening, let me know how to solve
any help greatly cherished
Mallik
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mallik, can you explain us, how are you adding your mapping resource? is it in your hibernate.cfg.xml? are you indicating the path of your mapping resource from classpath?

Thanks in advance
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that quite simply you are just missing your transaction calls. My understanding is that you need to begin and commit/rollback a transaction anytime you save or update.


[ March 29, 2007: Message edited by: David Madouros ]
 
Mallik Avula
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI everybody
thanks for your great help
i got it

Mallik
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic