I have a problem with getting the value from a list. For example, I create an ArrayList from a ResultSet. I want to compare the values of this ResultSet to another ResultSet. My approach is to convert the ResultSets to ArrayLists and then compare them.I already used String.append() but failed to obtain the string.
How to get the value from from the ArrayList?
Can a simple solution be provided?
my code:
main class:
String my_query = "SELECT * FROM test.test_application";
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Boolean result = false;
DatabaseConnection cc = new DatabaseConnection();
connection = cc.connect();
if (connection != null) {
    pstmt = connection.prepareStatement(my_query);
    rs = pstmt.executeQuery();
    TestingModel tm = new TestingModel();
    Gson gs = new Gson();
    ArrayList<TestingModel> list = new ArrayList<TestingModel>();
    while(rs.next()) {
        tm.setClientID(rs.getInt(1));
        tm.setClientName(rs.getString(2));
        tm.setClientAddress(rs.getString(3));
        tm.setClientTelpNumber(rs.getString(4));
        tm.setClientEmail(rs.getString(5));
        list.add(tm);
    }
    System.out.println(gs.toJson(list));
    StringBuilder string = new StringBuilder();
    for (int i = 0; i < list.size(); i++) {
        System.out.println(string.append(list.get(i).toString()));
    }
}
model:
public class TestingModel {
    private int clientID;
    private String clientName;
    private String clientAddress;
    private String clientTelpNumber;
    private String clientEmail;
    // setter and getter
}
 
    