0
回答
用dbutils对oracle模糊查询出现ORA-00904问题
华为云4核8G,高性能云服务器,免费试用   

 代码如下:

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);

我的sql用自己编的DAO代码进行模糊查询没有问题,但用queryRunner就出现如下错误:

java.sql.SQLException: ORA-00904: "NAMEIKE": 标识符无效
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”这个无效标识符呢?

举报
笨笨咸鱼
发帖于1年前 0回/139阅
顶部