package jp.ac.kcska.questionsystem.exammanager.horizon; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import jp.ac.kcska.questionsystem.ExcuteDatabase; public class GetExamList { private Connection getConnection() throws SQLException { Connection connection = null; connection = DriverManager.getConnection( "jdbc:mysql://localhost/questionsystem", "root", "mysql"); connection.setAutoCommit(false); return connection; } public ArrayList getList() { ArrayList examList = new ArrayList(); try { String sql = "SELECT * FROM EXAMVIEW"; ExcuteDatabase excuteDatabase = new ExcuteDatabase(); ResultSet resultSet = excuteDatabase.excuteSelect(sql); while (resultSet.next()) { ExamviewVo examVo = new ExamviewVo(); int id = resultSet.getInt("id"); String examname = resultSet.getString("examname"); String categoryname = resultSet.getString("categoryname"); byte valid = resultSet.getByte("valid"); examVo.setId(id); examVo.setExamname(examname); examVo.setCategoryname(categoryname); examVo.setValid(valid); examList.add(examVo); } } catch (SQLException e) { e.printStackTrace(); } return examList; } }