From 2c6a089b7cf5240ef79a258132021323e13129c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E9=94=90?= <2570878950@qq.com> Date: Fri, 26 May 2023 23:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9C=E6=88=91=E7=9A=84=E7=AC=AC=E5=9B=9B?= =?UTF-8?q?=E6=AC=A1=E4=BD=9C=E4=B8=9A=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230524 \344\275\234\344\270\232.md" | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 "20 \345\206\257\351\224\220/20230524 \344\275\234\344\270\232.md" diff --git "a/20 \345\206\257\351\224\220/20230524 \344\275\234\344\270\232.md" "b/20 \345\206\257\351\224\220/20230524 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..3920361 --- /dev/null +++ "b/20 \345\206\257\351\224\220/20230524 \344\275\234\344\270\232.md" @@ -0,0 +1,114 @@ +```html + + + + + 学生管理系统 + + +
+

查询学生

+ 输入你要查询的学生编号:
+ 输入你要查询的学生姓名:
+ 输入你要查询的学生性别:
+ +
+
+

添加学生

+ 输入你要添加的学生编号:
+ 输入你要添加的学生姓名:
+ 输入你要添加的学生性别:
+ +
+
+

删除学生

+ 输入你要删除的学生编号:
+ +
+
+

修改学生

+ 输入你要修改的学生编号:
+ 输入你要修改的学生姓名:
+ +
+ + +``` + +```java +package com.dao; + +import java.sql.*; + +public class Dao { + private Connection conn; + private String driver = "com.mysql.jdbc.Driver"; + private String url ="jdbc:mysql://localhost:3306/student_db?useSSL=false&useUnicode=true&charsetEnding=utf8"; + private String user="root"; + private String password="root"; + + public Dao() { + try { + Class.forName(driver); + System.out.println("驱动加载成功"); + } catch (ClassNotFoundException e) { + System.out.println("驱动加载失败!"); + throw new RuntimeException(e); + } + } + + public Connection getConn() { + try { + conn = DriverManager.getConnection(url,user,password); + System.out.println("数据库连接成功"); + } catch (SQLException e) { + System.out.println("数据库连接失败!"); + throw new RuntimeException(e); + } + return conn; + } + + public void setConn(Connection conn) { + this.conn = conn; + } +} +``` + +```java +package com.student; + +public class Student { + private int id; + private String name; + private String sex; + + public Student() { + } + + public Student(int id, String name, String sex) { + this.id = id; + this.name = name; + this.sex = sex; + } + + public void setId(int id) { + this.id = id; + } + + + public void setName(String name) { + this.name = name; + } + + public void setSex(String sex) { + this.sex = sex; + } + + @Override + public String toString() { + return "id= "+ id +" name= "+name+" sex= "+sex; + } +} +``` + +```java -- Gitee