diff --git "a/07 \345\206\257\345\273\272\347\250\213/20230519 jdbc\344\275\234\344\270\232.md.txt" "b/07 \345\206\257\345\273\272\347\250\213/20230519 jdbc\344\275\234\344\270\232.md"
similarity index 100%
rename from "07 \345\206\257\345\273\272\347\250\213/20230519 jdbc\344\275\234\344\270\232.md.txt"
rename to "07 \345\206\257\345\273\272\347\250\213/20230519 jdbc\344\275\234\344\270\232.md"
diff --git "a/07 \345\206\257\345\273\272\347\250\213/20230520 \344\275\234\344\270\232.md.txt" "b/07 \345\206\257\345\273\272\347\250\213/20230520 \344\275\234\344\270\232.md"
similarity index 100%
rename from "07 \345\206\257\345\273\272\347\250\213/20230520 \344\275\234\344\270\232.md.txt"
rename to "07 \345\206\257\345\273\272\347\250\213/20230520 \344\275\234\344\270\232.md"
diff --git "a/07 \345\206\257\345\273\272\347\250\213/20230522 \344\275\234\344\270\232.txt" "b/07 \345\206\257\345\273\272\347\250\213/20230522 \344\275\234\344\270\232.md"
similarity index 100%
rename from "07 \345\206\257\345\273\272\347\250\213/20230522 \344\275\234\344\270\232.txt"
rename to "07 \345\206\257\345\273\272\347\250\213/20230522 \344\275\234\344\270\232.md"
diff --git "a/07 \345\206\257\345\273\272\347\250\213/20230524 \344\275\234\344\270\232.md" "b/07 \345\206\257\345\273\272\347\250\213/20230524 \344\275\234\344\270\232.md"
new file mode 100644
index 0000000000000000000000000000000000000000..7d5d60da207e9c88caa970cc39af3969b4d67d76
--- /dev/null
+++ "b/07 \345\206\257\345\273\272\347\250\213/20230524 \344\275\234\344\270\232.md"
@@ -0,0 +1,217 @@
+```html
+
+
+
+
+
+ Title
+
+
+
+
+
+
+
+
+
+
+
+```
+
+```java
+//查询
+import jakarta.servlet.*;
+import jakarta.servlet.http.*;
+import jakarta.servlet.annotation.*;
+
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@WebServlet(name = "select", value = "/select")
+public class select extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ String id1 = request.getParameter("id");
+ ResultSet re = Jdbc.select("select * from student where id=?", id1);
+ try {
+ while (re.next()) {
+ String id = re.getString(1);
+ String name = re.getString(2);
+ response.getWriter().write(id+" "+name+"
");
+ }
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
+```
+
+```java
+//添加
+import jakarta.servlet.*;
+import jakarta.servlet.http.*;
+import jakarta.servlet.annotation.*;
+
+import java.io.IOException;
+
+@WebServlet(name = "add", value = "/add")
+public class add extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ String id = request.getParameter("id");
+ String name = request.getParameter("name");
+ int i = Jdbc.update("insert into student values(?,?)",id,name);
+ if (i>0){
+ response.getWriter().write("添加成功");
+ }else {
+ response.getWriter().write("添加失败");
+ }
+ }
+}
+```
+
+```java
+//删除
+import jakarta.servlet.*;
+import jakarta.servlet.http.*;
+import jakarta.servlet.annotation.*;
+
+import java.io.IOException;
+
+@WebServlet(name = "delete", value = "/delete")
+public class delete extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ String id = request.getParameter("id");
+ int i = Jdbc.update("delete from student where id=?",id);
+ if (i>0){
+ response.getWriter().write("删除成功");
+ }else {
+ response.getWriter().write("删除失败");
+ }
+ }
+}
+```
+
+```java
+//修改
+import jakarta.servlet.*;
+import jakarta.servlet.http.*;
+import jakarta.servlet.annotation.*;
+
+import java.io.IOException;
+
+@WebServlet(name = "update", value = "/update")
+public class update extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ String id = request.getParameter("id");
+ String name = request.getParameter("name");
+ int i = Jdbc.update("update student set name=? where id=?",name,id);
+ if (i>0){
+ response.getWriter().write("修改成功");
+ }else {
+ response.getWriter().write("修改失败");
+ }
+ }
+}
+```
+
+```java
+//工具类
+import java.sql.*;
+
+public class Jdbc {
+ static {
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ //创建连接
+ private static Connection conn() {
+ String url = "jdbc:mysql://localhost:3306/text?useSSL=false&useUnicode=true&characterEncoding=utf8";
+ Connection conn = null;
+ try {
+ conn = DriverManager.getConnection(url, "root", "root");
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return conn;
+ }
+
+ //查询
+ public static ResultSet select(String sql, String... arr) {
+ ResultSet re = null;
+ try {
+ PreparedStatement pst = conn().prepareStatement(sql);
+ for (int i = 0; i < arr.length; i++) {
+ pst.setString((i + 1), arr[i]);
+ }
+ re = pst.executeQuery();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return re;
+ }
+
+ //增删改
+ public static int update(String sql, String... arr) {
+ try {
+ PreparedStatement pst = conn().prepareStatement(sql);
+ for (int i = 0; i < arr.length; i++) {
+ pst.setString((i + 1), arr[i]);
+ }
+ int i = pst.executeUpdate();
+ return i;
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
+```
\ No newline at end of file