diff --git "a/work/com/java/minxi/java_20240524/java_2302_\351\203\221\345\277\227\347\272\242_2344310225/Main.java" "b/work/com/java/minxi/java_20240524/java_2302_\351\203\221\345\277\227\347\272\242_2344310225/Main.java" new file mode 100644 index 0000000000000000000000000000000000000000..c2d71a91da110177e6e28fc0d2ea8b77523dc5ba --- /dev/null +++ "b/work/com/java/minxi/java_20240524/java_2302_\351\203\221\345\277\227\347\272\242_2344310225/Main.java" @@ -0,0 +1,69 @@ +package com.java.minxi.java_20240524.java_2302_郑志红_2344310225; + +public class Main { + public static void main(String[] args) throws Exception { + Demo1(); + Demo2(); + Demo3(); + } + public static void Demo1() throws Exception{ + String taurl = "jdbc:mysql:///192.168.255.255:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection conn = DriverManager.getConnection(taurl, username, password); + String mysql = "select * from teacher_info;"; + Statement stmt = conn.createStatement(); + ResultSet sa = stmt.executeQuery(mysql); + + while (sa.next()){ + int id = sa.getInt("id"); + String name = sa.getString("teacher_name"); + int age = sa.getInt("teacher_age"); + System.out.println(id+"\t\t"+name+"\t\t\t"+age); + } + System.out.println(); + sa.close(); + stmt.close(); + conn.close(); + } + + private static void Demo2() throws Exception{ + //1. 获取连接 + String taurl = "jdbc:mysql:///192.168.255.255:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection conn = DriverManager.getConnection(taurl, username, password); + String sql = "select * from teacher_info where id = 1 && teacher_age = 20;"; + Statement stmt = conn.createStatement(); + ResultSet sd = stmt.executeQuery(sql); + + while (sd.next()){ + int id = sd.getInt(1); + String name = sd.getString(2); + int age = sd.getInt(3); + System.out.println(id+"\t"+name+"\t"+age); + } + System.out.println(); + sd.close(); + stmt.close(); + conn.close(); + } + + private static void Demo3() throws Exception{ + String taurl = "jdbc:mysql:///192.168.255.255:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection conn = DriverManager.getConnection(taurl, username, password); + String sql = "update teacher_info set teacher_name = '福可维' where id = 6;"; + Statement stmt = conn.createStatement(); + int i = stmt.executeUpdate(sql); + if (i>0){ + System.out.println("修改成功"); + }else{ + System.out.println("修改失败"); + } + stmt.close(); + conn.close(); + } + +} diff --git "a/work/com/java/minxi/java_20240531/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo.jsp" "b/work/com/java/minxi/java_20240531/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..d870c00559ca0ada6a22aeccdee98750c4e39f0a --- /dev/null +++ "b/work/com/java/minxi/java_20240531/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo.jsp" @@ -0,0 +1,77 @@ +<%-- + Created by IntelliJ IDEA. + User: zheng + Date: 2024/6/11 + Time: 19:24 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> + + + Title + + +

+ + <%! + 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("加菲猫",8); + out.println(cat.sleep()); + %> +
+ <% + for (int i = 1; i <= 9; i++) { + for (int j = 1; j <= i; j++) { + out.print(j+"X"+i+"="+i*j+" "); + } + out.print("
"); + } + %> +

+ + diff --git "a/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo1.jsp" "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo1.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..4c9b58ae8b0f7b431fc148357748a15146b72625 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo1.jsp" @@ -0,0 +1,25 @@ +<%-- + Created by IntelliJ IDEA. + User: zheng + Date: 2024/6/11 + Time: 19:47 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +// +

${param.r}

+<% + String parameter = request.getParameter("r"); + // + BigDecimal bigDecimal = new BigDecimal(parameter); + BigDecimal multiply = bigDecimal.multiply(bigDecimal).multiply(new BigDecimal("3.14")); + +%> +

圆形面积为<%=multiply%>

+ + diff --git "a/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo2.jsp" "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo2.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..55479b89392583be4eabcf311d5c6584506c103f --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/Demo2.jsp" @@ -0,0 +1,29 @@ +<%-- + Created by IntelliJ IDEA. + User: zheng + Date: 2024/6/11 + Time: 19:47 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +<% + String a= request.getParameter("a"); + String b= request.getParameter("b"); + String c= request.getParameter("c"); + // + BigDecimal bigDecimala = new BigDecimal(a); + BigDecimal bigDecimalb = new BigDecimal(b); + BigDecimal bigDecimalc = new BigDecimal(c); + BigDecimal divide = bigDecimalb.add(bigDecimala).multiply(bigDecimalc) + .divide(new BigDecimal("2"),2,BigDecimal.ROUND_HALF_UP); + + +%> +

这个梯形面积为:<%=divide%>

+ + diff --git "a/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/main.jsp" "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/main.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..9772abd1bd8d021585cd74276ac917b6f4a6d33b --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2023_\351\203\221\345\277\227\347\272\242_2344310225/main.jsp" @@ -0,0 +1,26 @@ +<%-- + Created by IntelliJ IDEA. + User: zheng + Date: 2024/6/11 + Time: 19:44 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + + + + + + + + + + + + + +