JavaWeb實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(1)
這是一個(gè)很簡(jiǎn)單的學(xué)生信息管理系統(tǒng),會(huì)用到很多小知識(shí),比如說:
- 數(shù)據(jù)庫連接池
- DBUtils
- JSP、EL、JSTL
- MVC設(shè)計(jì)模式
JavaWeb之簡(jiǎn)單的學(xué)生信息管理系統(tǒng)(一)
JavaWeb之簡(jiǎn)單的學(xué)生信息管理系統(tǒng)(二)
JavaWeb之簡(jiǎn)單的學(xué)生信息管理系統(tǒng)(三)
一、需求分析
實(shí)現(xiàn)一個(gè)簡(jiǎn)單的學(xué)生信息管理系統(tǒng),具體實(shí)現(xiàn)功能有如下:
1.查詢學(xué)生的息并列表展示
2.添加學(xué)生信息
3.刪除學(xué)生信息
4.更新(修改)學(xué)生信息
5.模糊查詢
二、準(zhǔn)備工作
1. 創(chuàng)建數(shù)據(jù)庫stus以及創(chuàng)建數(shù)據(jù)庫表stu
CREATE DATABASE stus; USE stus; CREATE TABLE stu ( sid INT PRIMARY KEY AUTO_INCREMENT, sname VARCHAR (20), gender VARCHAR (5), phone VARCHAR (20), birthday DATE, hobby VARCHAR(50), info VARCHAR(200) );
2. 項(xiàng)目框架
3. 導(dǎo)入項(xiàng)目需要的jar包
4. C3P0的配置文件c3p0-config.xml
<c3p0-config> <default-config> <property name="driverClass">com.mysql.cj.jdbc.Driver</property> <property name="jdbcUrl">jdbc:mysql://localhost/stus?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT</property> <property name="user">root</property> <property name="password">root</property> <property name="initialPoolSize">10</property> <property name="maxIdleTime">30</property> <property name="maxPoolSize">100</property> <property name="minPoolSize">10</property> <property name="maxStatements">200</property> </default-config> </c3p0-config>
三、代碼準(zhǔn)備
1. 實(shí)現(xiàn)Student類
【備:com.domain包下的Student.java】
package com.domain; import java.util.Date; /** * 這是封裝的學(xué)生對(duì)象Bean * @author Administrator * */ public class Student { private int sid; private String sname; private String gender; private String phone; private String hobby; private String info; private Date birthday; public Student() { super(); } public Student(String sname, String gender, String phone, String hobby, String info, Date birthday) { super(); this.sname = sname; this.gender = gender; this.phone = phone; this.hobby = hobby; this.info = info; this.birthday = birthday; } public int getSid() { return sid; } public void setSid(int sid) { this.sid = sid; } public String getSname() { return sname; } public void setSname(String sname) { this.sname = sname; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getHobby() { return hobby; } public void setHobby(String hobby) { this.hobby = hobby; } public String getInfo() { return info; } public void setInfo(String info) { this.info = info; } }
2. 寫一個(gè)類,判斷字符串是否相等【TestUtils.java】
package com.util; public class TestUtils { /** * 判斷某一個(gè)字符串是否為空 * @param s * @return */ public static boolean isEmpty(String s) { return s == null || s.length() == 0; } }
3. JDBCUtils02.java
package com.util; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.sql.DataSource; import com.mchange.v2.c3p0.ComboPooledDataSource; public class JDBCUtil02 { static ComboPooledDataSource dataSource = null; static{ dataSource = new ComboPooledDataSource(); } public static DataSource getDataSource() { return dataSource; } /** * 獲得連接對(duì)象 * @return * @throws SQLException */ public static Connection getConn() throws SQLException{ return dataSource.getConnection(); } /** * 釋放資源 * @param conn * @param st * @param rs */ public static void release(Connection conn , Statement st , ResultSet rs){ closeRs(rs); closeSt(st); closeConn(conn); } public static void release(Connection conn , Statement st){ closeSt(st); closeConn(conn); } private static void closeRs(ResultSet rs){ try { if(rs != null){ rs.close(); } } catch (SQLException e) { e.printStackTrace(); }finally{ rs = null; } } private static void closeSt(Statement st){ try { if(st != null){ st.close(); } } catch (SQLException e) { e.printStackTrace(); }finally{ st = null; } } private static void closeConn(Connection conn){ try { if(conn != null){ conn.close(); } } catch (SQLException e) { e.printStackTrace(); }finally{ conn = null; } } }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- javaWeb實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- JavaWeb實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(3)
- JavaWeb倉(cāng)庫管理系統(tǒng)詳解
- 基于javaweb+jsp實(shí)現(xiàn)學(xué)生宿舍管理系統(tǒng)
- JavaWeb實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(2)
- 基于javaweb+jsp實(shí)現(xiàn)企業(yè)車輛管理系統(tǒng)
- 基于javaweb+jsp實(shí)現(xiàn)個(gè)人日記管理系統(tǒng)
- 基于javaweb+jsp實(shí)現(xiàn)企業(yè)財(cái)務(wù)記賬管理系統(tǒng)
- 基于javaweb+jsp的游泳館會(huì)員管理系統(tǒng)(附源碼)
- JavaWeb實(shí)現(xiàn)學(xué)生管理系統(tǒng)的超詳細(xì)過程
相關(guān)文章
基于Java反射技術(shù)實(shí)現(xiàn)簡(jiǎn)單IOC容器
這篇文章主要介紹了基于Java反射技術(shù)實(shí)現(xiàn)簡(jiǎn)單IOC容器,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07SpringBoot單元測(cè)試沒有執(zhí)行的按鈕問題及解決
這篇文章主要介紹了SpringBoot單元測(cè)試沒有執(zhí)行的按鈕問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-01-01詳解Springboot集成sentinel實(shí)現(xiàn)接口限流入門
這篇文章主要介紹了詳解Springboot集成sentinel實(shí)現(xiàn)接口限流入門,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11java實(shí)現(xiàn)簡(jiǎn)單的拼圖游戲
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單的拼圖游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-07-07詳解SSM框架下結(jié)合log4j、slf4j打印日志
本篇文章主要介紹了詳解SSM框架下結(jié)合log4j、slf4j打印日志,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11Java實(shí)現(xiàn)迷你圖書管理系統(tǒng)案例全程
這篇文章主要為大家詳細(xì)介紹了如何利用java語言實(shí)現(xiàn)簡(jiǎn)單的圖書管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-12-12