Package com.cin.test.util

Source Code of com.cin.test.util.EmploymentTable

package com.cin.test.util;

import java.sql.*;

import com.cin.dto.EmploymentStatusDTO;

public class EmploymentTable extends Table {
  public EmploymentTable(Connection connection) {
    super("employmentstat", connection);
  }

  public void init() throws SQLException {
    Statement stmt = connection.createStatement();
    try{
      stmt.execute("insert into employmentstat (SSN, UNEMPLOYMENTREASON, EMPLOYMENTSTAT) values (10, null, ' Full-time schedules')");
      stmt.execute("insert into employmentstat (SSN, UNEMPLOYMENTREASON, EMPLOYMENTSTAT) values (11, null, ' Full-time schedules')");
      stmt.execute("insert into employmentstat (SSN, UNEMPLOYMENTREASON, EMPLOYMENTSTAT) values (13, ' Other job loser', ' Children or Armed Forces')");
    }finally{
      stmt.close();
    }
  }
 
  public EmploymentStatusDTO getRow(int ssn) throws SQLException {
    PreparedStatement stmt = connection.prepareStatement(
        "SELECT * " +
        "FROM "+getName()+" " +
        "WHERE ssn = ?");
    try{
      stmt.setInt(1, ssn);
      stmt.execute();
     
      ResultSet rs = stmt.getResultSet();
      if( rs.next() ){
        EmploymentStatusDTO dto = new EmploymentStatusDTO();
        dto.setEmploymentStatus(rs.getString("employmentstat"));
        dto.setUnemploymentReason(rs.getString("unemploymentreason"));
        return dto;
      } else {
        return null;
      }
    }finally{
      stmt.close();
    }
  }
}
TOP

Related Classes of com.cin.test.util.EmploymentTable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.