sql占位符怎么用
1、占位符的作用是代替参数输入,防止SQL注入,即sql被恶意篡改
2、定义conn为数据库连接引擎就不写了
String sql = "select * from table where id = ?";

3、result = conn.prepareStatement(sql);
4、pstmt.setString(1,id) ;绑定参数
阅读量:189
阅读量:34
阅读量:48
阅读量:154
阅读量:27
1、占位符的作用是代替参数输入,防止SQL注入,即sql被恶意篡改
2、定义conn为数据库连接引擎就不写了
String sql = "select * from table where id = ?";

3、result = conn.prepareStatement(sql);
4、pstmt.setString(1,id) ;绑定参数