2 yy 451686712 yy_451686712 于 2014.09.19 13:37 提问

sql语句中的?赋值失败??求大家帮忙找找原因,在下感激不尽

private Connection conn = null;
private PreparedStatement pstmt = null;
private ResultSet rs = null;

public List supplierfindbyname(Supplierlocation su) {
// TODO Auto-generated method stub
List sulist = new ArrayList();
String sql = "select * from fanwe_supplier_location where name = ?";
try {
conn = getConnection();
pstmt = conn.prepareStatement(sql);
System.out.println("su.getSuppname()----"+su.getSuppname());
pstmt.setString(1,"'%"+su.getSuppname()+"%'");
rs = pstmt.executeQuery();
System.out.println("sql----"+sql);
while(rs.next())
{
System.out.println("结果集中取出来的name----"+rs.getString("name"));
Supplierlocation supp = new Supplierlocation();
supp.setSuppname(rs.getString("name"));
supp.setPreview(rs.getString("preview"));
supp.setAvgpoint(rs.getFloat("avg_point"));
supp.setTakeawayprice(rs.getFloat("takeaway_price"));
supp.setTakeawaytime(rs.getInt("takeaway_time"));
supp.setShopcount(rs.getInt("shop_count"));
supp.setDeal_cate_match_row(rs.getString("deal_cate_match_row"));
supp.setXpoint(rs.getString("xpoint"));
supp.setYpoint(rs.getString("ypoint"));
sulist.add(supp);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally
{
closeConnection(conn, pstmt, rs);
}
return sulist;
}

2个回答

yy_451686712
yy_451686712   2014.09.19 14:05

自己顶.......................................

u011289525
u011289525   2014.09.19 20:42

你是想用模糊查询么?
是的话 就是你的查询语句错了 String sql = "select * from fanwe_supplier_location where name like = ?";

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!