JDBC中的PreparedStatement
时间:2021-07-01 10:21:17
帮助过:2人阅读
PreparedStatement preparedStatement=connection.prepareStatement(sql); //在执行查询操作之前必须对每个IN参数进行设置
//设置IN参数的语法格式:preparedStatement.setXXX(position,value) position为IN参数在SQL语句中的位置,valu为参数被设置的值
preparedStatement.setInt(1,160); preparedStatement.setInt(2,300); ResultSet rs=preparedStatement.executeQuery(); while (rs.next()){
String job_id=rs.getString("job_id");
String job_desc=rs.getString("job_desc");
String min_lvl=rs.getString("min_lvl");
String max_lvl=rs.getString("max_lvl");
System.out.print(job_id);
System.out.print(job_desc);
System.out.print(min_lvl);
System.out.println(max_lvl);
}
}
}
JDBC中的PreparedStatement
标签: