一、增加信息
public void testInsert(){
try{
Connection conn = MySqlDbUtil.getConnection();
String sql = "INSERT INTO band(name,remark) VALUES(?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"软工2班");
pstmt.setString(2,"备注信息");
int result = pstmt.executeUpdate();
if (result>0){
System.out.println("增加信息成功");
}else {
System.out.println("增加信息失败");
}
pstmt.close();
conn.close();
}catch (Exception e){
e.printStackTrace();
}
}
二、删除信息
public void testDelete(){
try{
Connection conn = MySqlDbUtil.getConnection();
String sql = "DELETE FROM band WHERE id=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt