From b85cd062956c68dc973e8af341264e27cd0a4c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BF=8A=E8=B1=AA?= <“3228734291@qq.com”> Date: Fri, 26 May 2023 23:44:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= 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 "35 \345\274\240\344\277\212\350\261\252/20230524 \344\275\234\344\270\232.md" diff --git "a/35 \345\274\240\344\277\212\350\261\252/20230524 \344\275\234\344\270\232.md" "b/35 \345\274\240\344\277\212\350\261\252/20230524 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..3920361 --- /dev/null +++ "b/35 \345\274\240\344\277\212\350\261\252/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