Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?

Here is the code:

```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
        List<Bike> bikeList = new ArrayList<Bike>();

        Class.forName("com.mysql.jdbc.Driver");
        Connection con  = null;
        Statement  stm = null;
        ResultSet rs = null;
        con=DriverManager.getConnection("jdbc:mysql://localhost:3306/spring_hibernate","root","root"); ;
        stm=con.createStatement(); 
        String qry="Select * from bike"; 
        rs=stm.executeQuery(qry);
        while(rs.next())
        {           
            /* I need to put   
             * rs.getString("name"),rs.getString("model")
             * etc into any of the suitable collection objects 
             * and then need to add those to the ArrayList - bikeList
             * 
             */

        }
        return bikeList;

    }

```

Answer: 
I don't know how Your Bike class look like, but you should do it like this way:

```
while(rs.next())
{
    String column1 = rs.getString("column1_name");
    .... and the others columns

    Bike bike = new Bike();

    bike.setColumn1(column1);
    .... and others...

    bikeList.add(bike)
}

```
You need to instantiate Bike in while loop and add to `List`.

```
 List<Bike> bikes  = new ArrayList<>();
 while(rs.next())
    {           
       Bike bike = new Bike();
       bike.setname( rs.getString("name"));
       //other properties
       bikes.add(bike);
    }

  return bikes;

```