From 02e55b909b884b5b4cde42861acacbad87e80165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=94=E5=87=AF=E8=BE=89?= <2814283821@qq.com> Date: Sat, 20 May 2023 03:49:01 +0000 Subject: [PATCH 1/3] README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孔凯辉 <2814283821@qq.com> --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd4867e --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# JSP+Sevrlet网站开发 + +#### 介绍 +JSP+Sevrlet网站开发 + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) \ No newline at end of file -- Gitee From 5d789aa22506461b9f3d272e444565a18a45b869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=E5=AD=94=E5=87=AF=E8=BE=89=E2=80=9D?= <“2814283821@qq.com”> Date: Sat, 20 May 2023 11:17:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023-5-18\344\275\234\344\270\232.md" | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 "44 \345\255\224\345\207\257\350\276\211/2023-5-18\344\275\234\344\270\232.md" diff --git "a/44 \345\255\224\345\207\257\350\276\211/2023-5-18\344\275\234\344\270\232.md" "b/44 \345\255\224\345\207\257\350\276\211/2023-5-18\344\275\234\344\270\232.md" new file mode 100644 index 0000000..b6b3f37 --- /dev/null +++ "b/44 \345\255\224\345\207\257\350\276\211/2023-5-18\344\275\234\344\270\232.md" @@ -0,0 +1,161 @@ +| 1. MySQL中创建一个数据库student_db | | | +| ---------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| | [2](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_2) | | +| | [3](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_3) | 2. 库中创建student表 | +| | [4](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_4) | | +| | [5](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_5) | 3. 表中数据如下 | +| | [6](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_6) | | +| | [7](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_7) | 4. \| 编号 \| 姓名 \| 性别 \| | +| | [8](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_8) | \| ---- \| ---- \| ---- \| | +| | [9](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_9) | \| 1 \| 张三 \| 男 \| | +| | [10](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_10) | \| 2 \| 李四 \| 女 \| | +| | [11](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_11) | \| 3 \| 王五 \| 男 \| | +| | [12](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_12) | | +| | [13](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_13) | 5. 编写java 4个类,分别实现以下功能 | +| | [14](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_14) | | +| | [15](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_15) | 1. 查询功能,查询student中所有数据 | +| | [16](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_16) | 2. 添加功能 | +| | [17](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_17) | 3. 修改功能 | +| | [18](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_18) | 4. 删除功能 | +| | [19](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_19) | | +| | [20](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_20) | 6. 扩展题【预习题】 | +| | [21](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_21) | | +| | [22](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_22) | 1. 能否实现一个类中,用四个方法来实现上面4个类的功能 | +| | [23](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_23) | 2. 能否实现将查询的结果,封装成java对象 | +| | [24](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_24) | | +| | [25](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_25) | ```Java | +| | [26](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_26) | public class Add { | +| | [27](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_27) | public static void main(String[] args) { | +| | [28](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_28) | // 1.加载驱动 | +| | [29](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_29) | try { | +| | [30](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_30) | Class.forName("com.mysql.jdbc.Driver"); | +| | [31](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_31) | // 2.创建连接 | +| | [32](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_32) | Connection niubi = DriverManager.getConnection("jdbc:mysql://localhost:3306/mxdx?useSSL=false&useUnicode=true&characterEncoding=utf8", "root", "root"); | +| | [33](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_33) | // 3.编写sql语句 | +| | [34](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_34) | String sql="insert into student values (1,'张三','男')"; | +| | [35](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_35) | // 4.获取sql语句对象 | +| | [36](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_36) | Statement st= niubi.createStatement(); | +| | [37](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_37) | // 5.执行sql语句 | +| | [38](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_38) | int i = st.executeUpdate(sql); | +| | [39](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_39) | // 6.处理返回结果 | +| | [40](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_40) | if (i>0){ | +| | [41](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_41) | System.out.println("删除/添加/修改成功了"+i+"行"); | +| | [42](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_42) | }else { | +| | [43](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_43) | System.out.println("删除/添加/修改失败"); | +| | [44](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_44) | } | +| | [45](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_45) | // 7.释放资源 | +| | [46](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_46) | st.close(); | +| | [47](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_47) | niubi.close(); | +| | [48](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_48) | } catch (ClassNotFoundException e) { | +| | [49](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_49) | throw new RuntimeException(e); | +| | [50](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_50) | } catch (SQLException e) { | +| | [51](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_51) | throw new RuntimeException(e); | +| | [52](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_52) | } | +| | [53](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_53) | | +| | [54](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_54) | } | +| | [55](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_55) | } | +| | [56](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_56) | ``` | +| | [57](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_57) | | +| | [58](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_58) | ```java | +| | [59](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_59) | **public** **class** **Delete** { | +| | [60](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_60) | **public** **static** **void** **main**(**String**[] args) { | +| | [61](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_61) | // 1.加载驱动 | +| | [62](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_62) | **try** { | +| | [63](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_63) | **Class**.forName("com.mysql.jdbc.Driver"); | +| | [64](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_64) | // 2.创建连接 | +| | [65](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_65) | **Connection** niubi = **DriverManager**.getConnection("jdbc:mysql://localhost:3306/mxdx?useSSL=false&useUnicode=true&characterEncoding=utf8", "root", "root"); | +| | [66](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_66) | // 3.编写sql语句 | +| | [67](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_67) | **String** sql="delete from student where 编号=1"; | +| | [68](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_68) | // 4.获取sql语句对象 | +| | [69](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_69) | **Statement** st= niubi.createStatement(); | +| | [70](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_70) | // 5.执行sql语句 | +| | [71](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_71) | **int** i = st.executeUpdate(sql); | +| | [72](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_72) | // 6.处理返回结果 | +| | [73](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_73) | **if** (i>0){ | +| | [74](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_74) | **System**.out.println("删除/添加/修改成功了"+i+"行"); | +| | [75](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_75) | }**else** { | +| | [76](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_76) | **System**.out.println("删除/添加/修改失败"); | +| | [77](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_77) | } | +| | [78](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_78) | // 7.释放资源 | +| | [79](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_79) | st.close(); | +| | [80](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_80) | niubi.close(); | +| | [81](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_81) | } **catch** (**ClassNotFoundException** e) { | +| | [82](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_82) | **throw** **new** **RuntimeException**(e); | +| | [83](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_83) | } **catch** (**SQLException** e) { | +| | [84](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_84) | **throw** **new** **RuntimeException**(e); | +| | [85](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_85) | } | +| | [86](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_86) | | +| | [87](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_87) | } | +| | [88](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_88) | } | +| | [89](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_89) | ``` | +| | [90](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_90) | | +| | [91](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_91) | ```java | +| | [92](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_92) | **public** **class** **select** { | +| | [93](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_93) | **public** **static** **void** **main**(**String**[] args) { | +| | [94](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_94) | **try** { | +| | [95](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_95) | // 1.加载驱动类 | +| | [96](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_96) | **Class**.forName("com.mysql.jdbc.Driver"); | +| | [97](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_97) | // 2.创建连接 | +| | [98](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_98) | **String** url="jdbc:mysql://localhost:3306/mxdx?useSSL=false&useUnicode=true&characterEncoding=utf8"; | +| | [99](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_99) | **String** username="root"; | +| | [100](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_100) | **String** password="root"; | +| | [101](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_101) | **Connection** niubi = **DriverManager**.getConnection(url, username, password); | +| | [102](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_102) | // 3.编写sql语句 | +| | [103](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_103) | **String** sql="select *from student "; | +| | [104](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_104) | // 4.获取执行sql语句的对象 | +| | [105](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_105) | **Statement** st= niubi.createStatement(); | +| | [106](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_106) | // 5.执行sql语句 | +| | [107](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_107) | **ResultSet** rs = st.executeQuery(sql); | +| | [108](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_108) | // 6.处理返回结果 | +| | [109](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_109) | **System**.out.println("id\t"+"姓名\t"+"性别\t"); | +| | [110](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_110) | **while** (rs.next()){ | +| | [111](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_111) | **int** id=rs.getInt("编号"); | +| | [112](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_112) | **String** name=rs.getString("姓名"); | +| | [113](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_113) | **String** sex=rs.getString("性别"); | +| | [114](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_114) | **System**.out.println(id+"\t"+name+"\t"+sex); | +| | [115](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_115) | } | +| | [116](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_116) | // 7.释放资源 | +| | [117](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_117) | rs.close(); | +| | [118](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_118) | st.close(); | +| | [119](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_119) | niubi.close(); | +| | [120](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_120) | } **catch** (**ClassNotFoundException** e) { | +| | [121](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_121) | **throw** **new** **RuntimeException**(e); | +| | [122](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_122) | } **catch** (**SQLException** e) { | +| | [123](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_123) | **throw** **new** **RuntimeException**(e); | +| | [124](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_124) | } | +| | [125](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_125) | } | +| | [126](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_126) | } | +| | [127](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_127) | ``` | +| | [128](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_128) | | +| | [129](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_129) | ```java | +| | [130](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_130) | **public** **class** **Update** { | +| | [131](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_131) | **public** **static** **void** **main**(**String**[] args) { | +| | [132](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_132) | // 1.加载驱动 | +| | [133](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_133) | **try** { | +| | [134](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_134) | **Class**.forName("com.mysql.jdbc.Driver"); | +| | [135](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_135) | // 2.创建连接 | +| | [136](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_136) | **Connection** niubi = **DriverManager**.getConnection("jdbc:mysql://localhost:3306/mxdx?useSSL=false&useUnicode=true&characterEncoding=utf8", "root", "root"); | +| | [137](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_137) | // 3.编写sql语句 | +| | [138](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_138) | **String** sql="update student set 姓名='老六' where 编号=3" ; | +| | [139](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_139) | // 4.获取sql语句对象 | +| | [140](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_140) | **Statement** st= niubi.createStatement(); | +| | [141](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_141) | // 5.执行sql语句 | +| | [142](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_142) | **int** i = st.executeUpdate(sql); | +| | [143](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_143) | // 6.处理返回结果 | +| | [144](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_144) | **if** (i>0){ | +| | [145](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_145) | **System**.out.println("删除/添加/修改成功了"+i+"行"); | +| | [146](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_146) | }**else** { | +| | [147](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_147) | **System**.out.println("删除/添加/修改失败"); | +| | [148](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_148) | } | +| | [149](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_149) | // 7.释放资源 | +| | [150](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_150) | st.close(); | +| | [151](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_151) | niubi.close(); | +| | [152](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_152) | } **catch** (**ClassNotFoundException** e) { | +| | [153](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_153) | **throw** **new** **RuntimeException**(e); | +| | [154](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_154) | } **catch** (**SQLException** e) { | +| | [155](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_155) | **throw** **new** **RuntimeException**(e); | +| | [156](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_156) | } | +| | [157](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_157) | | +| | [158](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_158) | } | +| | [159](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_159) | } | +| | [160](https://gitee.com/gan-xiaoqiang/jsp_servlet/commit/fc87093681e157726cc62a6929794bd5204386a6#74ece147f4bb9664b3a4d60874d0ef3bf3d6efac_0_160) | ``` | \ No newline at end of file -- Gitee From 1590d80d28669f56e0dc82b95733763f0738e7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=E5=AD=94=E5=87=AF=E8=BE=89=E2=80=9D?= <“2814283821@qq.com”> Date: Sun, 21 May 2023 22:57:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023-5-20\344\275\234\344\270\232.md" | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 "44 \345\255\224\345\207\257\350\276\211/2023-5-20\344\275\234\344\270\232.md" diff --git "a/44 \345\255\224\345\207\257\350\276\211/2023-5-20\344\275\234\344\270\232.md" "b/44 \345\255\224\345\207\257\350\276\211/2023-5-20\344\275\234\344\270\232.md" new file mode 100644 index 0000000..cb98e14 --- /dev/null +++ "b/44 \345\255\224\345\207\257\350\276\211/2023-5-20\344\275\234\344\270\232.md" @@ -0,0 +1,80 @@ +| ``` | | | +| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| | [2](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_2) | import java.sql.*; | +| | [3](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_3) | | +| | [4](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_4) | public class words { | +| | [5](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_5) | public static void main(String[] args) { | +| | [6](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_6) | try { | +| | [7](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_7) | Statement stmt = register(); | +| | [8](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_8) | select(stmt); | +| | [9](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_9) | } catch (ClassNotFoundException e) { | +| | [10](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_10) | throw new RuntimeException(e); | +| | [11](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_11) | } catch (SQLException e) { | +| | [12](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_12) | throw new RuntimeException(e); | +| | [13](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_13) | } | +| | [14](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_14) | } | +| | [15](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_15) | public static Statement register() throws ClassNotFoundException, SQLException { | +| | [16](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_16) | Class.forName("com.mysql.jdbc.Driver"); | +| | [17](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_17) | //2.链接对象 | +| | [18](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_18) | String url ="jdbc:mysql://localhost:3306/test"; | +| | [19](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_19) | String username ="root"; | +| | [20](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_20) | String password ="root"; | +| | [21](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_21) | Connection conn = DriverManager.getConnection(url, username, password); | +| | [22](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_22) | Statement stmt = conn.createStatement(); | +| | [23](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_23) | return stmt; | +| | [24](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_24) | } | +| | [25](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_25) | public class test { | +| | [26](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_26) | private int age; | +| | [27](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_27) | private String name; | +| | [28](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_28) | private String sex; | +| | [29](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_29) | | +| | [30](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_30) | public int getAge() { | +| | [31](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_31) | return age; | +| | [32](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_32) | } | +| | [33](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_33) | | +| | [34](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_34) | public void setAge(int age) { | +| | [35](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_35) | this.age = age; | +| | [36](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_36) | } | +| | [37](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_37) | | +| | [38](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_38) | public String getName() { | +| | [39](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_39) | return name; | +| | [40](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_40) | } | +| | [41](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_41) | | +| | [42](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_42) | public void setName(String name) { | +| | [43](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_43) | this.name = name; | +| | [44](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_44) | } | +| | [45](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_45) | | +| | [46](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_46) | public String getSex() { | +| | [47](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_47) | return sex; | +| | [48](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_48) | } | +| | [49](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_49) | | +| | [50](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_50) | public void setSex(String sex) { | +| | [51](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_51) | this.sex = sex; | +| | [52](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_52) | } | +| | [53](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_53) | | +| | [54](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_54) | @Override | +| | [55](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_55) | public String toString() { | +| | [56](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_56) | return "test{" + | +| | [57](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_57) | "age=" + age + | +| | [58](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_58) | ", name='" + name + '\'' + | +| | [59](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_59) | ", sex='" + sex + '\'' + | +| | [60](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_60) | '}'; | +| | [61](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_61) | } | +| | [62](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_62) | | +| | [63](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_63) | public test(int age, String name, String sex) { | +| | [64](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_64) | this.age = age; | +| | [65](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_65) | this.name = name; | +| | [66](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_66) | this.sex = sex; | +| | [67](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_67) | } | +| | [68](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_68) | | +| | [69](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_69) | public test() { | +| | [70](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_70) | } | +| | [71](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_71) | class te extends test{ | +| | [72](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_72) | @Override | +| | [73](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_73) | public int getAge() { | +| | [74](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_74) | return super.getAge(); | +| | [75](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_75) | } | +| | [76](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_76) | } | +| | [77](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_77) | } | +| | [78](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_78) | | +| | [79](https://gitee.com/class-22-class-03/jsp_servlet/commit/4ea9d98de9df4b0076a9530123e44f0240e936f0#a0bbed02995c5c731f5726a165e1cbbc978650d2_0_79) | ``` | \ No newline at end of file -- Gitee