public class zuoye1 {
public static void main(String[] args) throws SQLException {
Connection conn=Dbutils.getConnection();
String sql="select * from student";
PreparedStatement ps= conn.prepareStatement(sql);
ResultSet rs= ps.executeQuery();
while(rs.next()){
/*姓名 年龄 性别 分数 */
String sanme= rs.getString("sanme");
int age=rs.getInt("age");
String gender=rs.getString("gender");
int score=rs.getInt("score");
System.out.println("sanme =" +sanme + ",age ="+age + "gender="+gender+",socre ="+score);
}
//String sql2="select * from student where gender='女'";
// String sql3="update student set score = "+score+10+" where score<90";
String sql3 = "update student set score = 100 where gender='女'and score> 90";
//PreparedStatement ps2= conn.prepareStatement(sql2);
// ResultSet rs2= ps2.executeQuery();
PreparedStatement ps3= conn.prepareStatement(sql3);
int rs3=ps3.executeUpdate(sql3);
while(rs3>0){
System.out.println("修改成功");
}
ps3.close();
String sql4="select * from student where name like '%小%'";
PreparedStatement ps4= conn.prepareStatement(sql4);
ResultSet rs4= ps4.executeQuery();
while(rs4.next()){
/*姓名 年龄 性别 分数 */
String sanme= rs.getString("sanme");
int age=rs.getInt("age");
String gender=rs.getString("gender");
int score=rs.getInt("score");
System.out.println("sanme =" +sanme + ",age ="+age + "gender="+gender+",socre ="+score);