From 3b5c86089d9a85d6563b985097bdbd3f0a779d30 Mon Sep 17 00:00:00 2001
From: LuoZhouYi <2108439463@qq.com>
Date: Thu, 30 May 2024 12:10:52 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E2=80=9D5=E6=9C=8823=E6=97=A5=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=E2=80=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
java2301.iml | 1 +
.../Durid.properties" | 14 +++
.../Main1.java" | 33 +++++++
.../Main2.java" | 37 ++++++++
.../Main3.java" | 43 ++++++++++
.../Student_info.java" | 86 +++++++++++++++++++
6 files changed, 214 insertions(+)
create mode 100644 "work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Durid.properties"
create mode 100644 "work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main1.java"
create mode 100644 "work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main2.java"
create mode 100644 "work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main3.java"
create mode 100644 "work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Student_info.java"
diff --git a/java2301.iml b/java2301.iml
index bff56e42..eaf242fa 100644
--- a/java2301.iml
+++ b/java2301.iml
@@ -7,5 +7,6 @@
+
\ No newline at end of file
diff --git "a/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Durid.properties" "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Durid.properties"
new file mode 100644
index 00000000..b3075e5d
--- /dev/null
+++ "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Durid.properties"
@@ -0,0 +1,14 @@
+# ????
+driverClassName=com.mysql.cj.jdbc.Driver
+# ???????
+url=jdbc:mysql://127.0.0.1:3306/student?serverTimezone=Asia/Shanghai
+# ???????
+username=root
+# ??
+password=20041126
+# ?????????
+initialSize=5
+# ??????
+maxActive=10
+# ???????????
+maxWait=3000
\ No newline at end of file
diff --git "a/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main1.java" "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main1.java"
new file mode 100644
index 00000000..cd3e6bf7
--- /dev/null
+++ "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main1.java"
@@ -0,0 +1,33 @@
+package com.java.minxi.java_20240523.java_2301_罗周熠_2344310113;
+
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.sql.*;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class Main1 {
+ private static Object StandardCharsets;
+
+ public static void main(String[] args) {
+ try {
+ Class.forName("com.mysql.cj.jdbc.Driver");
+ String url="jdbc:mysql://127.0.0.1:3306/student?serverTimezone=Asia/Shanghai";
+ String userName="root";
+ String password="20041126";
+ Connection conn = DriverManager.getConnection(url,userName,password);
+ String sql="update student_info set student_name = '小王' where class_id = 1;";
+ Statement stmt = conn.createStatement();
+ int count = stmt.executeUpdate(sql);
+ System.out.println(count);
+ stmt.close();
+ conn.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git "a/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main2.java" "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main2.java"
new file mode 100644
index 00000000..91bfb4c7
--- /dev/null
+++ "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main2.java"
@@ -0,0 +1,37 @@
+package com.java.minxi.java_20240523.java_2301_罗周熠_2344310113;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Main2 {
+ public static void main(String[] args) {
+ try{
+ Class.forName("com.mysql.cj.jdbc.Driver");
+ String url="jdbc:mysql://127.0.0.1:3306/student?serverTimezone=Asia/Shanghai";
+ String userName="root";
+ String password="20041126";
+ Connection conn = DriverManager.getConnection(url,userName,password);
+ String sql = "select * from student_info where class_id = ? ;";
+ PreparedStatement statement = conn.prepareStatement(sql);
+ statement.setInt(1,1);
+ ResultSet resultSet = statement.executeQuery();
+
+ List objects = new ArrayList<>();
+ while (resultSet.next()){
+ Student_info studentInfo = new Student_info();
+ int id = resultSet.getInt("id");
+ String studentName = resultSet.getString("student_name");
+ int studentAge = resultSet.getInt("student_age");
+ int studentSex = resultSet.getInt("student_sex");
+ studentInfo.setId(id);
+ studentInfo.setStudent_name(studentName);
+ studentInfo.setStudent_age(studentAge);
+ studentInfo.setStudent_sex(studentSex);
+ objects.add(studentInfo);
+ } System.out.println(objects);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+}
diff --git "a/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main3.java" "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main3.java"
new file mode 100644
index 00000000..25446f19
--- /dev/null
+++ "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Main3.java"
@@ -0,0 +1,43 @@
+package com.java.minxi.java_20240523.java_2301_罗周熠_2344310113;
+
+import com.alibaba.druid.pool.DruidDataSourceFactory;
+import com.mysql.cj.protocol.FullReadInputStream;
+
+import javax.sql.DataSource;
+import java.io.FileInputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class Main3 {
+ public static void main(String[] args) {
+ try{
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(""));
+ DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
+ Connection connection1 = dataSource.getConnection();
+ String sql = "select * from student_info where class_id = ? ;";
+ PreparedStatement statement = connection1.prepareStatement(sql);
+ statement.setInt(1,1);
+ ResultSet resultSet = statement.executeQuery();
+ List objects = new ArrayList<>();
+ while (resultSet.next()){
+ Student_info studentInfo = new Student_info();
+ int id = resultSet.getInt("id");
+ String studentName = resultSet.getString("student_name");
+ int studentAge = resultSet.getInt("student_age");
+ int studentSex = resultSet.getInt("student_sex");
+ studentInfo.setId(id);
+ studentInfo.setStudent_name(studentName);
+ studentInfo.setStudent_age(studentAge);
+ studentInfo.setStudent_sex(studentSex);
+ objects.add(studentInfo);
+ } System.out.println(objects);
+ }catch (Exception e){
+
+ }
+ }
+}
diff --git "a/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Student_info.java" "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Student_info.java"
new file mode 100644
index 00000000..80c59e82
--- /dev/null
+++ "b/work/com/java/minxi/java_20240523/java_2301_\347\275\227\345\221\250\347\206\240_2344310113/Student_info.java"
@@ -0,0 +1,86 @@
+package com.java.minxi.java_20240523.java_2301_罗周熠_2344310113;
+
+
+public class Student_info {
+ private int id;
+
+ private String student_name;
+
+ private int student_age;
+
+ private String student_address;
+ private int student_sex;
+ private String student_phone;
+
+
+ public Student_info() {
+
+ }
+
+ public Student_info(int id, String student_name, int student_age, String student_address, int student_sex, String student_phone) {
+ this.id = id;
+ this.student_name = student_name;
+ this.student_age = student_age;
+ this.student_address = student_address;
+ this.student_sex = student_sex;
+ this.student_phone = student_phone;
+ }
+
+ public int getStudent_sex() {
+ return student_sex;
+ }
+
+ public void setStudent_sex(int student_sex) {
+ this.student_sex = student_sex;
+ }
+
+ public String getStudent_phone() {
+ return student_phone;
+ }
+
+ public void setStudent_phone(String student_phone) {
+ this.student_phone = student_phone;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getStudent_name() {
+ return student_name;
+ }
+
+ public void setStudent_name(String student_name) {
+ this.student_name = student_name;
+ }
+
+ public int getStudent_age() {
+ return student_age;
+ }
+
+ public void setStudent_age(int student_age) {
+ this.student_age = student_age;
+ }
+
+ public String getStudent_address() {
+ return student_address;
+ }
+
+ public void setStudent_address(String student_address) {
+ this.student_address = student_address;
+ }
+
+ @Override
+ public String toString() {
+ return "Student_info{" +
+ "id=" + id +
+ ", student_name='" + student_name + '\'' +
+ ", student_age=" + student_age +
+ ", student_address='" + student_address + '\'' +
+ '}';
+ }
+}
--
Gitee