I used to use com.datastax.driver.core.ResultSet. I could take all remaining rows and put it into an Array of my model class and then add it to List of Arrays.
Below is my previous code with ResultSet from datastax package.
List<ReportDescription[]> result = new ArrayList<>();
ReportDescription[] csvReportDescriptions;
csvReportDescriptions = resultSet.all().stream()
.map(row -> new ReportDescription(row.getObject("value"))).toArray(ReportDescription[]::new);
result.add(csvReportDescriptions);
Nowadays I change database so now I need to swithch ResultSet to java.sql.ResultSet package. Is it any possibility to get all rows, create new instance of my models and put it into List of Arrays as I did it before?
I make it by my own like that
try {
ResultSet rS = dataSource.getConnection().createStatement().executeQuery(query.toString());
while(rS.next()){
descriptions.add(new ReportDescription(rS.getObject("VALUE")));
}
} catch (SQLException e) {
dataSource.logError("Can't execute statement :" + query.toString());
}
csvReportDescriptions = descriptions.toArray(new ReportDescription[descriptions.size()]);
result.add(csvReportDescriptions);