mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 09:21:25 +08:00
Fix database selectStudentsFromCourse() bug
This commit is contained in:
@@ -301,7 +301,9 @@ public class DatabaseHelper {
|
|||||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||||
preparedStatement.setLong(1, courID);
|
preparedStatement.setLong(1, courID);
|
||||||
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
try (ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||||
students.add(StudentOA.select(resultSet.getLong("stuID")));
|
while (resultSet.next()) {
|
||||||
|
students.add(StudentOA.select(resultSet.getLong("stuID")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.cfive.classroom.library.database;
|
|||||||
|
|
||||||
import com.cfive.classroom.library.database.bean.Faculty;
|
import com.cfive.classroom.library.database.bean.Faculty;
|
||||||
import com.cfive.classroom.library.database.util.AlreadyExistsException;
|
import com.cfive.classroom.library.database.util.AlreadyExistsException;
|
||||||
|
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
||||||
import com.cfive.classroom.library.database.util.InsertException;
|
import com.cfive.classroom.library.database.util.InsertException;
|
||||||
import com.cfive.classroom.library.database.util.NoConfigException;
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -74,6 +75,11 @@ public class DatabaseTest {
|
|||||||
DatabaseHelper.selectAllFromStudent().forEach(LOGGER::debug);
|
DatabaseHelper.selectAllFromStudent().forEach(LOGGER::debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void selectStudentsFromCourseTest() throws NoConfigException, SQLException, DependenciesNotFoundException {
|
||||||
|
DatabaseHelper.selectStudentsFromCourse(2).forEach(LOGGER::debug);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void TempTest() {
|
void TempTest() {
|
||||||
LOGGER.debug(String.valueOf(UUID.randomUUID()));
|
LOGGER.debug(String.valueOf(UUID.randomUUID()));
|
||||||
|
|||||||
Reference in New Issue
Block a user