Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data not inserting into oracle database?

 
Mallik Avula
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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("deepak_38@yahoo.com");
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
 
Halcon Guatemala
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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
 
David Madouros
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
HI everybody
thanks for your great help
i got it

Mallik
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic