我有一个使用数据库的项目,我有一些主要课程,如学生、模块、招生和更多 3 个课程来管理它们。这里的问题是
在学生班我有这个代码
私有字符串 id;
@DomainConstraint(optional = false, mutable = true, type = Type.String, length = 50)
private String name;
@DomainConstraint(optional = false, mutable = true, type = Type.String, length = 20)
private String dob;
@DomainConstraint(optional = false, mutable = true, type = Type.String, length = 50)
private String address;
@DomainConstraint(optional = false, mutable = true, type = Type.String, length = 50)
private String email;
private static int autoIncrementInt = 0;
public Student(String name, String dob, String address, String email) {
this.name = name;
this.dob = dob;
this.address = address;
this.email = email;
idGenerator();
}
但是在班级 EnrolmentManager 中,我想以学生的名义为他们注册这样的课程
public void load() throws SQLException {
Connection con;
Properties connectionProps = new Properties();
// set up properties, e.g. user name/password
con = DriverManager.getConnection("jdbc:derby:courseman;create=false", connectionProps);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT Student.name as studentName, Module.name as Modulename, Enrolment.internalMark,Enrolment.examMark FROM Student,Module,Enrolment WHERE Student.id=Enrolment.sid AND Module.code=Enrolment.mcode");
while (rs.next()) {
String s = rs.getString("studentName");
String m = rs.getString("Modulename");
double y = rs.getDouble("internalMark");
double d = rs.getDouble("examMark");
Enrolment e = new Enrolment( s, m, y, d);
enrolments.add(e);
}
}
这里有一个错误,因为在类 Enrollment 我有它的 Constructor 是
public Enrolment(Student stu, Module module,Double internalMark, Double examMark) {
this.student = stu;
this.module = module;
this.internalMark = internalMark;
this.examMark = examMark;
finalGradeGenerator();
}
因此在类中EnrolmentManager
,它有一个错误是构造函数注册是未定义的。你能帮我解决这个问题吗,谢谢