1
코드 블라인드가되었다고 생각합니다.ResultSet을 2DArray/HashMap/Lists 목록으로 바꾸기
저는 현재 친구와 함께 작은 프로젝트를 진행하고 있으며 JDBC를 사용하여 mySQL 데이터베이스에서 선택하고 있습니다.
내가 원하는 것은 select 문을 실행 한 후에 모든 데이터의 '2D'목록을 얻는 것입니다. array[columnName][all of the data inside the selected column]
의사 코드
// Count all rows from a column
// Count the columns selected
// Adds the column names to 'array'
for(int i = 1; i <= columnCount; i++)
columns.add(resultSetMeta.getColumnName(i));
// Adds the results of the first column to the 'array'
// How can I add the results from n columns?
for(int i = 1; i <= rowCount; i++) {
while (resultSet.next())
rows.add(resultSet.getString(i));
}
columnsAndRows.put(columns, rows);
에 사용하기 가장 적합한 데이터 형식은 무엇입니까 -
는 내가 뭔가 이런 식으로 반환하려는 생각 '레플리카 테이블 '- 배열 목록, 배열 또는 HashMaps?
ResultSet
을 2D 데이터 형식으로 만드는 가장 좋은 방법은 무엇입니까?ResultSet
을 통해 반복 할 때 어떻게 다음 열로 이동할 수 있습니까?
의 말씀을 전합니다. 즉, 열 단위로만 반복 할 수 있습니다. 테이블은 일반적으로 행 단위로 작동합니다. 그래서 아마도 List