首页 > 代码库 > jdbc防止sql注入-PreparedStatement
jdbc防止sql注入-PreparedStatement
jdbc防止sql注入
jdbc防止sql注入-PreparedStatement
public List getUserByName(String name,String password){
ResultSet rs = null;
PreparedStatement stat = null;
Connection conn = null;
List list = new ArrayList();
try {
conn = createConnection();
String sql = "select name,password from manager where name=? and password=? ";
stat = conn.prepareStatement(sql);
stat.setString(1, name);
stat.setString(2, password);
rs = stat.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
String []user = new String[2];
user[0] = rs.getString(1);
user[1] = rs.getString(2);
list.add(user);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
closeAll(rs, stat, conn);
}
return list;
}
jdbc防止sql注入-PreparedStatement
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。