dbutils模糊查询

本文详细阐述了如何使用SQL语句进行复杂查询,并通过参数化避免SQL注入风险。介绍了如何利用连接操作和条件筛选来优化查询性能,同时强调了在数据库操作中释放资源的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码:

 StringBuffer sql = new StringBuffer("select ti.ky_city,ti.car_number,ti.first_bus,ti.last_bus,ti.interval,tl.station,ti.price,ti.cost,ti.length,ti.remark,ti.cards from ecityadmin.T_DATA_BUS_INFO ti,ecityadmin.T_DATA_BUS_LIST tl where ti.CAR_NUMBER=tl.CAR_NUMBER ");
  sql.append("AND tl.STATION LIKE ? order by ti.CAR_NUMBER");
  Object[] params = new Object[]{};
  Object[] param = ArrayUtils.add(params, "%"+stationName+"%");
  System.out.println("stationQuery'sql = " + sql.toString());
  try {
   list = (List<HebGongjiao>) queryRunner.query(conn,sql.toString(),param, new BeanListHandler(HebGongjiao.class));
  } catch (SQLException e) {
   throw new RuntimeException(e);
  } finally {
            DBCommonUtil.releaseConnection(conn);
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值