方法一:
String sql="select num,id,birth,hname,height from health_data_sys where id=? group by ?";
res=database.Search(sql, id);传输参数sql
public ResultSet Search(String sql, String str) {
try {
System.out.println(sql);
System.out.println(str);
PreparedStatement pst = con.prepareStatement(sql);
if (str != null) {
pst.setString(1,str);设置第一个参数
pst.setString(2,str);/设置第二个参数值
}
// executeQuery用于产生单个结果集的语句,例如 SELECT 语句
res = pst.executeQuery();
if(res!=null) System.out.println("h");
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("查询有错");
e.printStackTrace();
}
return res;
}
方法二:
public R