- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章JavaWeb实现学生信息管理系统(1)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
这是一个很简单的学生信息管理系统,会用到很多小知识,比如说:
JavaWeb之简单的学生信息管理系统(一) JavaWeb之简单的学生信息管理系统(二) JavaWeb之简单的学生信息管理系统(三) 。
实现一个简单的学生信息管理系统,具体实现功能有如下:
1.查询学生的息并列表展示 2.添加学生信息 3.删除学生信息 4.更新(修改)学生信息 5.模糊查询 。
1. 创建数据库stus以及创建数据库表stu 。
1
2
3
4
5
6
7
8
9
10
11
|
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. 项目框架 。
3. 导入项目需要的jar包 。
4. C3P0的配置文件c3p0-config.xml 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<
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
>
|
1. 实现Student类 。
【备:com.domain包下的Student.java】 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
package
com.domain;
import
java.util.Date;
/**
* 这是封装的学生对象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. 写一个类,判断字符串是否相等【TestUtils.java】 。
1
2
3
4
5
6
7
8
9
10
11
12
|
package
com.util;
public
class
TestUtils {
/**
* 判断某一个字符串是否为空
* @param s
* @return
*/
public
static
boolean
isEmpty(String s) {
return
s ==
null
|| s.length() ==
0
;
}
}
|
3. JDBCUtils02.java 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
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;
}
/**
* 获得连接对象
* @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
;
}
}
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/weixin_44270855/article/details/104236494 。
最后此篇关于JavaWeb实现学生信息管理系统(1)的文章就讲到这里了,如果你想了解更多关于JavaWeb实现学生信息管理系统(1)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
JavaWeb 接收Request请求参数的几种方式 1. HttpServletRequest request接收参数 @RequestMapping("/test1") public St
上次写了一篇JDBC工具类实现登录功能,但是只能在控制台实现输入用户名密码。这次使用了Servlet来实现登录功能,可以通过在页面上输入账号密码,然后提交表单,查询数据库,从而实现登录功能。 1、
mapper.xml文件 ? 1
session失效时间设置方法,具体方法如下所示: 1、java代码 <!--优先级是最高的--> ?
javaweb dbutils执行sql命令并遍历结果集时不能查到内容的原因及处理方法如下所示: 遍历结果集时只遍历bean对象才会只输出第一行那种内容(第一行是输出了userentity类实例化
javaWeb 四大域对象 1)和属性相关的方法 Object getAttribute(String name) 获取指定
javaweb 实现文件下载 不要再说用<a>标签下载了,这个会把文件打开而不是下载 例如: <a href="E:\MyDesktop\37fecd6
JavaWeb 简单分页的实现: 这次主要是讲解一下通过登录后对得到的数据进行分页,首先我们新建一个登录页面login.jsp,因为我们主要学习一下分页,所以登录验证的部分不再阐述,主要代码如下:
1.什么是EL自定义函数 EL自定义函数是在EL表达式中调用的某个java类的静态方法,这个静态方法需在web应用程序中进行配置才可以被EL表达式调用。 EL自定义函数可以扩展EL表达式的功能,
1、注解 注解Annotation,是一种类似注释的机制,在代码中添加注解可以在之后某时间使用这些信息。跟注释不同的是,注释是给我们看的,java虚拟机不会编译,注解也是不编译的,但是我们可以通
1 Spring基本特征 Spring是一个非常活跃的开源框架;它是一个基于Core来构架多层JavaEE系统的框架,它的主要目地是简化企业开发. Spring以一种非侵入式的方式来管理你的代
1、依赖注入(DI) 依赖注入听起来很高深的样子,其实白话就是:给属性赋值。一共有两种方法,第一是以构造器参数的形式,另外一种就是以setting方法的形式。 1 构造器注入 1 使用构造器
1、文件的上传和下载 1、文件上传的原理分析 1、文件上传的必要前提: &nbs
乱码的方式有很多,这里指出一种不容易想到的 *请确保您的页面单独访问正常,经过servlet请求转发时,有PrintWriter out = response.getWriter()不正常,没有正
最近在学习JavaWeb时,有用到鼠标移动事件,所以今天在这里记录一个相关的案例,同时也是对相关知识的一个巩固,效果为在鼠标移动到表格对应行列时,该行列的背景颜色发生变化。 效果如下: 其中
文件下载时,我们可能需要一次下载多个文件。批量下载文件时,需要将多个文件打包为zip,然后再下载。 实现思路有两种: 一是将所有文件先打包压缩为一个文件,然后下载这个压缩包, 二是一边压缩一边
一.Struts文件上传的思路 之前也讲过了FileUpload这个组件,功能很强大,但是操作繁琐复杂。这次,在Strust中也对文件上传有所支持,并FileUpload进行了包装,用起来方便了许多
EL全称 Expression Language(表达式语言),是jsp2.0最重要的特性之一,可以利用EL表达式来访问应用程序中的数据,来消除jsp页面中的java脚本。 el表达式的语法 e
1、ServletConfig讲解 1.1、配置Servlet初始化参数 在Servlet的配置文件web.xml中,可以使用一个或多个<init-param>标签为servl
1、Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术。 Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个
我是一名优秀的程序员,十分优秀!