java.sql.SQLException: 无效的列索引的问题

问题描述

publicList<RegionDomain>getRegionList2(AdministratorDomainuser){Stringsql2="select*fromwm_em_broadband_jidetailwhere1=1";StringBuffersql=newStringBuffer(sql2);inti=0;Object[]ob=newObject[6];if(user.getAccount()!=null&&!"".equals(user.getAccount())){sql.append("andaccount=?");ob[i]=user.getAccount();i++;}if(user.getUser_id()!=null&&!"".equals(user.getUser_id())){sql.append("andgoods_no=?");ob[i]=user.getUser_id();i++;}if(user.getUser_ip()!=null&&!"".equals(user.getUser_ip())){sql.append("andstaff_id=?");ob[i]=user.getUser_ip();i++;}if(user.getUser_name()!=null&&!"".equals(user.getUser_name())){sql.append("andpwd=?");ob[i]=user.getUser_name();i++;}if(user.getBirthDayStr()!=null&&!"".equals(user.getBirthDayStr())&&user.getCreateTimeStr()!=null&&!"".equals(user.getCreateTimeStr())){sql.append("andsys_timebetweento_date(?,'yyyy/mm/dd')andto_date(?,'yyyy/mm/dd')");ob[i]=user.getBirthDayStr();i++;ob[i]=user.getCreateTimeStr();}Listresult=this.getEjTemplate().queryForList(sql.toString(),ob);returnresult;}小弟这段代码在queryForList时抛出了java.sql.SQLException:无效的列索引的异常,用debug把sql提取出来去plsql跑没有任何问题

解决方案

解决方案二:

解决方案三:
这句错了吧:sql.append("andaccount=?");,应该是sql.append("andaccount="+“user.getAccount()”),其他的类似

时间: 2024-08-31 11:36:58

java.sql.SQLException: 无效的列索引的问题的相关文章

java.sql.SQLException: 列名无效 [问题点数:25分,结帖人zshzyh] 收藏

问题描述 java.sql.SQLException:列名无效atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.

求教关于“java.sql.SQLException 列名无效”的问题

问题描述 使用DBUtil查询数据库时Java报列名'lei_xing'无效.但是这个SQL语句在MSSQL的控制台下面能够争取执行.到底是什么原因啊?这是查询部分的代码:Stringsql="selecttg.fid,tg.intime,tg.lei_bie,tg.ftitle,tg.inpart,tg.inname,jl.idfromtonggaotgleftjoin(selectid,fidfromyue_du_ji_luywherelei_xing=?)jlontg.fid=jl.fid

数据库一添加-java.sql.SQLException: 列名无效

问题描述 java.sql.SQLException: 列名无效 表单添加的时候数据库能正常添加这一行,但是控制台上还是会报 java.sql.SQLException: 列名无效 这个错误?请问怎么回事啊~~~急 //插入方法 public void insert(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException{ Connection co

ora-Caused by: java.sql.SQLException: ORA-00911: 无效字符

问题描述 Caused by: java.sql.SQLException: ORA-00911: 无效字符 if(stat){ sqlsb.append(" select * from ("); }else{ sqlsb.append("select count(*) from ("); } sqlsb.append("select bb.datetime datetime, sum(decode(bb.typevalue, '新入金', bb.init

java.sql.SQLException: 索引中丢失 IN或OUT 参数::x

使用JDBC时,会有这么一个错误:java.sql.SQLException: 索引中丢失 IN或OUT 参数::x 如下示例中insertLog.execute();这行会抛出这个异常: String logSQL = "insert into tbl_obj(id, obj, type, cont, proposer, operator, date, remark) " + "values(seq_tot.nextval, ?, ?, ?, ?, ?, SYSDATE,

Caused by: java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配

          项目中遇到这样一个问题:                 Caused by:java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配 atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) atoracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) atoracle.jdbc.

spring-Could not obtain connection metadata java.sql.SQLException: Io exception

问题描述 Could not obtain connection metadata java.sql.SQLException: Io exception 启动tomcat的时候就报下面的错.求大神指引....... 谢谢 [INFO] - Initializing connection provider: org.springframework.orm.hibernate3.TransactionAwareDataSourceConnectionProvider 2013-07-08 16:2

hibernate proxool java.sql.SQLException

问题描述 大家好,我现在在项目中使用了hibernate来连接数据库,使用到的连接池是proxool,但奇怪的是,在tomcat的日志中,每隔一定时间就会出现以下信息:09:02:35,768 DEBUG fm_oracleproxool:431 - 009441 (00/09/00) - #7920 removed because it has problems: java.sql.SQLException: ORA-00923: 未找到要求的 FROM 关键字09:02:36,407 DEB

mysql java.sql.SQLException 问题

问题描述 mysql java.sql.SQLException 问题 java.sql.SQLException: We are already in the process of making 20 connections and the number of simultaneous builds has been throttled to 19 这是什么问题,大家帮我解决下,急. . . 解决方案 并发的线程过多,已经超过你设置的连接数,同时强调一点,设置的连接数可能会对你的系统的性能有一