예제 #1
0
  @Override
  public OrtDTO createPoint(OrtDTO dto) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(
            connection,
            CREATEPOINT,
            false,
            new Object[] {dto.getPointX(), dto.getPointY(), dto.getDescription()});
    preparedStatement.executeUpdate();

    return findPointByAxis(dto.getPointX(), dto.getPointY());
  }
예제 #2
0
  @Override
  public OrtDTO findPointByAxis(int punktX, int punktY) throws SQLException {
    OrtDTO ort = new OrtDTO();
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(connection, FINDPOINTBYAXIS, false, new Object[] {punktX, punktY});
    resultSet = preparedStatement.executeQuery();

    while (resultSet.next()) {
      ort.setPointId(resultSet.getLong("id"));
      ort.setPointX(resultSet.getInt("xAxis"));
      ort.setPointY(resultSet.getInt("yAxis"));
      ort.setDescription(resultSet.getString("name"));
    }
    return ort;
  }
예제 #3
0
  @Override
  public void deletePoint(OrtDTO dto) throws SQLException {

    PreparedStatement preparedStatement = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement =
        DaoUtil.prepareStatement(
            connection, DELETEPOINTBYID, false, new Object[] {dto.getPointId()});
    preparedStatement.executeUpdate();
  }
예제 #4
0
  @Override
  public List<OrtDTO> findAllPoints() throws SQLException {
    List<OrtDTO> retVal = new ArrayList<OrtDTO>();
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    Connection connection = daoFactory.getConnection();
    preparedStatement = DaoUtil.prepareStatement(connection, FINDALLPOINTS, false, new Object[0]);
    resultSet = preparedStatement.executeQuery();

    while (resultSet.next()) {
      OrtDTO ort = new OrtDTO();
      ort.setPointId(resultSet.getLong("id"));
      ort.setPointX(resultSet.getInt("xAxis"));
      ort.setPointY(resultSet.getInt("yAxis"));
      ort.setDescription(resultSet.getString("name"));
      retVal.add(ort);
    }
    return retVal;
  }