我正在研究大学招聘系统,我已将德比数据库连接到我的Netbeans Java项目,我正在尝试将Student对象添加到数据库中的Student表中。这是我的功能使用(它与工作人员合作,但对象有固定信息而不是输入)..
public static boolean addStudent(Student s) {
String connectionURL = "jdbc:derby://localhost:1527/University";
try {
Connection conn = DriverManager.getConnection(connectionURL, "BUE", "BUE");
Statement st = conn.createStatement();
String sql = "INSERT INTO STUDENT VALUES (" + s.getFirstName()+ "," + "'" + s.getLastName()+ "'" + "," + "'" + s.getCountry()+"'" + "," +"'" + s.getEmail()+ "'" + "," + "'" + s.getBirthYear() + "'" + "," + "'"+ s.getStudentUsername() + "'" +"," + s.getStudentPassword() +")";
System.out.println("@@@");
st.executeUpdate(sql);
st.close();
return true;
} catch (Exception ex) {
System.out.println(ex.getMessage());
return false;
}
}
这是创建对象和调用addStudent()函数的范围..
Student newAccount= new Student( firstNameTextField2.getText(), lastNameTextField.getText(), EmailTextField.getText(), countryTextField.getText(), birthYearTextField.getText(), usernameTextField.getText(), passText);
Student.addStudent(newAccount);
在运行和创建新帐户时(插入时),它给了我这个错误..
Column 'E' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'E' is not a column in the target table.