I am trying to create a Java application using Netbeans 8.2 for a uni project. I'm having an issue after creating a JFrame
for adding some data to the database.
NetBeans highlights the final statement ujc.create(u2);
in the code segment below with the following error message:
Unreported exception PreexistingEntityException; must be caught or declared to be thrown
Can someone advise what I need to do to fix this issue? I have no idea what I'm doing wrong.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
Users u2 = new Users();
u2.setEmployeeno(jTextField1.getText());
u2.setFirstname(jTextField2.getText());
u2.setSurname(jTextField3.getText());
EntityManagerFactory emf = Persistence.createEntityManagerFactory(
"BatteryManagementSystemPU");
UsersJpaController ujc = new UsersJpaController(emf);
ujc.create(u2);
}