Results 1 to 2 of 2
  1. #1
    seristee is offline Member
    Join Date
    Jan 2012
    Posts
    8
    Rep Power
    0

    Default entity manager problem

    Java Code:
    try {
                    Users user = new Users();
                    
                    user.setFirstname(main.firstnameField.getText());
                    user.setLastname(main.lastnameField.getText());                
                    String servicenumbers = main.servicenumberField.getText();
                    int servicenumber = Integer.parseInt(servicenumbers);
                    user.setServicenumber(servicenumber);
                    int divisions = main.divisionBox.getSelectedIndex();
                    String division = Integer.toString(divisions);
                    if (divisions == 0) {
                        division = "Fire Prevention North";
                    }
                    if (divisions == 1) {
                        division = "Fire Prevention South";
                    }
                    user.setDivision(division);
                    char[] Password = main.passwordField.getPassword();
                    String PassWord = String.valueOf(Password);
                    String password = BCrypt.hashpw(PassWord, BCrypt.gensalt());
                    user.setPassword(password);
                    
                    main.FPAppPUEntityManager.getTransaction().begin();
                    main.FPAppPUEntityManager.persist(user);
                    main.FPAppPUEntityManager.getTransaction().commit();
                } catch (Exception e) {
                    //e.printStackTrace();
                    main.FPAppPUEntityManager.getTransaction().rollback();
                }
    i keep getting this error when i add this to my button eventhandler can anyone point me in the right direction

    Internal Exception: java.sql.SQLIntegrityConstraintViolationException: Column 'PASSWORD' cannot accept a NULL value.
    Error Code: 20000
    Call: INSERT INTO USERS (SERVICENUMBER, ACCESSLEVEL, DIVISION, FIRSTNAME, LASTNAME, PASSWORD) VALUES (?, ?, ?, ?, ?, ?)
    bind => [6 parameters bound]
    Query: InsertObjectQuery(fpapp.Users[ servicenumber=449 ])


    thanx in advance for your help

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: entity manager problem

    Check the value of password?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem with layout manager
    By mDennis10 in forum New To Java
    Replies: 8
    Last Post: 09-05-2011, 04:02 AM
  2. Jpa2 entity update problem
    By videanuadrian in forum Advanced Java
    Replies: 6
    Last Post: 06-08-2011, 12:05 PM
  3. lookup of entity manager
    By tovi in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 04-14-2011, 09:02 AM
  4. Replies: 0
    Last Post: 08-02-2010, 05:41 PM
  5. problem with ejb 3.0 entity beans with manyToMany relationship
    By makcro in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 07-26-2007, 08:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •