不对之处请指正!
Vector v=new Vector();
Vector w=new Vector();
Vector p=new Vector();
try{
sql0="select mctfanswer, shortanswer from questions where classid='"+courseid+"' and type='"+type+"' order by assignid";
stmt0=con.createStatement();
result0=stmt0.executeQuery(sql0);
while(result0.next())
{
String mctf=result0.getString(1);
String shortanswer=result0.getString(2);
Vector rows=new Vector(2,1);
rows.addElement(mctf);
rows.addElement(shortanswer);
v.addElement(rows);
}
result0.close();
stmt0.close();
}catch (SQLException Ex) {
out.println("query questions failed");
} try{
sql1="select mctfanswer,shortanswer from submittedqs where classid='"+courseid+"' and type='"+type+"' and userid='"+userid+"' order by assignid";
stmt01=con.createStatement();
result01=stmt01.executeQuery(sql1);
while(result01.next())
{
String submctf=result01.getString(1);
String subshort=result01.getString(2);
Vector rows0=new Vector(2,1);
rows0.addElement(submctf);
rows0.addElement(subshort);
w.addElement(rows0);
}
result01.close();
stmt01.close();
}catch (SQLException Ex) {
out.println("query questions failed");
}
try{
sql10="select points from questions where classid='"+courseid+"' and session='"+section+"' and type='"+type+"' order by assignid";
stmt0=con.createStatement();
result0=stmt0.executeQuery(sql0);
while(result0.next())
{
points=result0.getInt(1);
Vector rows1=new Vector(1,1);
rows1.addElement(points);
p.addElement(rows1);
}
result01.close();
stmt01.close();
}catch (SQLException Ex) {
out.println("query questions failed");
}
for(int i=1;i<v.size() ;i++){
if(v.equals(w)){
points=Integer.parseInt(rows1.elementAt(i));
points+=points;
}
Vector v=new Vector();
Vector w=new Vector();
Vector p=new Vector();
try{
sql0="select mctfanswer, shortanswer from questions where classid='"+courseid+"' and type='"+type+"' order by assignid";
stmt0=con.createStatement();
result0=stmt0.executeQuery(sql0);
while(result0.next())
{
String mctf=result0.getString(1);
String shortanswer=result0.getString(2);
Vector rows=new Vector(2,1);
rows.addElement(mctf);
rows.addElement(shortanswer);
v.addElement(rows);
}
result0.close();
stmt0.close();
}catch (SQLException Ex) {
out.println("query questions failed");
} try{
sql1="select mctfanswer,shortanswer from submittedqs where classid='"+courseid+"' and type='"+type+"' and userid='"+userid+"' order by assignid";
stmt01=con.createStatement();
result01=stmt01.executeQuery(sql1);
while(result01.next())
{
String submctf=result01.getString(1);
String subshort=result01.getString(2);
Vector rows0=new Vector(2,1);
rows0.addElement(submctf);
rows0.addElement(subshort);
w.addElement(rows0);
}
result01.close();
stmt01.close();
}catch (SQLException Ex) {
out.println("query questions failed");
}
try{
sql10="select points from questions where classid='"+courseid+"' and session='"+section+"' and type='"+type+"' order by assignid";
stmt0=con.createStatement();
result0=stmt0.executeQuery(sql0);
while(result0.next())
{
points=result0.getInt(1);
Vector rows1=new Vector(1,1);
rows1.addElement(points);
p.addElement(rows1);
}
result01.close();
stmt01.close();
}catch (SQLException Ex) {
out.println("query questions failed");
}
for(int i=1;i<v.size() ;i++){
if(v.equals(w)){
points=Integer.parseInt(rows1.elementAt(i));
points+=points;
}
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080%2Fcom\_0002fusdl_0002fstudent_0002fTestResults_0002ejspTestResults_jsp_60.java:660: Incompatible type for method. Can't convert int to java.lang.Object.
rows1.addElement(points);
^
C:\tomcat\work\localhost_8080%2Fcom\_0002fusdl_0002fstudent_0002fTestResults_0002ejspTestResults_jsp_60.java:670: Undefined variable or class name: rows1
points=Integer.parseInt(rows1.elementAt(i));
^
2 errors
points好象没有定义
int points=0;
ROWS1定义在了WHILE里,那在外面就不能用了.
我感觉你的v和w,p都是多余的啊不是已经有row0和rows,row1了吗?