代码:
QueryRunner queryRunner = new QueryRunner();
connection = JdbcUtils.getConnection();
String sql = "SELECT id,name,address,phone FROM customer WHERE name LIKE ?";
List<Customer> list = queryRunner.query(connection,sql,new BeanListHandler<Customer>(Customer.class), "%j%");
for(Customer c: list){
System.out.println(c);
}
当我用自己的DAO代码查询时,没问题。但是用queryRunner,出现以下异常:</p>
java.sql.SQLException: ORA-00904: "NAMEIKE": invalid identifier
Query: SELECT id,name,address,phone FROM customer WHERE name LIKE ? Parameters: [%j%]
at org.apache.commons.dbutils.AbstractQueryRunner.rethrow(AbstractQueryRunner.java:392)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:351)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:212)
at com.lteagle.mvcapp.test.Test.main(Test.java:19)
我不知道无效标识符“NAMEIKE”来自哪里。