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个回答

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

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问