- 论坛徽章:
- 0
|
这个是我用JAVA写的一个查询方法
public Vector getAllbyOneandTwo(String colname1,String colvalue1,String colname2,String colvalue2){
Vector vt=new Vector();
Standards standard=null;
DBConnect db=null;
ResultSet rs=null;
String sql="select * from standards where (binary ? like ?) and (binary ? like ?)";
try{
db=new DBConnect();
db.prepareStatement(sql);
db.setString(1,colname1);
db.setBytes(2,("%"+colvalue1+"%").getBytes("gb2312"));
db.setString(3,colname2);
db.setBytes(4,("%"+colvalue2+"%").getBytes("gb2312"));
rs=db.executeQuery();
while(rs.next()){
standard=new Standards();
standard.setAlivetime(rs.getString("alivetime"));
standard.setContent(rs.getString("content"));
standard.setDomain(rs.getString("domain"));
standard.setDraftdept(rs.getString("draftdept"));
standard.setFname(rs.getString("fname"));
standard.setId(rs.getInt("id"));
standard.setIsaudit(rs.getInt("isaudit"));
standard.setIsdrop(rs.getInt("isdrop"));
standard.setIsoutdate(rs.getInt("isoutdate"));
standard.setIssecret(rs.getInt("issecret"));
standard.setIsvalid(rs.getInt("isvalid"));
standard.setName(rs.getString("name"));
standard.setNumber(rs.getString("number"));
standard.setPath(rs.getString("path"));
standard.setSystem(rs.getString("system"));
standard.setType(rs.getInt("type"));
standard.setUpdatetime(rs.getString("updatetime"));
standard.setVersion(rs.getString("version"));
vt.add(standard);
}
}catch(Exception e){e.printStackTrace();}
finally{
try{
if(db!=null)
db.close();
}catch(Exception e){e.printStackTrace();}
}
return vt;
}
编译也可以通过,也可以运行,就是得不到应该有的的结果 |
|