jdbc 直接查询sql

@SuppressWarnings("unchecked")
	public List<helloWordDto> getCardUpgradeDetailList(
			String cardUpgradeId) {
		String sql = "SELECT hello_id FROM helloword  WHERE word = ?";
		try{
			return (List<helloWordDto>)this.getJdbcTemplate().query(sql, new Object[]{cardUpgradeId}, new RowMapper() {
				
				public CardUpgradeDetailDto mapRow(ResultSet rs, int arg1) throws SQLException {
					helloWordDto dto = new helloWordDto();
					dto.sethelloId(rs.getString("hello_id"));
					
					return dto;
				}
			});
		}catch(Exception e){
			logger.error("执行sql:"+sql+";错误",e);
			return null;
		}
		
	}
@SuppressWarnings("unchecked")
	public List<helloword> getSendhellowordList(final String helloid){
		List<helloword> list1 = (List<helloword>)getJdbcTemplate().execute(new StatementCallback(){
			public Object doInStatement(Statement stm) throws SQLException,DataAccessException {
				String sql = "select helloid,helloNAME from helloword helloid = "+ helloid ;
				ResultSet rs = stm.executeQuery(sql);
				List<helloword> list = null;
				while(rs.next()){
					if(null == list){
						list = new ArrayList<helloword>();
					}
					helloword s = new helloword();
					String hellowordId = rs.getString("helloid");
					String hellowordName = rs.getString("helloNAME");
					s.sethellowordId(hellowordId);
					s.sethellowordName(hellowordName);
					list.add(s);
				}
				return list;
			}
			
		});
		return list1;
	}

 

转载于:https://my.oschina.net/u/2369810/blog/783866

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值