Exemplo n.º 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;
 }
Exemplo n.º 2
0
  public Customer getCustomerByUserId(String userName) throws SQLException, ClassNotFoundException {

    StringBuffer sb = new StringBuffer();
    sb.append("SELECT * FROM ")
        .append(myProps.getProperty("schemaName"))
        .append("CUSTOMER WHERE USERID = ")
        .append("'")
        .append(userName)
        .append("'");

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

    Connection con = null;
    Customer customer = null;

    try {
      con = DBUtils.getConnection();
      logger.debug("Got the connection...");
      Statement st = con.createStatement();
      ResultSet rs = st.executeQuery(sql);
      logger.debug("Result = " + rs);
      while (rs.next()) {
        customer = new Customer();
        customer.setUserName(rs.getString("USERID"));
        customer.setPassword(rs.getString("PASSWORD"));
        customer.setEmail(rs.getString("EMAIL"));
        customer.setFname(rs.getString("FIRSTNAME"));
        customer.setLname(rs.getString("LASTNAME"));
        customer.setCustType(CustomerTypeEnum.getEnumByValue(rs.getString("CUSTTYPE")));
        customer.setStatus(CustomerStatusEnum.getEnumByValue(rs.getString("STATUS")));
      }

    } 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);
      }
    }
    return customer;
  }
Exemplo n.º 3
0
  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);
      	}
      }*/
  }