From ef83e52b3249783a557896730708d037ea09e281 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=98=8E=E5=87=BD?= <3084917167@qq.com>
Date: Mon, 22 May 2023 14:20:42 +0000
Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=BB=BA=2002=20=E9=99=88?=
=?UTF-8?q?=E6=98=8E=E5=87=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
"02 \351\231\210\346\230\216\345\207\275/.keep" | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "02 \351\231\210\346\230\216\345\207\275/.keep"
diff --git "a/02 \351\231\210\346\230\216\345\207\275/.keep" "b/02 \351\231\210\346\230\216\345\207\275/.keep"
new file mode 100644
index 0000000..e69de29
--
Gitee
From d180d5f563c550a880496451d6ea5f412ba43980 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=98=8E=E5=87=BD?= <3084917167@qq.com>
Date: Mon, 22 May 2023 14:22:43 +0000
Subject: [PATCH 2/3] =?UTF-8?q?02=20=E9=99=88=E6=98=8E=E5=87=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 陈明函 <3084917167@qq.com>
---
.../20230519 jsp\344\275\234\344\270\232.md" | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "02 \351\231\210\346\230\216\345\207\275/20230519 jsp\344\275\234\344\270\232.md"
diff --git "a/02 \351\231\210\346\230\216\345\207\275/20230519 jsp\344\275\234\344\270\232.md" "b/02 \351\231\210\346\230\216\345\207\275/20230519 jsp\344\275\234\344\270\232.md"
new file mode 100644
index 0000000..e69de29
--
Gitee
From 50dbe53fd2b46cdb997f4702334b41caec2073e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E6=98=8E=E5=87=BD?= <3084917167@qq.com>
Date: Thu, 25 May 2023 02:18:27 +0000
Subject: [PATCH 3/3] =?UTF-8?q?02=20=E9=99=88=E6=98=8E=E5=87=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 陈明函 <3084917167@qq.com>
---
.../0525\344\275\234\344\270\232.md" | 199 ++++++++++++++++++
1 file changed, 199 insertions(+)
create mode 100644 "02 \351\231\210\346\230\216\345\207\275/0525\344\275\234\344\270\232.md"
diff --git "a/02 \351\231\210\346\230\216\345\207\275/0525\344\275\234\344\270\232.md" "b/02 \351\231\210\346\230\216\345\207\275/0525\344\275\234\344\270\232.md"
new file mode 100644
index 0000000..bb9c6fa
--- /dev/null
+++ "b/02 \351\231\210\346\230\216\345\207\275/0525\344\275\234\344\270\232.md"
@@ -0,0 +1,199 @@
+````java
+package servle;
+
+import until.Text;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@WebServlet("/Text")
+
+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);
+ }
+ out.write("
");
+ //增添
+// String sql1="insert into studnet value(10,'牛蚊疯','妖魔鬼怪大傻叉')";
+// try {
+// int insert = Text.insert(sql1);
+// out.write("添加成功!");
+// } catch (Exception e) {
+// out.write("添加失败!");
+// }
+ //修改
+// String sql2="update studnet set name='刘文峰' where id=10";
+// try {
+// int update = Text.insert(sql2);
+// out.write("修改成功!");
+// } catch (Exception e) {
+// out.write("修改失败!");
+// }
+ //删除
+// String sql3="delete from studnet where id=1";
+// try {
+// int delete = Text.delete(sql3);
+// out.write("删除成功");
+// } catch (Exception e) {
+// out.write("删除成功");
+// }
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+}
+
+```
+
+## Text
+
+``` java
+package until;
+
+import java.sql.*;
+
+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;
+ }
+}
+````
+
--
Gitee