From d0c2918ae4e24e202790076aea42c8461ae5f1c0 Mon Sep 17 00:00:00 2001 From: pengshun <3024235926@qq.com> Date: Thu, 30 May 2024 11:05:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en.java" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "work/com/java/minxi/java_20240524/java_2302_\345\275\255\351\241\272_2344310202/en.java" diff --git "a/work/com/java/minxi/java_20240524/java_2302_\345\275\255\351\241\272_2344310202/en.java" "b/work/com/java/minxi/java_20240524/java_2302_\345\275\255\351\241\272_2344310202/en.java" new file mode 100644 index 0000000..3ac5b1f --- /dev/null +++ "b/work/com/java/minxi/java_20240524/java_2302_\345\275\255\351\241\272_2344310202/en.java" @@ -0,0 +1,42 @@ +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; + +public class en { + public static void main(String[] args) throws Exception { + dbDemo(); + } + public static void dbDemo() throws Exception{ + Connection connection = null; + Statement statement = null; + + //1.注册驱动 铺路到仓库 + + + //2.获取连接(给定数据库连接的参数) 去仓库开门, 开门的钥匙 + String url = "jdbc:mysql:///student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection conn = DriverManager.getConnection(url, username, password); + + //2. 定义sql + String sql = "select * from studentinfo;"; + + //3. 获取执行sql的对象 Statement + Statement stmt = conn.createStatement(); + + //4. 执行sql + int i = stmt.executeUpdate(sql); + if (i > 0) { + System.out.println("修改成功~"); + } else { + System.out.println("修改失败~"); + } + + //5. 释放资源 + stmt.close(); + + conn.close(); + } +} + -- Gitee From cdeb8bcf0da138b92888111e747ffcde5b8eb998 Mon Sep 17 00:00:00 2001 From: pengshun <3024235926@qq.com> Date: Wed, 5 Jun 2024 13:58:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../obtain.jsp" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "work/com/java/minxi/java_20240531/java_2302_\345\275\255\351\241\272_2344310202/obtain.jsp" diff --git "a/work/com/java/minxi/java_20240531/java_2302_\345\275\255\351\241\272_2344310202/obtain.jsp" "b/work/com/java/minxi/java_20240531/java_2302_\345\275\255\351\241\272_2344310202/obtain.jsp" new file mode 100644 index 0000000..503cab4 --- /dev/null +++ "b/work/com/java/minxi/java_20240531/java_2302_\345\275\255\351\241\272_2344310202/obtain.jsp" @@ -0,0 +1,69 @@ +package com.java.minxi.java_20240531.java_2302_彭顺_2344310202; +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + +

+ <%! + class Animal{ + String sleep(){ + return "一只动物在睡觉"; + } + } + class Cat{ + private String name; + private int time; + + public Cat(String name, int time) { + this.name = name; + this.time = time; + } + + public Cat() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getTime() { + return time; + } + + public void setTime(int time) { + this.time = time; + } + String sleep(){ + String text = "一只"+this.getName()+"睡了"+this.getTime()+"小时"; + return text; + } + } + + %> + <% + Animal animal = new Animal(); + out.println(animal.sleep()); + %> +
+ <% + Cat cat = new Cat("老虎",4); + out.println(cat.sleep()); + %> +
+ <% + for (int i = 1; i <= 9; i++) { + for (int j = 1; j <= i; j++) { + out.print(j+"*"+i+"="+i*j+" "); + } + out.print("
"); + } + %> +

+ + -- Gitee From 208316e527f273ded3a67791874a2b332fccc6c7 Mon Sep 17 00:00:00 2001 From: pengshun <3024235926@qq.com> Date: Fri, 7 Jun 2024 14:06:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circle.jsp" | 28 +++++++++++++++ .../ladder.jsp" | 30 ++++++++++++++++ .../main.jsp" | 34 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/circle.jsp" create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/ladder.jsp" create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/main.jsp" diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/circle.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/circle.jsp" new file mode 100644 index 0000000..b463797 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/circle.jsp" @@ -0,0 +1,28 @@ +<%@ page import="javafx.geometry.Side" %><%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-06 + Time: 19:13 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" %> + + + Title + + +%> +<% +String SideA = request.getParameter("SideA"); +double a = Double.parseDouble(SideA); + +%> +<%! public Double circle(Double a){ + return Math.PI*a*a; +}; +%> + +

三角形的面积为:

<%=circle(a)%> + + + diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/ladder.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/ladder.jsp" new file mode 100644 index 0000000..4be1a0f --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/ladder.jsp" @@ -0,0 +1,30 @@ +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-06 + Time: 19:13 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +<% + String SideB = request.getParameter("SideB"); + String SideC = request.getParameter("SideC"); + String SideD = request.getParameter("SideD"); + double b = Double.parseDouble(SideB); + double c = Double.parseDouble(SideC); + double d = Double.parseDouble(SideD); + +%> +<%! public Double ladder(Double b,Double c,Double d){ +return (b+c)*d/2; +}; +%> + +

梯形的面积为:

<%=ladder(b,c,d)%> + + diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/main.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/main.jsp" new file mode 100644 index 0000000..72fd62e --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\275\255\351\241\272_2344310202/main.jsp" @@ -0,0 +1,34 @@ +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-06 + Time: 19:12 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + +<% double a = 2; +double b = 3; +double c = 4; +double d = 5; +%> +

计算圆的面积

+
加载circle.jsp 计算半径<%=a%>圆的面积 + + + + +

计算梯形的面积

+
加载ladder.jsp 计算半径<%=b%>,<%=c%>,<%=d%>梯形的面积 + + + + + + + -- Gitee From 4e6c7dfe2c548e3493646deb1341ff071bda5d5e Mon Sep 17 00:00:00 2001 From: pengshun <3024235926@qq.com> Date: Fri, 7 Jun 2024 17:26:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index1.jsp" | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\345\275\255\351\241\272_2344310202/index1.jsp" diff --git "a/work/com/java/minxi/java_20240606/java_2302_\345\275\255\351\241\272_2344310202/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\345\275\255\351\241\272_2344310202/index1.jsp" new file mode 100644 index 0000000..ad16f3c --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\345\275\255\351\241\272_2344310202/index1.jsp" @@ -0,0 +1,118 @@ +package com.java.minxi.java_20240605.java_2302_彭小林_2344310228; + + +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.Statement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.List" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" %> + + + + + +

+ <%! + class UserInfo { + private int id; + private String user_name; + private String user_phone; + + // 构造函数 + + + public UserInfo(int id, String user_name, String user_phone) { + this.id = id; + this.user_name = user_name; + this.user_phone = user_phone; + } + + // getter 方法 + public int getId() { + return id; + } + + public String getUserName() { + return user_name; + } + + public String getUserPhone() { + return user_phone; + } + + // toString 方法用于方便打印对象信息 + @Override + public String toString() { + return "UserInfo{" + + "id=" + id + + ", UserName='" + user_name + '\'' + + ", userPhone='" + user_phone + '\'' + + '}'; + } + } + + %> + <% + // JDBC配置信息 + String url = "jdbc:mysql://127.0.0.1:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + + // 创建List对象 + List userList = new ArrayList<>() ; + + try { + // 加载驱动 + Class.forName("com.mysql.cj.jdbc.Driver"); + + // 建立连接 + Connection connection = DriverManager.getConnection(url, username, password); + String sql = "select id,user_name,user_phone from user_info;"; + // 创建Statement + Statement statement = connection.createStatement(); + + // 执行查询 + ResultSet re = statement.executeQuery(sql); + + // 遍历结果集,封装到UserInfo对象并添加到列表中 + while (resultSet.next()) { + int id = resultSet.getInt("id"); + String userName = resultSet.getString("user_name"); + String userPhone = resultSet.getString("user_phone"); + userList.add(new UserInfo(id, userName, userPhone)); + } + + // 关闭资源 + re.close(); + statement.close(); + connection.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + // 输出List中的数据 + for (UserInfo userInfo : userList) { + out(userInfo.toString()); + } + %> + + + +

+ +


+<% + request.setAttribute("userList", userList); +%> + + + + + + + + + -- Gitee