Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: PreexistingEntityException error in NetBeans

  1. #1
    Junior Member
    Join Date
    Mar 2022
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default PreexistingEntityException error in NetBeans

    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 form 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 as 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);  
       }

    My problem is now solved using try/catch statement
    Last edited by danboy775; March 14th, 2022 at 09:00 PM. Reason: Problem now solved

Similar Threads

  1. No error from netbeans, tons of errors with javac
    By paps in forum Java Theory & Questions
    Replies: 4
    Last Post: July 30th, 2020, 10:18 AM
  2. i/o error when using Netbeans 7.3 and Java 7
    By btsutherland in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 23rd, 2013, 02:52 PM
  3. Error in connection sql server 2008 using netbeans 7.2
    By Indrajeet in forum JDBC & Databases
    Replies: 1
    Last Post: January 20th, 2013, 11:38 PM
  4. Using NetBeans and I have no idea what the error message means...
    By Rick Sebastian in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 20th, 2013, 08:30 PM
  5. [SOLVED] NetBeans and SQLite error
    By Boquito17 in forum JDBC & Databases
    Replies: 3
    Last Post: October 13th, 2012, 04:46 PM