diff --git "a/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc1.java" "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc1.java" new file mode 100644 index 0000000000000000000000000000000000000000..4cb032584a77e5ed3ea7fd29761f15f7c348cd9f --- /dev/null +++ "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc1.java" @@ -0,0 +1,35 @@ +package com.java.minxi.java_20240524.java_2302_吴憶豪_2244310224; + +import java.sql.*; + +public class jdbc1 { + public static void main(String[] args) { + String url = "jdbc:mysql://locallhost:3306/root"; + String user = "username"; + String password = "password"; + + try { + Class.forName("com.java.minxi.java_20240524.java_2302_吴憶豪_2244310224.jdbc1.Driver"); + + System.out.println("link start"); + Connection conn = DriverManager.getConnection(url, user, password); + + System.out.println("select infomaion"); + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("select id,teacher_name,teacher_age from users"); + + while (rs.next()) { + int id = rs.getInt("id"); + String teacher_name = rs.getString("name"); + System.out.println("id:" + id); + System.out.println("name:" + teacher_name); + } + rs.close(); + stmt.close(); + conn.close(); + } + catch(Exception e){ + e.printStackTrace(); + } + } +} diff --git "a/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc2.java" "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc2.java" new file mode 100644 index 0000000000000000000000000000000000000000..b93514127365e522d0c6bd68d561f481a289ebad --- /dev/null +++ "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc2.java" @@ -0,0 +1,38 @@ +package com.java.minxi.java_20240524.java_2302_吴憶豪_2244310224; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + +public class jdbc2 { + public static void main(String[] args) { + String url = "jdbc:mysql://localhost:3306/root"; + String user = "username"; + String password = "password"; + + String sql = "select * from users where id = ? and age = ?"; + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection conn = DriverManager.getConnection(url, user, password); + PreparedStatement pstmt = conn.prepareStatement(sql); + pstmt.setInt(1, 1); + pstmt.setInt(2, 35); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) { + int id = rs.getInt("id"); + String name = rs.getString("teacher_name"); + int age = rs.getInt("teacher_age"); + System.out.println("id:" + id + ",name:" + name + ",age" + age); + } + rs.close(); + pstmt.close(); + conn.close(); + } + catch (Exception e){ + e.printStackTrace(); + + } + } + } + diff --git "a/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc3.java" "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc3.java" new file mode 100644 index 0000000000000000000000000000000000000000..1d992a2dbd87e50efbb283078d33a440f4bb66c8 --- /dev/null +++ "b/work/com/java/minxi/java_20240524/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jdbc3.java" @@ -0,0 +1,29 @@ +package com.java.minxi.java_20240524.java_2302_吴憶豪_2244310224; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.DruidDataSourceFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.util.Properties; + +public class jdbc3 { + public static void main(String[] args) throws Exception { + Properties props = new Properties(); + props.put("url","jdbc:mysql://localhost:3306/your_database"); + props.put("username","your_name"); + props.put("password","your_password"); + props.put("driverClassName","com.mysql.cj.jdbc.Driver"); + + DruidDataSource dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(props); + Connection connection = dataSource.getConnection(); + String sql = "UPDATE users SET username = ? WHERE id = ?"; + PreparedStatement statement = connection.prepareStatement(sql); + statement.setString(1,"小严"); + statement.setInt(2, 3); + int affectedRows = statement.executeUpdate(); + statement.close(); + connection.close(); + System.out.println("affectedRows:"+affectedRows); + } +} diff --git "a/work/com/java/minxi/java_20240531/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jsp.jsp" "b/work/com/java/minxi/java_20240531/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jsp.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..7d6cc14cb34a51dd5dee4edea00b2e0898c0e751 --- /dev/null +++ "b/work/com/java/minxi/java_20240531/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/jsp.jsp" @@ -0,0 +1,74 @@ +package com.java.minxi.java_20240530.java_2302_吴憶豪_2244310224; + +import static java.lang.System.out; +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + title + + + +<%! +//定义一个Animal类,并在类中定义一个String sleep(int time)的成员方法 + + public class Animal { +public String sleep(int time) { +return "一只动物在睡觉"; +} +} + +//定义一个Cat类,包含name及time的属性,并定义String sleep(int time)的方法 +public class Cat { +private String name; +private int time; + +public Cat(String name, int time) { +this.name = name; +this.time = time; +} +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; +} + +public String sleep(int time){ +return"一只"+this.name+"睡觉睡了"+time+"小时"; +} +} %> + +<% Animal animal = new Animal(); +String sleep = animal.sleep(0); +out.println(sleep); + +Cat cat = new cat(); +cat.setName("汤姆猫"); +String sleep1 = animal.sleep(8); +out.println(sleep1); +%> + + +<% for (int i =1;i<=9;i++){ %> + + <% for(int j=1;j<=i;j++){ %> + + <%}%> + + <%}%> +
+ <% out.println(i+"*"+j+"="+i*j);%> +
+ + +} diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/circle.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/circle.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..3fe13c32fc0c21f9996a3fbf1a38028a67386608 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/circle.jsp" @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + title + + + + <% + String radius = request.getParameter("radius"); + double r = double.getParameter("radius"); + double area = Math.PI*r*r; + %> +

The radius <%= raidus%> of area is:<%= area%>

+ + + + diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/ladder.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/ladder.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..9c57edcdc52b7ef7cf9f6598d7678a6213b4a4e3 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/ladder.jsp" @@ -0,0 +1,8 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<% + double top = double.parseDouble(request.getParameter("top")); + double bottom = double.parseDobule(request.getParameter("bottom")); + double height = Double.parseDouble(request.getParameter("height")); + double area = ((top+bottom)/2)* height; +%> +

The ladder top <%=top%>,bottom<%=bottom%>and height<%=height%>is:<%=area%>

\ No newline at end of file diff --git "a/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/main.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/main.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..64e47e072c30675af466705e73dc1414aaa87663 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\345\220\264\346\206\266\350\261\252_2244310224/main.jsp" @@ -0,0 +1,25 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + + main + + + +
circle area:
+ top:
+ bottom:
+ height:
+
+ + + + + + + + + + + \ No newline at end of file