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是传进来的参数,去调这个就不报错

解决方案 »

  1.   

    if(notesId!=null)换成if(Date.hasValue(notesID))试下
      

  2.   

    如果employeeNo==0报异常,因为sql语句有可能错误,还有贴出异常消息
      

  3.   

    这个是我的查询方法的代码你看下不知对你有没有帮助
    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;
    }
      

  4.   

    这是我的,你看一下
    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;
    }
      

  5.   

    if(!toDate.equals(""){
    改成
    if(toDate!=null && !"".equals(toDate)){还错的话,详细异常信息贴一下。
      

  6.   

    if(notesId!=null){ 
    sql.append(" AND notes_id like '%"+notesId.toUpperCase+"%' "); 

    那么如果(notesId==null)的情况你没写估计你这里出错了
      

  7.   

    java.lang.Exception: 测试1ORA-00933: SQL 命令未正确结束
    我在TOAD里试,是可以的
      

  8.   

    不好意思,可能是没问题的,可能还是和SQL有关,我去了前两个条件,就可以,
    但不知道为什么
      

  9.   

    这样写试试:
    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')"); 
       } 
      

  10.   

    问你个问题,JAVA到EXCEL如何控制,横排,竖排
      

  11.   

    在网上下个excel的java api,如:jxl或poi,就可以操作excel了