1 Reply Latest reply on Jul 18, 2007 4:11 PM by Stephan Seelig

    error InitialContext - database error

    Stephan Seelig Newbie

      Hi guys,

      I have the following inital Method to fill my database everytime I start jboss-4.0.5:

      public void contextInitialized(ServletContextEvent arg0) {
       logger.info("ServletContext initialized, initialize DB.");
       InitialContext iCtx;
       try {
       iCtx = new InitialContext();
       internetShop = (InternetShopLocal) iCtx
       .lookup("InternetShop/InternetShop/local");
       } catch (NamingException exc) {
       throw new RuntimeException(exc);
       }
       List<EntityBean> mockEntities = new ArrayList<EntityBean>();
       User user = getMockUser();
       mockEntities.add(user);
      
       mockEntities.add(....);
       mockEntities.add(....);
       mockEntities.add(....);
       try {
       internetShop.saveMockEntities(mockEntities);
       } catch (Exception e) {
       e.printStackTrace();
       }
      }


      The Method getMockUser() returns a fille user Object

      public static User getMockUser() {
       User result = new User();
       result.setAccountNumber("01234");
       result.setAdmin(false);
       result.setBankName("Western Union");
       result.setBankNumber("43210");
       result.setCity("Gossersweiler Stein");
       result.setCompanyName("Feuchtraumbeseitigung");
       result.setEmail("deep@dami.sch");
       result.setHousenumber("12a");
       result.setLogin("user");
       result.setName("user");
       result.setPassword("asswd");
       result.setStreet("wersglaubt");
       result.setSurname("step");
       result.setZipcode("43012");
       return result;
      }


      So I think my configurations are right cause the database structure is ok:

      21:56:58,329 INFO [TableMetadata] table found: PUBLIC.USER
      21:56:58,329 INFO [TableMetadata] columns: [password, banknumber, login, street, id, accountnumber, surname, bankname, companyname, housenumber, email, name, zipcode, admin, city]
      21:56:58,329 INFO [TableMetadata] foreign keys: []
      21:56:58,329 INFO [TableMetadata] indexes: [sys_pk_57, sys_idx_sys_ct_56_58]
      21:56:58,344 INFO [SchemaUpdate] schema update complete

      And this is the message I get every time:
      Why are the values null and ??? that's not possible.
      Anybody who has some ideas please let me know...

      21:57:02,594 ERROR [STDERR] 18.07.2007 21:57:02 com.internetshop.InitializeDBCtxListener contextInitialized
      INFO: ServletContext initialized, initialize DB.
      21:57:03,204 INFO [STDOUT] Hibernate: insert into User (id, name, password, admin, login, accountNumber, bankName, bankNumber, city, companyName, email, housenumber, street, surname, zipcode) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      21:57:03,250 WARN [JDBCExceptionReporter] SQL Error: -104, SQLState: 23000
      21:57:03,250 ERROR [JDBCExceptionReporter] Unique constraint violation: SYS_CT_56 in statement [insert into User (id, name, password, admin, login, accountNumber, bankName, bankNumber, city, companyName, email, housenumber, street, surname, zipcode) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]

      thanks Stephan