这是我的代码:
String[] teams = {"Blue Team", "Red Team", "Yellow Team", "Green Team", "Orange Team"};
int count = 0, team = 0;
String selectSQL = "select * from students"; // rand and distinct
Statement stmt = conn.createStatement();
ResultSet rs1 = stmt.executeQuery(selectSQL);
// Retrieve the results
while(rs1.next()){
if(count==3){
team++;
count = 0;
}
stmt.executeUpdate("Insert into "teams[team]" values ('"+rs1.getString("studentno")+"', '"+rs1.getString("firstname")+"', '"+rs1.getString("surname")+"', '"+rs1.getString("degreecode")+"', '"+rs1.getString("dob")+"')");
}
我在 stmt.executeUpdate 上收到错误消息。这是错误:
java.lang.Error: Unresolved compilation problems:
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token "]", AssignmentOperator expected after this token
Syntax error on token ")", delete this token
CreateTheTeams.doGet(CreateTheTeams.java:69)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
如何修复错误?