sql=new StringBuffer(" select * from LN_EMPLOYEEBASEINFORMATION ");
if(employeeNo!=0){
sql.append(" where employee_no='"+employeeNo+"' ");
}
if(notesId!=null){
sql.append(" AND notes_id like '%"+notesId.toUpperCase()+"%' ");
}
if(!toDate.equals(""){
sql.append(" AND birthday=to_date('"+toDate+"','yyyy-mm-dd')");
}
为什么总报java.lang.Exception异常 ,toDate是传进来的参数,去调这个就不报错
if(employeeNo!=0){
sql.append(" where employee_no='"+employeeNo+"' ");
}
if(notesId!=null){
sql.append(" AND notes_id like '%"+notesId.toUpperCase()+"%' ");
}
if(!toDate.equals(""){
sql.append(" AND birthday=to_date('"+toDate+"','yyyy-mm-dd')");
}
为什么总报java.lang.Exception异常 ,toDate是传进来的参数,去调这个就不报错
解决方案 »
- jsp文件输出成html是顶部总是出现一段空白行.
- 父窗体提交action子窗体接受结果集的问题
- webwork文件上传问题
- 代码出错
- alert() 和 <jsp:forward ...>不能一起使用吗?麻烦高手帮忙看下下面几行代码,多谢/!!!
- 求教jsp数据导出到excel
- 寻问:用jdbc连接Sybase时,出现了"java.lang.ClassNotFoundException: com.sybase.jdbc.SybDriver",怎么办?
- 介绍几本书?
- SpringMVC+junit测试报错
- 如何用获取一个图片文件的长度、高度数值??
- 请教高手jocky不能混淆编译成兼容JVM1.4问题(急!!!!!!!!!!!!!!!!)
- jsp问题
public String find(UserTest I,int pageSize,int pageIndex)
{
String result="";
String Name = I.get("Name");
String Password = I.get("Password");
String Birthday=I.get("Birthday");
String Address=I.get("Address");
String Tel=I.get("Tel");
StringBuffer sql = new StringBuffer("SELECT Name from mytest where 1=1");
if(Data.hasValue(Name))
sql.append(" and Name like ?");
if(Data.hasValue(Password))
sql.append(" and Password like=?");
if(Data.hasValue(Birthday))
sql.append(" and Birthday like=?");
if(Data.hasValue(Address))
sql.append(" and Address like=?");
if(Data.hasValue(Tel))
sql.append(" and Tel like=?");
sql.append(" order by Name desc");
DBAccess q = new DBAccess();
result = q.executeQuery(sql.toString(), I.propList, pageSize, pageIndex);
setCOUNT(q.COUNT);
setEOF(q.EOF);
return result;
}
public List getList(int employeeNo,String notesId)throws Exception{
List alist=new ArrayList();
StringBuffer sql=null;
ResultSgl sgl=new ResultSgl();
Connection conn=sgl.getConnection();
HashMap map=new HashMap();
try{
sql=new StringBuffer(" select * from LN_EMPLOYEEBASEINFORMATION ");
if(employeeNo!=0){
sql.append(" where employee_no='"+employeeNo+"' ");
}else if(employeeNo==0){
System.out.println("ddd");
}
if(notesId!=null){
sql.append(" AND notes_id like '%"+notesId.toUpperCase+"%' ");
}
if(!toDate.equals("")){
sql.append(" AND birthday=to_date('"+toDate+"','yyyy-mm-dd')");
}
System.out.println();
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery(sql.toString());
while(rs.next()){
EmployeeForm eform=new EmployeeForm();
eform.setEmployeeNO(rs.getInt("employee_no"));
eform.setSex(rs.getInt("sex"));
eform.setFirstName(rs.getString("first_name"));
eform.setLastName(rs.getString("last_name"));
eform.setNotesId(rs.getString("notes_id"));
alist.add(eform);
}
}catch(Exception ex){
throw new Exception("测试1"+ex.getMessage());
}
return alist;
}
改成
if(toDate!=null && !"".equals(toDate)){还错的话,详细异常信息贴一下。
sql.append(" AND notes_id like '%"+notesId.toUpperCase+"%' ");
}
那么如果(notesId==null)的情况你没写估计你这里出错了
我在TOAD里试,是可以的
但不知道为什么
sql=new StringBuffer(" select * from LN_EMPLOYEEBASEINFORMATION where 1=1");
if(employeeNo!=0){
sql.append(" and employee_no='"+employeeNo+"' ");
}
if(notesId!=null){
sql.append(" AND notes_id like '%"+notesId.toUpperCase()+"%' ");
}
if(!toDate.equals(""){
sql.append(" AND birthday=to_date('"+toDate+"','yyyy-mm-dd')");
}