in 的用法:
public String updateSourceStatus(String sourceids) {
String sql_update="update data_source set is_same_with_post='1' where is_download='1' and id not in ( "+sourceids.substring(0,sourceids.length()-1)+" )";
// 得到数据库链接
Connection con = getConn_DataSource();
// 查询结果
PreparedStatement ps;
String result="";
try {
ps = con.prepareStatement(sql_update);
//ps.setString(1, );
int count = ps.executeUpdate();
if(count>0){
result="true";
}else{
result="false";
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
like 的用法
String expr = "select * from table where url like ?";
pstmt = con.prepareStatement(expr);
String a="a";
pstmt.setString(1, "%"+a+"%");//自动添加单引号 (包装后的参数)
pstmt.execute();
ok!!