资源简介
用IDEA开发的JavaWeb简易作业管理系统,使用MySql数据库,内含建表语句。
功能实现如下:
老师:添加作业,添加学生,查看作业情况
学生:提交作业
功能实现如下:
老师:添加作业,添加学生,查看作业情况
学生:提交作业
代码片段和文件信息
package com.java.code.Jdbc;
import com.java.code.Model.Homework;
import com.java.code.Model.Student;
import com.java.code.Model.StudentHomework;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class StudentHomeworkJdbc {
public static void main(String[] args) {
String a =“1“;
List list = selectAll(a);
for (StudentHomework sthw : list){
System.out.println(sthw.gethwId());
}
Homework hw = showHomeworkDetails(a);
System.out.println(hw.gethwtitle());
}
private static String url = “jdbc:mysql://127.0.0.1:3306/school?serverTimezone=Asia/Shanghai“;
private static String driverName = “com.mysql.cj.jdbc.Driver“;
/**
* 从student_homework表读取指定作业id 的所有记录,即某次作业的所有提交记录
* @return 返回结果list
*/
public static List selectAll(String hw_id) {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String sqlString = “SELECT * FROM student_homework where hw_id=“+hw_id;
List list = new ArrayList<>();
try (Connection connection = DriverManager.getConnection(url “root“ “12345ysp“)) {
try (Statement statement = connection.createStatement()) {
try (ResultSet resultSet = statement.executeQuery(sqlString)) {
//获取执行结果
while (resultSet.next()) {
StudentHomework sh = new StudentHomework();
sh.setsthwId(resultSet.getLong(“st_hw_id“));
sh.setstId(resultSet.getLong(“st_id“));
sh.sethwId(resultSet.getLong(“hw_id“));
sh.sethwtitle(resultSet.getString(“hw_title“));
sh.sethwContent(resultSet.getString(“hw_content“));
sh.setsubmitContent(resultSet.getString(“submit_content“));
sh.setsthwCreateTime(resultSet.getTimestamp(“st_hw_create_time“));
list.add(sh);
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
/**
* 向homework表添加作业记录
* @param homework 将要添加的homework
* @return true=>成功否则失败
*/
public static boolean addHomework(Homework homework){
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String sqlString = “insert into homework (hw_idhw_titlehw_contenthw_create_time) values(????)“;
int resultSet = 0;
try (Connection connection = DriverManager.getConnection(url “root“ “12345ysp“)) {
try (PreparedStatement ps = connection.prepareStatement(sqlString)) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\artifacts\
文件 563 2020-03-10 20:44 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\artifacts\JavaEE_HomeworkManager_war_exploded.xm
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\codest
文件 153 2020-03-10 20:44 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\codest
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\libraries\
文件 290 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\libraries\lib.xm
文件 276 2020-03-10 20:44 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\misc.xm
文件 291 2020-03-10 20:44 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\modules.xm
文件 10652 2020-03-10 22:41 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\.idea\workspace.xm
文件 1000 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\JavaEE-HomeworkManager.iml
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Jdbc\
文件 9138 2020-03-10 22:34 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Jdbc\StudentHomeworkJdbc.class
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Model\
文件 1283 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Model\Homework.class
文件 1083 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Model\Student.class
文件 1852 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Model\StudentHomework.class
目录 0 2020-03-10 22:49 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Servlet\
文件 2088 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Servlet\AddHomeworkServlet.class
文件 2020 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Servlet\AddStudentServlet.class
文件 1598 2020-03-10 20:46 JavaWeb-HomeworkManager\JavaEE-HomeworkManager\out\artifacts\JavaEE_HomeworkManager_war_exploded\WEB-INF\classes\com\java\code\Servlet\QueryStudentHomeworkServlet.class
............此处省略67个文件信息
相关资源
- JAVA仿QQ聊天71357
- java毕业设计:简单Java教务管理系统
- 尚硅谷_宋红康_IntelliJIDEA的安装、配置
- java版植物资源管理系统
- Java最强混淆放破解利器Zelix KlassMast
- java swing中文帮助文档
- 点数据的核密度分析
- 摄影平台系统 java毕业设计
- Java讲义4thcodes.rar
- Java面试宝典2018-最全面试资料
- javaweb项目+设计模式单例模式,工厂模
- 网上招聘系统
- JavaWeb网上书城项目 界面简洁漂亮 功
- java实现QQ项目
- mysql-connector-java-8.0.17.zip
- java socket即时聊天工具 可发文件 实现
- 大学生就业系统-论文-文档
- 基于java的学生管理系统源码
- JavaWeb客户管理系统
- mysql-connector-java-8.0.11
- jsp的网上购物商城
- JspLibrary.zip
- 网上花店的设计与实现毕业论文
- java编写电影购票系统新手专用
- 基于java电影售票系统新手专用类
- 基于java前后端简易电影购票系统新手
- java实现pdf上传、、在线预览、删除、
- Java实现物流跟踪查询+Demo+Word
- JAVA医药管理系统设计(论文+源代码)
- java旅游系统
评论
共有 条评论