Connection conn=getConnection();
int row=0;
try{
String sql ="insert into BOOKS(book_name,price,amount,author) values(?,?,?,?)";
PreparedStatement ps = conn.prepareStatement(sql);
for(int i=1;i<4;i++){
ps.setString(1,"三体"+i);
ps.setInt(2,i*100);
ps.setInt(3,i*10);
ps.setString(4,"刘慈欣");
ps.addBatch();
}
int[] rows=ps.executeBatch();
// conn.commit();
row=rows.length;
ps.close();
conn.close();
}catch(SQLException e){
e.printStackTrace();
}
返回的 row 为0 求大神帮忙看一下!!