Sign in to follow this  
Followers 0
HarrySeah

JavaEE how to insert new record on database

3 posts in this topic

hi , im try to do the java web to connect with managed bean and connect to the javaDB (entity) class

 

i trying to insert the record in the database but ....fail....

 

public void createUser(){

 

Booking book = new Booking();
book.setLessonno(this.l_id);
book.setCustomername(strName);
book.setCustomerphone(strPhone);
try {
utx.begin();
em.persist(book);
utx.commit();
} catch (Exception e) {
throw new RuntimeException(e);
}

 

}

 

this come out a error ....

java.lang.UnsupportedOperationException: Not supported yet.

 

 

public void updateDB(){

EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("testTrainingPU");
EntityManager entitymanager = emfactory.createEntityManager();
entitymanager.getTransaction().begin();
Lesson lesson = entitymanager.find(Lesson.class, this.l_id);
lesson.setQuantity(lesson.getQuantity()-1);
entitymanager.getTransaction().commit();
Booking book = new Booking();
book.setCustomername(strName);
book.setCustomerphone(strPhone);
book.setLessonno(this.l_id);
entitymanager.persist(book);
entitymanager.getTransaction().commit();
entitymanager.close();
emfactory.close();
}
this way also same
so how i need to solve it ...thanks
Edited by HarrySeah

Share this post


Link to post
Share on other sites

Which line of code is that exception coming from? The stack trace should have an indication of that. Which operation is not supported?

Share this post


Link to post
Share on other sites

Has the Booking class been declared as an entity and annotated?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0