PreparedStatement的用法
在写精确查找的时候,sql语句用错了,然后查了查PreparedStatement的用法
具体的用法可以参考博文:https://www.cnblogs.com/onmyway20xx/p/4273321.html
1 String sql= "select * from system where name =?"; 2 Connection conn=Database.getConnection();
3 PreparedStatement pstmt = null; 4 ResultSet rs = null; 5 try { 6 pstmt = conn.prepareStatement(sql); 7 pstmt.setString(1, name); 8 rs = pstmt.executeQuery(); 9 while(rs.next()) { 10 String Name=rs.getString("name"); 11 } 12 }