JDBC的开发步骤
加载驱动
获取连接
获取执行平台
执行sql语句
处理结果
关闭资源
public class DeletejdbcDemo{
public static void main(Stirngs[] args){
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManage.getConnection("jdbc:mysql://localhost:3306/mydb01","root","123456");
String sql = "delete from student where id = 1;";
Statemenet statement = conn.createStatement();
int count = statement.executeUpdate(sql);
System.out.println("共影响了"+count+"行数据" );
statement.close();
conn.close();
}
}
行更新
int count = statement.executeUpdate(sql);
System.out.println("共影响了"+count+"行数据" );
statement.close();
conn.close();
}
}