Question: I want to create a list with my database field values.
There are 2 columns, name and surname.
I want to create a list that stores all names in name column in a field and then add to my DTO.

Is this possible?

Answer: 
It is. What have you tried ? 

To access the database, you need to [use JDBC](http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html) and execute a query, giving you a `ResultSet`.

I would create an class called `FullName` with 2 String fields `name` and `surname`. Just populate these in a loop using 

```
rs.getString("NAME");  // column name
rs.getString("SURNAME");

```

e.g.

```
List<FullName> fullnames = new ArrayList<FullName>();
while (rs.next()) {
    fullnames.add(new FullName(rs));
}

```

Note that I'm populating the object via the `ResultSet` object directly. You may choose instead to implement a constructor taking the 2 name fields.

Note also that I'm creating a `Fullname` object. So the firstname/surname are kept separate and you have the freedom to add initials etc. later. You may prefer to rename this `Person` and that will give you the freedom to add additional attributes going forwards.
What worked for me is:

```
ResultSetMetaData rsmd = rs.getMetaData();
         int columnCount = rsmd.getColumnCount();

         ArrayList<String> resultList= new ArrayList<>(columnCount);
         while (rs.next()) {
             int i = 1;
             while(i <= columnCount) {
                 resultList.add(rs.getString(i++));
             }
         }
         return resultList;

```