title: Creating a list with database values and store in DTO
body: <p>I have a my main class, a DTO, and a DAO.
  what I want to do is to read the database table CUSTOMER(two fields NAME, SURNAME) then write it to a txt file. I cant seem to get it to store the values in the DTO so that my main class can get it.</p>
  
  <p>My DTO exist of two fields, NAME and SURNAME with the getters and setters.
  The problem lies in my DAO with the List</p>
  
  <p>*please keep in mind I'm a student.</p>
  
  <p>This is what I have done so far:
  result, writes to file like this: [name surname, name surname, name surname,]
  I need it to write to the file pipe deliminated " | "</p>
  
  <pre><code>public CustomerDTO getDetails(Connection conn) throws SQLException {
  
      CustomerDTO customerDTO = new CustomerDTO();
      ResultSet rs = null;
      PreparedStatement pstmnt = null;
  
      try {
          // SELECT NAME, SURNAME FROM CUSTOMER
          StringBuffer stringBuffer = new StringBuffer("SELECT " + DBConstants.CUST_NAME + ", ");
          stringBuffer.append(DBConstants.CUST_SURNAME);
          stringBuffer.append(" FROM " + "CUSTOMER");
          //build string
          String query = stringBuffer.toString();
          //prepared statement
          pstmnt = conn.prepareStatement(query);
          //execute preparestatement
          rs = pstmnt.executeQuery();
          //keep reading next line in table - .next() method means next line
          List myList = new ArrayList();
  
          while (rs.next()) {
              String ss = rs.getString("NAME");
              String sss = rs.getString("SURNAME");
              myList.add(ss + " " + sss);
              customerDTO.setName(myList.toString());
              customerDTO.setSurname(myList.toString());
          }
      } catch (Exception e) {
          e.getMessage();
      }
      rs.close();
      //return DTO with details.
      return customerDTO;
  }
  </code></pre>