请版主帮忙!!!

风清扬-3 2002-12-09 04:07:58
不对之处请指正!
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;

}
...全文
29 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxhong 2002-12-11
  • 打赏
  • 举报
回复
if(v.elementAt(i).equals(w.elementAt(i)))
zxhong 2002-12-11
  • 打赏
  • 举报
回复
你现在的问题是什么?
zxhong 2002-12-11
  • 打赏
  • 举报
回复
你是想比较整个数组还是比较数组中的元素?
我感觉你的v和w,p都是多余的啊不是已经有row0和rows,row1了吗?
jmars 2002-12-11
  • 打赏
  • 举报
回复
补充:不是因为POINTS没定义,而且定义为INT是不行的,VECTOR里要放OBJECT,比如INTEGER是可以的.
ROWS1定义在了WHILE里,那在外面就不能用了.
zxhong 2002-12-11
  • 打赏
  • 举报
回复
rows1要放在while外面定义
points好象没有定义
int points=0;
风清扬-3 2002-12-11
  • 打赏
  • 举报
回复
报错
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
zxhong 2002-12-09
  • 打赏
  • 举报
回复
什么错误信息?
风清扬-3 2002-12-09
  • 打赏
  • 举报
回复
不对之处请指正!
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;

}

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧