读书人

有段代码不知道哪里有异常请赐教

发布时间: 2012-01-15 22:57:49 作者: rapoo

有段代码不知道哪里有错误请赐教
package jihe.jiheinfo;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Score {

public int Ids;
int a,b,c,d;
int UserId;
String Today;
String Lastday;
DBconn db=new DBconn();
List score_max=new ArrayList();

public void time(){
Calendar today=Calendar.getInstance();
SimpleDateFormat sdf=new SimpleDateFormat( "yyyy-MM-dd ");
Today=sdf.format(today.getTime());

today.add(Calendar.DATE,-60);
Lastday=sdf.format(today.getTime());

}//时间方法

public List scores() throws SQLException,Exception{

String SQL= "select Id,count(Id) as Ids from Users where LastTimes between ' "+Lastday+ " ' and ' "+Today+ " ' ";
ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
Ids=Integer.parseInt(rs.getString( "Ids "));
ScoreBean sb=new ScoreBean();
sb.setId(rs.getString( "Id "));
score_max.add(sb);

}
return score_max;
}//有多少人员处理


//查询表积分有3个方法
public int getC_score(int UserId)
throws NumberFormatException, SQLException {

String SQL= "select count(HostManId) as jifen from costumecomm " +
"where HostManId= ' "+UserId+ " ' " +
"and Times between ' "+Lastday+ " ' and ' "+Today+ " ' ";

ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
a=Integer.parseInt(rs.getString(1));
}
return a;
}


public int getO_score(int UserId)
throws NumberFormatException, SQLException{

String SQL1= "select count(HostManId) as jifen from ornamentcomm " +
"where HostManId= ' "+UserId+ " ' " +


"and Times between ' "+Lastday+ " ' and ' "+Today+ " ' ";

ResultSet rs1=db.executeQuery(SQL1);
while(rs1.next()){
b=Integer.parseInt(rs1.getString(1));
}
return b;
}

public int getT_score(int UserId)
throws NumberFormatException, SQLException{

String SQL2= "select count(HostManId) as jifen from toiletrycomm " +
"where HostManId= ' "+UserId+ " ' " +
"and Times between ' "+Lastday+ " ' and ' "+Today+ " ' ";

ResultSet rs2=db.executeQuery(SQL2);
while(rs2.next()){
c=Integer.parseInt(rs2.getString(1));
}
return c;
}

public int getSum(int UserId) throws NumberFormatException, SQLException{
d=getT_score(UserId)+getC_score(UserId)+getO_score(UserId);
return d;
}//每个人的总积分


}

[解决办法]
没有仔细看,这条sql就有问题。
String SQL= "select Id,count(Id) as Ids from Users where LastTimes between ' "+Lastday+ " ' and ' "+Today+ " ' ";

读书人网 >J2SE开发

热点推荐