Exemple #1
0
 public static com.sp3.mvc.jaxb.Customer getJaxbCustomer(Customer customer) {
   com.sp3.mvc.jaxb.Customer jaxbCustomer = new com.sp3.mvc.jaxb.Customer();
   jaxbCustomer.setCusttype(customer.getCustType().toString());
   jaxbCustomer.setEmail(customer.getEmail());
   jaxbCustomer.setFirstname(customer.getFname());
   jaxbCustomer.setLastname(customer.getLname());
   jaxbCustomer.setPassword(customer.getPassword());
   jaxbCustomer.setStatus(customer.getStatus().toString());
   jaxbCustomer.setUserid(customer.getUserName());
   return jaxbCustomer;
 }
  public void insertCustomer(Connection conn, Customer customer) throws SQLException {

    StringBuffer sb = new StringBuffer();
    sb.append("INSERT INTO ")
        .append(myProps.getProperty("schemaName"))
        .append("CUSTOMER VALUES('")
        .append(customer.getUserName())
        .append("','")
        .append(customer.getPassword())
        .append("','")
        .append(customer.getEmail())
        .append("','")
        .append(customer.getFname())
        .append("','")
        .append(customer.getLname())
        .append("','")
        .append(customer.getCustType())
        .append("','")
        .append(customer.getStatus())
        .append("');");

    String sql = sb.toString();
    logger.debug("SQL Query - " + sql);

    try {
      Statement st = conn.createStatement();
      int rs = st.executeUpdate(sql);
      logger.debug("Result = " + rs);

    } catch (SQLException e) {
      logger.error("SQLException occured while inserting registration." + e);
      throw e;
    } /*catch (ClassNotFoundException e) {
      	logger.error("ClassNotFoundException while  loading the driver."+e);
      	throw e;
      } finally {
      	try {
      		DBUtils.closeConnection(con);
      	} catch (SQLException e) {
      		logger.error("SQLException occured while closing connection."+e);
      	}
      }*/
  }