diff --git "a/12 \346\236\227\344\277\212\344\274\237/0525 \347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.md" "b/12 \346\236\227\344\277\212\344\274\237/0525 \347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.md"
new file mode 100644
index 0000000000000000000000000000000000000000..5827ca5fa614f80703381c3f57c59802799efeda
--- /dev/null
+++ "b/12 \346\236\227\344\277\212\344\274\237/0525 \347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.md"
@@ -0,0 +1,136 @@
+ public class SS extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ System.out.println("这是我数出语句");
+ resp.setContentType("Text/html;charset=utf-8");
+ PrintWriter out = resp.getWriter();
+ out.write("你接受到了一条消息");
+ out.write("
");
+ out.write("| 编号 | 姓名 | 性别 |
");
+ //查询
+ String sql="select * from studnet";
+ ResultSet qure = Text.qure(sql);
+ try {
+ while (qure.next()){
+ int id = qure.getInt("id");
+ String name = qure.getString("name");
+ String sex = qure.getString("sex");
+ out.write("| "+id+" | "+""+name+" | "+""+sex+" |
");
+ }
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ public class Text {
+ private static final String url="jdbc:mysql:///aaa?useSSL=false&useUnicode=true&characterEncoding=utf8";
+ private static final String username="root";
+ private static final String password="root";
+ static{
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ } catch (ClassNotFoundException e) {
+ System.out.println("驱动包异常请检查");
+ }
+ }
+ public static Connection getcon() {
+ Connection con = null;
+ try {
+ con = DriverManager.getConnection(url, username, password);
+ } catch (SQLException e) {
+ System.out.println("连接异常'");
+ }
+ return con;
+ }
+ public static Connection conget(){
+ Connection con = null;
+ try {
+ con = DriverManager.getConnection(url, username, password);
+ } catch (SQLException e) {
+ System.out.println("连接异常");
+ }
+ return con;
+ }
+ public static ResultSet qure(String sql, String...keys) {//查询
+ ResultSet res = null;
+ try {
+ Connection con = conget();
+ PreparedStatement pre = con.prepareStatement(sql);
+ for (int i = 0; i < keys.length; i++) {
+ pre.setString((i+1),keys[i]);
+ }
+ res = pre.executeQuery();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return res;
+ }
+ public static int insert(String sql,String...keys) {//添加
+ int num = 0;
+ PreparedStatement pre = null;
+ try {
+ Connection con = conget();
+ pre = con.prepareStatement(sql);
+ for (int i = 0; i < keys.length; i++) {
+ pre.setString((i + 1), keys[i]);
+ }
+ num = pre.executeUpdate();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ pre.close();
+ conget().close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return num;
+ }
+ public static int update(String sql,String...keys) {//修改
+ int num = 0;
+ PreparedStatement pre = null;
+ try {
+ Connection con = conget();
+ pre = con.prepareStatement(sql);
+ for (int i = 0; i < keys.length; i++) {
+ pre.setString((i + 1), keys[i]);
+ }
+ num = pre.executeUpdate();
+ pre.close();
+ conget().close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ pre.close();
+ conget().close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return num;
+ }
+ public static int delete(String sql,String...keys) {//删除
+ int num = 0;
+ PreparedStatement pre = null;
+ try {
+ Connection con = conget();
+ pre = con.prepareStatement(sql);
+ for (int i = 0; i < keys.length; i++) {
+ pre.setString((i + 1), keys[i]);
+ }
+ num = pre.executeUpdate();
+
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ pre.close();
+ conget().close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return num;
+ }
+ }