Java项目 1 - 学生成绩管理系统---采用 Servlet+Jsp+JavaBean+MySql 设计方式,

本文介绍了使用Servlet+Jsp+JavaBean+MySql设计的学生成绩管理系统,通过创建数据库class_db,包含admin、student、classes、course、enrol、teacher等表,实现了学生、课程、班级等数据的存储。同时,展示了如何插入数据及可能出现的错误处理,涉及数据库操作和Java连接数据库的sqlBean类文件。
摘要由CSDN通过智能技术生成

 

 

Enter password: ***
Welcome to the MySQL monitor.  Commands end with ; or \g.

 

create  database  class_db ;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| class_db           |
| da_database10      |
| mysql              |
| test               |
+--------------------+

mysql> use class_db;
Database changed

mysql> create table admin ( id int(8) not null primary key auto_increment,
    -> name varchar(30) ,
    -> password varchar(30) );
Query OK, 0 rows affected (0.64 sec)

mysql> show tables;
+--------------------+
| Tables_in_class_db |
+--------------------+
| admin              |
+--------------------+
1 row in set (0.06 sec)

 

 

 

 

mysql> create table student( id varchar(50) not null primary key ,
    -> name varchar(10) not null ,
    -> password varchar(50)  ,
    -> jiguan varchar(10) not null ,
    -> department varchar(10)  ,
    -> sex varchar(10)  ,
    -> mark int(11) ,
    -> tel varchar(50)  ,
    -> e_mail varchar(50)  );
Query OK, 0 rows affected (0.23 sec)

 


mysql> create table classes ( id varchar(50) not null  ,
    -> tea_id varchar(10) not null primary key ,
    -> cour_id varchar(10) not null  ,
    -> room_id varchar(50) not null  ,
    -> cour_time varchar(10) not null  );
Query OK, 0 rows affected (0.25 sec)

 

 

mysql> create table course ( id varchar(10) not null primary key  ,
    -> name varchar(20) not null  ,
    -> mark int(11) not null  ,
    -> prepare varchar(10)   ,
    -> dep varchar(10)   );
Query OK, 0 rows affected (0.20 sec)

 

 

mysql> create table enrol ( stu_id varchar(50) not null primary key  ,
    -> class_id varchar(50) not null  ,
    -> accept tinyint(1)  ,
    -> score varchar(50) );
Query OK, 0 rows affected (0.25 sec)

 

 

mysql> create table teacher ( id varchar(10) not null   ,
    -> name varchar(50) not null  ,
    -> title varchar(50) not null  ,
    -> password varchar(50) not null  );
Query OK, 0 rows affected (0.25 sec)

 

 

 

 

各表插入数据:


mysql> insert  into admin values(1 , 'limq',1 ) ;
Query OK, 1 row affected (0.48 sec)

 

 

 mysql> insert  into student values(1 , '韩博', 1, '山东' ,  '机械系', '女',  9,  3317138,'123@qq.com' ) ;

 

 

 


Enter password: ***
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.68-community MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use class_db;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_class_db |
+--------------------+
| admin              |
| classes            |
| course             |
| enrol              |
| student            |
| teacher            |
+--------------------+
6 rows in set (0.05 sec)

mysql> insert  into student values(1 , '韩博', 1, '山东' ,  '机械系', '女',  9,
 3317138, 123@qq.com ) ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '@qq.c
om )' at line 1
mysql> insert  into student values(1 , '韩博', 1, '山东' ,  '机械系', '女',  9,
 3317138, '123@qq.com' ) ;
Query OK, 1 row affected (0.33 sec)

mysql> select * from student;
+----+------+----------+--------+------------+------+------+---------+----------
--+
| id | name | password | jiguan | department | sex  | mark | tel     | e_mail
  |
+----+------+----------+--------+------------+------+------+---------+----------
--+
| 1  | 韩博 | 1        | 山东   | 机械系     | 女   |    9 | 3317138 | 123@qq.co
m |
+----+------+----------+--------+------------+------+------+---------+----------
--+
1 row in set (0.09 sec)

mysql> insert  into student values( 2 , '王强', 1, '陕西' ,  '机械系', '男',  5,
  3317138, '124@qq.com' ) ;
Query OK, 1 row affected (0.13 sec)

mysql> select * from student;
+----+------+----------+--------+------------+------+------+---------+----------
--+
| id | name | password | jiguan | department | sex  | mark | tel     | e_mail
  |
+----+------+----------+--------+------------+------+------+---------+----------
--+
| 1  | 韩博 | 1        | 山东   | 机械系     | 女   |    9 | 3317138 | 123@qq.co
m |
| 2  | 王强 | 1        | 陕西   | 机械系     | 男   |    5 | 3317138 | 124@qq.co
m |
+----+------+----------+--------+------------+------+------+---------+----------
--+
2 rows in set (0.00 sec)

mysql> insert  into student values( 3 , '张永', 1, '河南' ,  '电子系', '男',  0,
  113317138, '125@qq.com' ) ;
Query OK, 1 row affected (0.14 sec)

mysql> select * from student;
+----+------+----------+--------+------------+------+------+-----------+--------
----+
| id | name | password | jiguan | department | sex  | mark | tel       | e_mail
    |
+----+------+----------+--------+------------+------+------+-----------+--------
----+
| 1  | 韩博 | 1        | 山东   | 机械系     | 女   |    9 | 3317138   | 123@qq.
com |
| 2  | 王强 | 1        | 陕西   | 机械系     | 男   |    5 | 3317138   | 124@qq.
com |
| 3  | 张永 | 1        | 河南   | 电子系     | 男   |    0 | 113317138 | 125@qq.
com |
+----+------+----------+--------+------------+------+------+-----------+--------
----+
3 rows in set (0.00 sec)

mysql> insert  into classes values( 1 , 2, 1, 101 ,  Mon_1 ) ;
ERROR 1054 (42S22): Unknown column 'Mon_1' in 'field list'
mysql> show columns from classes;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| id        | varchar(50) | NO   |     | NULL    |       |
| tea_id    | varchar(10) | NO   | PRI | NULL    |       |
| cour_id   | varchar(10) | NO   |     | NULL    |       |
| room_id   | varchar(50) | NO   |     | NU

  • 3
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值