让你的DBUtils支持enum

本文通过解决DBUtils处理下划线字段及枚举类型的问题,展示了如何使用DBUtils进行数据库操作。通过对BeanProcessor类的扩展,实现了对特殊字段和类型的正确处理。

最近几天在研究Java分布式技术如:Socket、Mina、Web Service、Hessian、REST等。

今天早上看到DBUtils,试用了起来,并写了测试单元。

 

1、创建了一个日志表,用DBUtils读写日志,然后进行了测试,在测试过程中,发现

new BeanHandler<ActionLog>(ActionLog.class)

 这个过程中出现有些数据为空 ,仔细一看数据库字段,如:log_id,log_tag有下划线的都取不出数据来 。然后google了一下发现JE里有个文章正好解决了这个问题:http://www.iteye.com/topic/381714

 

2、根据文章说的在 org.apache.commons.dbutils.BeanProcessor 添加了个方法columnPropEquals(表字段和类属性比较)

    private boolean columnPropEquals(String columnName, String propName) {
   {
          return (columnName.replace("_", "").equalsIgnoreCase(propName.replace("_", "")));
   }}

    并且在mapColumnsToProperties 中调用些方法

    protected int[] mapColumnsToProperties(ResultSetMetaData rsmd,
            PropertyDescriptor[] props) throws SQLException {

        int cols = rsmd.getColumnCount();
        int columnToProperty[] = new int[cols + 1];
        Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND);

        for (int col = 1; col <= cols; col++) {
            String columnName = rsmd.getColumnLabel(col);
            
            if (null == columnName || 0 == columnName.length()) {
              columnName = rsmd.getColumnName(col);
            }
            
            for (int i = 0; i < props.length; i++) {
            	//在这里进行调用新的比较方法
                if (columnPropEquals(columnName, props[i].getName())) {
                    columnToProperty[col] = i;
                    break;
                }
            }
        }

        return columnToProperty;
    }
 

 3、继续跑单元测试,然后又报错

Exception in thread "main" java.sql.SQLException Cannot set  logType: incompatible types.

 然后我用DEBUG跟踪后发现是数据类型 的问题,BeanProcessor.callSetter 无法把Object 转成Enum类型

// Don't call setter if the value object isn't the right type 
            if (this.isCompatibleType(value, params[0])) {
                setter.invoke(target, new Object[] { value });
            }

 

4、找到BeanProcessor.callSetter 方法,在[3]中的if后面 添加了特有Enum类型的值设置

// Don't call setter if the value object isn't the right type 
            if (this.isCompatibleType(value, params[0])) {
                setter.invoke(target, new Object[] { value });
            }
            else if (params[0].isEnum())
            {
            	try {
            		//value == null时,让Domain设置默认值
            		//只有value != null时对进行转换设置值
            		if(value != null)
            		{
            			//Class转换对应enum
                		Class cz = Class.forName(params[0].getName());
    					setter.invoke(target, Enum.valueOf(cz, (String) value));
            		}
				} catch (ClassNotFoundException e) {
					throw new SQLException("Cannot set " + prop.getName() + ": incompatible types.");
				}
				
            }

 5、继续跑单元测试,成功

  ActionLog [logContent=测试, logId=1, logLevel=INFO, logSourceId=, logTag=测试, logType=ACTION, opdate=2010-09-08 05:53:22.0, opip=192.168.1.159, opuser=JWinder]

 

6、总结

有的时候发现很多开源的项目并没有我们想像得那么完美,当你发现不完美(缺陷)时,修正它,并把你的经验分享给每一个人,让别人站在你的时间上节约时间,所以希望大家一起分享你的快乐

 

 

 

7、附件,附上我的ActionLog和单元测试

ActionLog.java

public class ActionLog implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Long     logId;                     // 日志ID
	private LogType  logType = LogType.NORMAL;  // 日志类型
	private LogLevel logLevel = LogLevel.INFO;	// 事件级别
	private String   opuser;				    // 操作人ID
	private Date     opdate;                    // 操作时间
	private String   opip;                      // 操作IP
	private String   logSourceId;			    // 操作关联源对象ID
	private String   logTag;                    // 操作事件内容标签(提供更好的搜索)
	private String   logContent;                // 事件内容
	
	public enum LogType {
		/** 一般日志 */
		NORMAL("NORMAL"),
		
		/** 登录日志 */
		LOGIN("LOGIN"),
		
		/** 活动操作日志 */
		ACTION("ACTION"),
		
		/** 错误日志 */
		ERROR("ERROR"),
		;
		
		private String name;

		LogType(String name) {
			this.name = name;
		}
	
		public String getName() {
			return this.name;
		}
		
	}

	public enum LogLevel {
		
		INFO("INFO"),
		
		SUCCESS("SUCCESS"),
		
		WARN("WARN"),
		
		ERROR("ERROR"),
		
		;
		
		private String name;

		LogLevel(String name) {
			this.name = name;
		}
	
		public String getName() {
			return this.name;
		}
	}

	public Long getLogId() {
		return logId;
	}

	public void setLogId(Long logId) {
		this.logId = logId;
	}

	public LogType getLogType() {
		return logType;
	}

	public void setLogType(LogType logType) {
		this.logType = logType;
	}

	public LogLevel getLogLevel() {
		return logLevel;
	}

	public void setLogLevel(LogLevel logLevel) {
		this.logLevel = logLevel;
	}

	public String getOpuser() {
		return opuser;
	}

	public void setOpuser(String opuser) {
		this.opuser = opuser;
	}

	public Date getOpdate() {
		return opdate;
	}

	public void setOpdate(Date opdate) {
		this.opdate = opdate;
	}

	public String getOpip() {
		return opip;
	}

	public void setOpip(String opip) {
		this.opip = opip;
	}

	public String getLogSourceId() {
		return logSourceId;
	}

	public void setLogSourceId(String logSourceId) {
		this.logSourceId = logSourceId;
	}

	public String getLogTag() {
		return logTag;
	}

	public void setLogTag(String logTag) {
		this.logTag = logTag;
	}

	public String getLogContent() {
		return logContent;
	}

	public void setLogContent(String logContent) {
		this.logContent = logContent;
	}

	@Override
	public String toString() {
		return "ActionLog [logContent=" + logContent + ", logId=" + logId
				+ ", logLevel=" + logLevel + ", logSourceId=" + logSourceId
				+ ", logTag=" + logTag + ", logType=" + logType + ", opdate="
				+ opdate + ", opip=" + opip + ", opuser=" + opuser + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((logId == null) ? 0 : logId.hashCode());
		result = prime * result
				+ ((logLevel == null) ? 0 : logLevel.hashCode());
		result = prime * result + ((logType == null) ? 0 : logType.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ActionLog other = (ActionLog) obj;
		if (logId == null) {
			if (other.logId != null)
				return false;
		} else if (!logId.equals(other.logId))
			return false;
		if (logLevel == null) {
			if (other.logLevel != null)
				return false;
		} else if (!logLevel.equals(other.logLevel))
			return false;
		if (logType == null) {
			if (other.logType != null)
				return false;
		} else if (!logType.equals(other.logType))
			return false;
		return true;
	}
	
	public static String getInsertSQL()
	{
		return ("INSERT INTO action_log (log_type, log_level, opuser, opdate, opip, log_source_id, log_tag, log_content) values (?, ?, ?, ?, ?, ?, ?, ?)");
	}
	
	public static Object[] toArray(ActionLog log)
	{
		return new Object[] {log.logType, log.logLevel, log.opuser, log.opdate, log.opip, log.logSourceId, log.logTag, log.logContent};
	}
	
	public static ActionLog getTestActionLog()
	{
		ActionLog log = new ActionLog();
		log.setLogType(LogType.ACTION);
		log.setLogLevel(LogLevel.INFO);
		log.setOpuser("JWinder");
		log.setOpdate(new Date());
		log.setOpip("192.168.1.159");
		log.setLogSourceId("");
		log.setLogTag("测试 操作日志");
		log.setLogContent("测试日志系统数据");
		return log;
	}
	
	public static void main(String[] args) {
		System.err.println(LogType.ACTION);
	}
	
}

 action_log表SQL

 create database logservice;
    use logservice;

	drop table `logservice`.`action_log`;
	
    create table `logservice`.`action_log`(
        `log_id` INT not null auto_increment,
       `log_type` VARCHAR(16) not null,
       `log_level` VARCHAR(16) not null,
       `opuser` VARCHAR(32) not null,
       `opdate` DATETIME not null,
       `opip` VARCHAR(32) not null,
       `log_source_id` VARCHAR(64),
       `log_tag` VARCHAR(256),
       `log_content` TEXT not null,
        primary key (`log_id`)
    );

 

DBUtilsTest.java

public class DBUtilsTest {
	
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
//		Connection conn = null;  
//        Statement stmt = null;  
//        ResultSet rs = null;  
//        Class.forName("com.mysql.jdbc.Driver");
//        conn = DriverManager.getConnection("jdbc:mysql://192.168.1.82:3306/logservice", "root", "123456");  
//            stmt = conn.createStatement();  
//            stmt.executeUpdate("INSERT INTO action_log (log_type, log_level, opuser, opdate, opip, log_source_id, log_tag, log_content) values " +
//            		"('ACTION', 'INFO', 'JWinder','2010-09-08 05:53:22.123', '192.168.1.159', '', '测试 操作日志', '测试日志系统数据')");
            
		DBUtilsTest example = new DBUtilsTest();
		//example.batch();
		//example.fillStatement();
		//example.query();
		//example.update();
		example.qq();
		example.closeDataSource();
	}

	private DataSource dataSource = null;
	private QueryRunner runner = null;

	public DBUtilsTest() {
		initDataSource();
		runner = new QueryRunner(dataSource);
	}

	private void closeDataSource() throws SQLException {
		((BasicDataSource) dataSource).close();
	}
	private DataSource initDataSource() {
		if (dataSource == null) {
			BasicDataSource basicDs = new BasicDataSource();
			basicDs.setDriverClassName("com.mysql.jdbc.Driver");
			basicDs.setUrl("jdbc:mysql://192.168.1.82:3306/logservice");
			basicDs.setUsername("root");
			basicDs.setPassword("123456");
			this.dataSource = basicDs;
		}
		return dataSource;
	}

	private void qq() throws SQLException
	{
		String sql = "SELECT * FROM action_log WHERE log_id = ?";
		ActionLog r4 = runner.query(sql, new BeanHandler<ActionLog>(ActionLog.class), "1");
		System.out.println("  " + r4.toString());
	}
}
ava实现Web学生选课管理系统 一、系统介绍 1.软件环境 2.系统功能 3.数据库 二、系统展示 1.登录页面 2.学生-主页面 3.学生-查看个人信息 4.学生-选择课程 5.学生-查看已选课程 6.教师-主页面 7.教师-查看个人信息 8.教师-评分 9.教师-查看任课信息 10.管理员-主页面 11.管理员-管理员功能-查看个人信息 12.管理员-管理员功能-添加新的管理员 13.管理员-学生功能-添加学生 14.管理员-学生功能-获取所有学生 15.管理员-课程功能-添加课程 16.管理员-课程功能-查询课程 17.管理员-教师功能-添加教师 18.管理员-教师功能-获取所有教师 三、部分代码 AdminDaoImpl.java CourseDaoImpl.java StudentCourseTeacherDaoImpl.java StudentDaoImpl.java TeacherCourseDaoImpl.javab TeacherDaoImpl.java addAdmin.jsp addCourse.jsp addStudent.jsp addTeacher.jsp 四、其他 1.其他系统实现 JavaWeb系统系列实现 JavaSwing系统系列实现 2.获取源码 3.备注 4.鸡汤 一、系统介绍 1.软件环境 Java:jdk1.8 Mysql:8.0.13 Tomcat:8.5.23 2.系统功能 学生 1.查看个人信息 2.选课 3.查看已选课程 教师 1.查看个人信息 2.评分 3.查看任课课程 管理员 1.管理员功能 (1).查看个人信息 (2).添加新的管理员 2.学生功能 (1).添加学生 (2).获取所有学生 3.课程功能 (1).添加课程 (2).查询课程 4.教师功能 (1).添加教师 (2)获取所有教师 3.数据库 /* Navicat Premium Data Transfer Source Server : MySQL Source Server Type : MySQL Source Server Version : 80013 Source Host : localhost:3306 Source Schema : jsp_servlet_selectcourse Target Server Type : MySQL Target Server Version : 80013 File Encoding : 65001 Date: 23/06/2021 20:46:30 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for t_admin -- ---------------------------- DROP TABLE IF EXISTS `t_admin`; CREATE TABLE `t_admin` ( `userid` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `username` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `age` int(3) NULL DEFAULT NULL, `score` decimal(5, 1) NULL DEFAULT NULL, `introduction` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `enterdate` date NULL DEFAULT NULL, PRIMARY KEY (`userid`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_admin -- ---------------------------- INSERT INTO `t_admin` VALUES ('admin', '管理员', 'admin', 21, 100.0, ' ', '2018-06-12'); INSERT INTO `t_admin` VALUES ('admin1', '水坚石青', 'admin1', 25, 99.0, '', '2021-06-22'); -- ---------------------------- -- Table structure for t_class -- ---------------------------- DROP TABLE IF EXISTS `t_class`; CREATE TABLE `t_class` ( `classno` int(4) NOT NULL AUTO_INCREMENT, `cname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `cteacher` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `classroom` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`classno`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1531 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_class -- ---------------------------- INSERT INTO `t_class` VALUES (1520, '软工', '赵丽', '综阶1'); INSERT INTO `t_class` VALUES (1521, '软工', '齐兴斌', '综阶2'); INSERT INTO `t_class` VALUES (1522, '软工', '张志斌', '综阶3'); INSERT INTO `t_class` VALUES (1523, '软工', '郭小英', '综阶5'); INSERT INTO `t_class` VALUES (1524, '软工', '郭新峰', '综阶6'); INSERT INTO `t_class` VALUES (1525, '软工', '王若慧', '综阶7'); INSERT INTO `t_class` VALUES (1526, '软工', '贾春华', '综阶8'); INSERT INTO `t_class` VALUES (1527, '软工', '朱云雷', '综阶9'); INSERT INTO `t_class` VALUES (1528, '软工', '李雪梅', '综阶10'); INSERT INTO `t_class` VALUES (1529, '软工', '张举 ', '综阶11'); INSERT INTO `t_class` VALUES (1530, '软工', '米晓萍', '综阶12'); INSERT INTO `t_class` VALUES (1531, '软工', '张建英', '综阶13'); -- ---------------------------- -- Table structure for t_course -- ---------------------------- DROP TABLE IF EXISTS `t_course`; CREATE TABLE `t_course` ( `cno` int(4) NOT NULL AUTO_INCREMENT, `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `credit` int(1) NULL DEFAULT NULL, `periodstart` date NULL DEFAULT NULL, `periodend` date NULL DEFAULT NULL, PRIMARY KEY (`cno`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1009 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_course -- ---------------------------- INSERT INTO `t_course` VALUES (1001, '数据库', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1002, '数据结构', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1003, 'j2ee', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1004, '计算机网络', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1005, '计算机组成原理', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1007, '编译原理', 4, '2018-02-01', '2018-08-08'); INSERT INTO `t_course` VALUES (1008, 'C语言', 4, '2018-02-01', '2018-02-01'); INSERT INTO `t_course` VALUES (1009, 'c++', 4, '2018-01-02', '2018-05-28'); INSERT INTO `t_course` VALUES (1010, '1', 1, '2021-06-22', '2021-06-22'); -- ---------------------------- -- Table structure for t_sc -- ---------------------------- DROP TABLE IF EXISTS `t_sc`; CREATE TABLE `t_sc` ( `sno` int(10) NOT NULL, `cno` int(4) NOT NULL, `tno` int(4) NOT NULL, `score` decimal(5, 2) NULL DEFAULT NULL, PRIMARY KEY (`sno`, `cno`, `tno`) USING BTREE, INDEX `t_sc_ibfk_2`(`cno`) USING BTREE, INDEX `t_sc_ibfk_3`(`tno`) USING BTREE, CONSTRAINT `t_sc_ibfk_1` FOREIGN KEY (`sno`) REFERENCES `t_student` (`sno`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `t_sc_ibfk_2` FOREIGN KEY (`cno`) REFERENCES `t_course` (`cno`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `t_sc_ibfk_3` FOREIGN KEY (`tno`) REFERENCES `t_teacher` (`tno`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_sc -- ---------------------------- INSERT INTO `t_sc` VALUES (2015001, 1002, 1001, 100.00); INSERT INTO `t_sc` VALUES (2015001, 1004, 1001, 99.00); INSERT INTO `t_sc` VALUES (2015001, 1004, 1006, NULL); INSERT INTO `t_sc` VALUES (2015001, 1005, 1002, NULL); INSERT INTO `t_sc` VALUES (2015001, 1007, 1004, NULL); INSERT INTO `t_sc` VALUES (2015001, 1008, 1002, NULL); INSERT INTO `t_sc` VALUES (2015001, 1008, 1004, NULL); INSERT INTO `t_sc` VALUES (2015001, 1008, 1005, NULL); -- ---------------------------- -- Table structure for t_student -- ---------------------------- DROP TABLE IF EXISTS `t_student`; CREATE TABLE `t_student` ( `sno` int(9) NOT NULL AUTO_INCREMENT, `password` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `sname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `phone` bigint(11) NULL DEFAULT NULL, `sex` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `birthday` date NULL DEFAULT NULL, `classno` int(4) NULL DEFAULT NULL, `remark` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`sno`) USING BTREE, INDEX `t_student_ibfk_1`(`classno`) USING BTREE, CONSTRAINT `t_student_ibfk_1` FOREIGN KEY (`classno`) REFERENCES `t_class` (`classno`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB AUTO_INCREMENT = 2015570 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_student -- ---------------------------- INSERT INTO `t_student` VALUES (2015001, '123456', '李四', 15788888888, '女', '2021-06-22', 1525, '优秀'); INSERT INTO `t_student` VALUES (2015002, '123456', '王茹', 15788888888, '女', '2018-05-28', 1520, '良好'); INSERT INTO `t_student` VALUES (2015003, '123456', '张三', 15788888888, '女', '2018-05-28', 1520, '良好'); INSERT INTO `t_student` VALUES (2015004, '123456', '王五', 15788888888, '女', '2018-05-28', 1520, '优秀'); INSERT INTO `t_student` VALUES (2015005, '123456', '李浩', 15788888888, '女', '2018-05-28', 1520, '合格'); INSERT INTO `t_student` VALUES (2015006, '123456', '黄县', 15788888888, '女', '2018-05-28', 1520, '良好'); INSERT INTO `t_student` VALUES (2015007, '123456', '钱一', 15788888888, '女', '2018-05-28', 1520, '优秀'); INSERT INTO `t_student` VALUES (2015009, '123456', '赵括', 15788888888, '女', '2018-05-28', 1520, '优秀'); INSERT INTO `t_student` VALUES (2015010, '123456', '赵括', 15788888888, '女', '2018-05-28', 1520, '优秀'); -- ---------------------------- -- Table structure for t_tc -- ---------------------------- DROP TABLE IF EXISTS `t_tc`; CREATE TABLE `t_tc` ( `cno` int(4) NOT NULL, `tno` int(4) NOT NULL, PRIMARY KEY (`cno`, `tno`) USING BTREE, INDEX `t_tc_ibfk_2`(`tno`) USING BTREE, CONSTRAINT `t_tc_ibfk_1` FOREIGN KEY (`cno`) REFERENCES `t_course` (`cno`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `t_tc_ibfk_2` FOREIGN KEY (`tno`) REFERENCES `t_teacher` (`tno`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_tc -- ---------------------------- INSERT INTO `t_tc` VALUES (1001, 1001); INSERT INTO `t_tc` VALUES (1002, 1001); INSERT INTO `t_tc` VALUES (1004, 1001); INSERT INTO `t_tc` VALUES (1009, 1001); INSERT INTO `t_tc` VALUES (1005, 1002); INSERT INTO `t_tc` VALUES (1008, 1002); INSERT INTO `t_tc` VALUES (1002, 1003); INSERT INTO `t_tc` VALUES (1004, 1003); INSERT INTO `t_tc` VALUES (1007, 1004); INSERT INTO `t_tc` VALUES (1008, 1004); INSERT INTO `t_tc` VALUES (1008, 1005); INSERT INTO `t_tc` VALUES (1004, 1006); -- ---------------------------- -- Table structure for t_teacher -- ---------------------------- DROP TABLE IF EXISTS `t_teacher`; CREATE TABLE `t_teacher` ( `tno` int(4) NOT NULL AUTO_INCREMENT, `tname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `phone` bigint(11) NULL DEFAULT NULL, `hiredate` date NULL DEFAULT NULL, `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`tno`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1006 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of t_teacher -- ---------------------------- INSERT INTO `t_teacher` VALUES (1001, '张志斌', '123456', 15788888888, '2017-07-20', '张老师是一个超级幽默的老师,教学认真,态度友好,有自己独有的教学方法,深得学生喜爱'); INSERT INTO `t_teacher` VALUES (1002, '白茹意', '123456', 15766666666, '2018-03-06', '白老师工作认真负责,不推卸责任'); INSERT INTO `t_teacher` VALUES (1003, '郭新峰', '123456', 15733333333, '2018-05-14', '<span style=\"font-family:Arial Black;\"><span style=\"color:#E53333;\"><span style=\"color:#E53333;\">郭老师很认真负责</span></span></span>'); INSERT INTO `t_teacher` VALUES (1004, '赵丽', '123456', 15722222222, '2018-04-03', NULL); INSERT INTO `t_teacher` VALUES (1005, '齐兴斌', '123456', 15711111111, '2004-05-28', NULL); INSERT INTO `t_teacher` VALUES (1006, '尹少平', '123456', 15777777777, '2014-06-11', NULL); SET FOREIGN_KEY_CHECKS = 1; AI写代码 sql 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 二、系统展示 1.登录页面 2.学生-主页面 3.学生-查看个人信息 4.学生-选择课程 5.学生-查看已选课程 6.教师-主页面 7.教师-查看个人信息 8.教师-评分 9.教师-查看任课信息 10.管理员-主页面 11.管理员-管理员功能-查看个人信息 12.管理员-管理员功能-添加新的管理员 13.管理员-学生功能-添加学生 14.管理员-学生功能-获取所有学生 15.管理员-课程功能-添加课程 16.管理员-课程功能-查询课程 17.管理员-教师功能-添加教师 18.管理员-教师功能-获取所有教师 三、部分代码 AdminDaoImpl.java package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.util.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import com.bluehonour.sscs.dao.AdminDao; import com.bluehonour.sscs.entity.Admin; import com.bluehonour.sscs.util.DBUtils; public class AdminDaoImpl implements AdminDao{ @Override public Admin find(String userId, String password) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Admin admin = null; try { //建立连接 connection = DBUtils.getConnection(); //向数据库发送sql命令并得到结果 String sql = "select * from t_admin where userid = ? and password = ?"; preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, userId); preparedStatement.setString(2, password); rs = preparedStatement.executeQuery(); //处理返回结果 if(rs.next()) { //取出结果集当前行各个字段的值 String userName = rs.getString("username"); int age = rs.getInt("age"); double score = rs.getDouble("score"); Date enterDate = rs.getDate("enterdate"); String introduction = rs.getString("introduction"); //封装成对象 admin = new Admin(userId, userName, password, age, score, enterDate, introduction); } } catch (SQLException e) { e.printStackTrace(); } finally { //关闭数据库资源 DBUtils.closeAll(rs, preparedStatement, connection); } return admin; } @Override public int save(Admin admin) { String sql = "insert into t_admin values(?,?,?,?,?,?,?)"; Object[] params = {admin.getUserId(),admin.getUserName(),admin.getPassword(),admin.getAge(), admin.getScore(),admin.getIntroduction(),admin.getEnterDate()}; return DBUtils.executeUpdate(sql, params); } } AI写代码 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 CourseDaoImpl.java package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.bluehonour.sscs.dao.CourseDao; import com.bluehonour.sscs.entity.Course; import com.bluehonour.sscs.util.DBUtils; public class CourseDaoImpl implements CourseDao{ @Override public int save(Course course) { String sql = "insert into t_course (name,credit,periodstart,periodend) values(?,?,?,?) "; Object[] params = {course.getName(), course.getCredit(), course.getPeriodstart(), course.getPeriodend()}; return DBUtils.executeUpdate(sql, params); } @Override public List<Course> findAll() { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Course> list = new ArrayList<Course>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_course order by cno"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行各个字段的值 int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); Date periodstart = rs.getDate("periodstart"); Date periodend = rs.getDate("periodend"); // 封装成对象 Course course = new Course(cno,name, credit, periodstart, periodend); list.add(course); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } } AI写代码 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 StudentCourseTeacherDaoImpl.java package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.bluehonour.sscs.dao.StudentCourseTeacherDao; import com.bluehonour.sscs.entity.Course; import com.bluehonour.sscs.entity.StudentCourse; import com.bluehonour.sscs.entity.Teacher; import com.bluehonour.sscs.util.DBUtils; public class StudentCourseTeacherDaoImpl implements StudentCourseTeacherDao { @Override public int save(int sno, int cno, int tno) { String sql = "insert into t_sc(sno,cno,tno) values(?,?,?)"; Object[] params = {sno,cno,tno}; return DBUtils.executeUpdate(sql, params); } @Override public List<Course> findSelectedCourse(int sno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Course> list = new ArrayList<Course>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_course c" + " join t_sc sc" + " on (c.cno = sc.cno)" + " join t_teacher t" + " on (sc.tno = t.tno)" + " where sno = " + sno; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行课程各个字段的值 int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); Date periodstart = rs.getDate("periodstart"); Date periodend = rs.getDate("periodend"); // 封装成课程对象 Course course = new Course(cno,name, credit, periodstart, periodend); //取出结果集中教师各个字段的值 int tno = rs.getInt("tno"); String tname = rs.getString("tname"); String password = rs.getString("password"); long phone = rs.getLong("phone"); Date hiredate = rs.getDate("hiredate"); String remark = rs.getString("remark"); //封装成教师对象 Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark); //将教师加入课程 course.setTeacher(teacher); list.add(course); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } @Override public List<Course> findSelectableCourse(int sno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Course> list = new ArrayList<Course>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "SELECT c.*, t.* FROM t_tc a " + "LEFT JOIN t_course c " + "ON a.cno = c.cno " + "LEFT JOIN t_teacher t " + "ON a.tno = t.tno " + "WHERE (a.cno, a.tno) NOT IN " + "( SELECT cno,tno " + "FROM t_sc " + "WHERE sno = " + sno +") "; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行课程各个字段的值 int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); Date periodstart = rs.getDate("periodstart"); Date periodend = rs.getDate("periodend"); // 封装成课程对象 Course course = new Course(cno,name, credit, periodstart, periodend); //取出结果集中教师各个字段的值 int tno = rs.getInt("tno"); String tname = rs.getString("tname"); String password = rs.getString("password"); long phone = rs.getLong("phone"); Date hiredate = rs.getDate("hiredate"); String remark = rs.getString("remark"); //封装成教师对象 Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark); //将教师加入课程 course.setTeacher(teacher); list.add(course); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } @Override public int removeStudentDistributedCourse(int sno, int cno, int tno) { String sql = "delete from t_sc where sno = ? and cno = ? and tno = ?"; Object[] params = {sno,cno,tno}; return DBUtils.executeUpdate(sql, params); } @Override public List<StudentCourse> getSelectedStudentAndCourse(int tno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<StudentCourse> list = new ArrayList<StudentCourse>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "SELECT" + " s.sno," + " s.sname," + " s.classno," + " clazz.cname," + " c.cno," + " c. NAME," + " c.credit," + " sc.score" + " FROM" + " t_student s" + " LEFT JOIN t_class clazz ON clazz.classno = s.classno" + " LEFT JOIN t_sc sc ON sc.sno = s.sno" + " LEFT JOIN t_course c ON c.cno = sc.cno" + " WHERE" + " sc.tno = " + tno + " ORDER BY" + " c.cno," + " s.sno"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); int sno = rs.getInt("sno"); int classno = rs.getInt("classno"); String sname = rs.getString("sname"); String cname = rs.getString("cname"); double score = rs.getDouble("score"); //封装成教师对象 StudentCourse sc = new StudentCourse(sno, sname, classno, cname, cno, name, credit, score); list.add(sc); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } @Override public int courseRemark(int sno, int cno, int tno, double score) { String sql = "update t_sc set score = ? where sno = ? and cno = ? and tno = ?"; Object[] params = {score,sno,cno,tno}; return DBUtils.executeUpdate(sql, params); } } AI写代码 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 StudentDaoImpl.java package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.bluehonour.sscs.dao.StudentDao; import com.bluehonour.sscs.entity.ClassInfo; import com.bluehonour.sscs.entity.CriteriaStudent; import com.bluehonour.sscs.entity.Student; import com.bluehonour.sscs.util.DBUtils; public class StudentDaoImpl implements StudentDao { @Override public int save(Student stu) { String sql = "insert into t_student(password,sname,phone,sex,birthday,classno,remark) values(?,?,?,?,?,?,?)"; Object[] params = { stu.getPassword(), stu.getSname(), stu.getPhone(), stu.getSex(), stu.getBirthday(), stu.getClassno(), stu.getRemark() }; return DBUtils.executeUpdate(sql, params); } @Override public List<Student> findAll() { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Student student = null; List<Student> stuList = new ArrayList<Student>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_student"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行各个字段的值 int sno = rs.getInt("sno"); String password = rs.getString("password"); String sname = rs.getString("sname"); long phone = rs.getLong("phone"); String sex = rs.getString("sex"); Date birthday = rs.getDate("birthday"); int classno = rs.getInt("classno"); String remark = rs.getString("remark"); // 封装成对象 student = new Student(sno,password, sname, phone, sex, birthday, classno, remark); stuList.add(student); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return stuList; } @Override public int del(int sno) { String sql = "delete from t_student where sno = ?"; Object[] params = {sno }; return DBUtils.executeUpdate(sql, params); } @Override public Student findById(int sno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Student student = null; try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_student where sno = " + sno; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 if (rs.next()) { // 取出结果集当前行各个字段的值 String password = rs.getString("password"); String sname = rs.getString("sname"); long phone = rs.getLong("phone"); String sex = rs.getString("sex"); Date birthday = rs.getDate("birthday"); int classno = rs.getInt("classno"); String remark = rs.getString("remark"); // 封装成对象 student = new Student(sno,password, sname, phone, sex, birthday, classno, remark); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return student; } @Override public int update(Student stu) { String sql = "update t_student set sname=?,password=?,phone=?,birthday=?,sex=?,classno=?,remark=? where sno=?"; Object[] params = { stu.getSname(),stu.getPassword(),stu.getPhone(),stu.getBirthday(),stu.getSex(),stu.getClassno(), stu.getRemark(),stu.getSno() }; return DBUtils.executeUpdate(sql, params); } @Override public Student find(String sno, String password) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Student student = null; try { //建立连接 connection = DBUtils.getConnection(); //向数据库发送sql命令并得到结果 String sql = "select * from t_student where sno = ? and password = ?"; preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, sno); preparedStatement.setString(2, password); rs = preparedStatement.executeQuery(); //处理返回结果 if(rs.next()) { //取出结果集当前行各个字段的值 String sname = rs.getString("sname"); long phone = rs.getLong("phone"); String sex = rs.getString("sex"); Date birthday = rs.getDate("birthday"); int classno = rs.getInt("classno"); String remark = rs.getString("remark"); //封装成对象 student = new Student(Integer.parseInt(sno), password, sname, phone, sex, birthday, classno, remark); } } catch (SQLException e) { e.printStackTrace(); } finally { //关闭数据库资源 DBUtils.closeAll(rs, preparedStatement, connection); } return student; } @Override public List<ClassInfo> getClassInfo() { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; ClassInfo clazz = null; List<ClassInfo> list = new ArrayList<ClassInfo>(); try { //建立连接 connection = DBUtils.getConnection(); //向数据库发送sql命令并得到结果 String sql = "select * from t_class"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); //处理返回结果 while(rs.next()) { //取出结果集当前行各个字段的值 int classno = rs.getInt("classno"); String cname = rs.getString("cname"); String cteacher = rs.getString("cteacher"); String classroom = rs.getString("classroom"); //封装成对象 clazz = new ClassInfo(classno, cname, cteacher, classroom); list.add(clazz); } } catch (SQLException e) { e.printStackTrace(); } finally { //关闭数据库资源 DBUtils.closeAll(rs, preparedStatement, connection); } return list; } @Override public List<Student> getForListWithCriteriaStudent(CriteriaStudent student) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Student> stuList = new ArrayList<Student>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 StringBuffer sql = new StringBuffer(); sql.append("select * from t_student"); if(!student.getSno().equals("")) { sql.append(" and sno like '%"+ student.getSno() +"%'"); } if(!student.getSname().equals("")) { sql.append(" and sname like '%"+ student.getSname() +"%'"); } if(!student.getSex().equals("")) { sql.append(" and sex ='"+ student.getSex() +"'"); } if(!student.getClassno().equals("")) { sql.append(" and classno like '%"+ student.getClassno() +"%'"); } if(!student.getRemark().equals("")) { sql.append(" and remark='"+ student.getRemark() +"'"); } String SQL = sql.toString(); SQL = SQL.replaceFirst("and", "where"); System.out.println(SQL); preparedStatement = connection.prepareStatement(SQL); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行各个字段的值 int sno = rs.getInt("sno"); String password = rs.getString("password"); String sname = rs.getString("sname"); long phone = rs.getLong("phone"); String sex = rs.getString("sex"); Date birthday = rs.getDate("birthday"); int classno = rs.getInt("classno"); String remark = rs.getString("remark"); // 封装成对象 Student stu = new Student(sno,password, sname, phone, sex, birthday, classno, remark); stuList.add(stu); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return stuList; } } AI写代码 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 TeacherCourseDaoImpl.javab package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.bluehonour.sscs.dao.TeacherCourseDao; import com.bluehonour.sscs.entity.Course; import com.bluehonour.sscs.entity.Teacher; import com.bluehonour.sscs.util.DBUtils; public class TeacherCourseDaoImpl implements TeacherCourseDao { @Override public int save(int cno, int tno) { String sql = "insert into t_tc values(?,?)"; Object[] params = {cno,tno}; return DBUtils.executeUpdate(sql, params); } @Override public int delete(int cno, int tno) { String sql = "delete from t_tc where cno = ? and tno = ?"; Object[] params = {cno,tno}; return DBUtils.executeUpdate(sql, params); } @Override public List<Course> findAll() { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Course> list = new ArrayList<Course>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_course c" + " join t_tc tc" + " on (c.cno = tc.cno)" + " join t_teacher t" + " on (tc.tno = t.tno)" + " order by c.cno"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行课程各个字段的值 int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); Date periodstart = rs.getDate("periodstart"); Date periodend = rs.getDate("periodend"); // 封装成课程对象 Course course = new Course(cno,name, credit, periodstart, periodend); //取出结果集中教师各个字段的值 int tno = rs.getInt("tno"); String tname = rs.getString("tname"); String password = rs.getString("password"); long phone = rs.getLong("phone"); Date hiredate = rs.getDate("hiredate"); String remark = rs.getString("remark"); //封装成教师对象 Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark); //将教师加入课程 course.setTeacher(teacher); list.add(course); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } } AI写代码 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 TeacherDaoImpl.java package com.bluehonour.sscs.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.bluehonour.sscs.dao.TeacherDao; import com.bluehonour.sscs.entity.Course; import com.bluehonour.sscs.entity.Student; import com.bluehonour.sscs.entity.Teacher; import com.bluehonour.sscs.util.DBUtils; public class TeacherDaoImpl implements TeacherDao { @Override public int save(Teacher teacher) { String sql = "insert into t_teacher(tname,password,phone,hiredate,remark) values(?,?,?,?,?) "; Object[] params = {teacher.getTname(),teacher.getPassword(),teacher.getPhone(),teacher.getHiredate(),teacher.getRemark()}; return DBUtils.executeUpdate(sql, params); } @Override public List<Teacher> findAll() { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; List<Teacher> list = new ArrayList<Teacher>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_teacher order by tno"; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行各个字段的值 int tno = rs.getInt("tno"); String tname = rs.getString("tname"); String password = rs.getString("password"); long phone = rs.getLong("phone"); Date hiredate = rs.getDate("hiredate"); String remark = rs.getString("remark"); // 封装成对象 Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark); list.add(teacher); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } @Override public int delete(int tno) { String sql = "delete from t_teacher where tno = ?"; Object[] params = {tno }; return DBUtils.executeUpdate(sql, params); } @Override public Teacher findById(int tno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Teacher teacher = null; try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select * from t_teacher where tno = " + tno; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 if (rs.next()) { // 取出结果集当前行各个字段的值 String tname = rs.getString("tname"); String password = rs.getString("password"); long phone = rs.getLong("phone"); Date hiredate = rs.getDate("hiredate"); String remark = rs.getString("remark"); // 封装成对象 teacher = new Teacher(tno, tname, password, phone, hiredate, remark); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return teacher; } @Override public int update(Teacher teacher) { String sql = "update t_teacher set tname=?,password=?,phone=?,hiredate=?,remark=? where tno=?"; Object[] params = {teacher.getTname(),teacher.getPassword(),teacher.getPhone(),teacher.getHiredate(),teacher.getRemark(),teacher.getTno()}; return DBUtils.executeUpdate(sql, params); } @Override public List<Course> getAssumeCourse(int tno) { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet rs = null; Course course = null; List<Course> list = new ArrayList<>(); try { // 建立连接 connection = DBUtils.getConnection(); // 向数据库发送sql命令并得到结果 String sql = "select c.* from t_tc tc " + "LEFT JOIN t_teacher t on t.tno = tc.tno " + "LEFT JOIN t_course c on c.cno = tc.cno " + "where tc.tno = " + tno ; preparedStatement = connection.prepareStatement(sql); rs = preparedStatement.executeQuery(); // 处理返回结果 while (rs.next()) { // 取出结果集当前行各个字段的值 int cno = rs.getInt("cno"); String name = rs.getString("name"); int credit = rs.getInt("credit"); Date periodstart = rs.getDate("periodstart"); Date periodend = rs.getDate("periodend"); // 封装成对象 course = new Course(cno,name, credit, periodstart, periodend); list.add(course); } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtils.closeAll(rs, preparedStatement, connection); } return list; } } AI写代码 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 addAdmin.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head lang="en"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>增加管理员</title> <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>"> <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/kindeditor/kindeditor-all.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/kindeditor/lang/zh_CN.js"></script> <script> KindEditor.ready(function(K) { filterMode: false,//是否开启过滤模式 window.editor = K.create('#introduction-id'); }); </script> </head> <body> <div class="nav"> <%-- ${error } <div><img src="${pageContext.request.contextPath }/images/register_admin.jpg"></div> --%> <% if(request.getAttribute("error") != null){ %> <div><img src="${pageContext.request.contextPath }/images/add_admin_error.jpg"></div> <% } else{ %> <div><img src="${pageContext.request.contextPath }/images/register_admin.jpg"></div> <% } %> <div class="nav1"> <form action="${pageContext.request.contextPath }/addAdmin.do" method="post"> <p> <label for="userId">管理员账号:</label> <input type="text" name="userId" id="userId""><span>请输入4-10位用户名</span> </p> <p> <label for="userName">真实姓名:</label> <input type="text" name="userName" id="userName" value=""><span>请输入您的真实姓名</span> </p> <p> <label for="passWord">密码:</label> <input type="password" name="passWord" id="passWord" value="" size="20px"><span>密码为6-16位</span> </p> <p> <label for="rePassWord">确认密码:</label> <input type="password" name="rePassWord" id="rePassWord" value="" size="20px"><span>请再次输入密码</span> </p> <p> <label for="age">年龄:</label> <input type="text" name="age" id="age" value=""><span>请输入年龄</span> </p> <p> <label for="score">成绩:</label> <input type="text" name="score" id="score" value=""><span>请输入成绩</span> </p> <p> <label for="enterDate">入职时间:</label> <input type="text" name="enterDate" id="enterDate" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入入职时间</span> </p> <p> <label for="introduction">简介:</label> <textarea class="no" name="introduction" id="introduction-id" style=" width: 700px; height: 200px; visibility: hidden; display: block;"> </textarea> </p> <button class="sub"> <img src="${pageContext.request.contextPath }/images/button.gif"> </button> </form> </div> </div> <script> window.onload = function(e) { var form = document.querySelector('form'); var userId = document.querySelector('#userId'); var userName = document.querySelector('#userName'); var passWord = document.querySelector('#passWord'); var rePassWord = document.querySelector('#rePassWord'); var age = document.querySelector('#age'); var score = document.querySelector('#score'); var enterDate = document.querySelector('#enterDate'); var span = document.querySelectorAll('span'); //onsubmit事件 form.onsubmit = function(e) { var userId = checkUserId(); if (!userId) { return false; } var username = checkUserName(); if (!username) { return false; } var password = checkPassWord(); if (!password) { return false; } var rePassWord = checkRePassWord(); if (!rePassWord) { return false; } var age = checkAge(); if (!age) { return false; } var score = checkScore(); if (!score) { return false; } var enterDate = checkEnterDate(); if (!enterDate) { return false; } return true; }; //onblur失去焦点事件 userId.onblur = function(e) { checkUserId(); }; userName.onblur = function(e) { checkUserName(); }; passWord.onblur = function(e) { checkPassWord(); }; rePassWord.onblur = function(e) { checkRePassWord(); }; age.onblur = function(e) { checkAge(); }; score.onblur = function(e) { checkScore(); }; enterDate.onblur = function(e) { checkEnterDate(); }; //---------------------------------函数封装------------------------------------------------------------- //管理员账户(3-10位) function checkUserId(e) { if (userId.value.length == 0) { span[0].innerText = '账户不能为空'; span[0].className = 'danger'; return false; } var pattern = /^[A-Za-z0-9]{3,10}$/; if (!pattern.test(userId.value)) { span[0].innerText = '账户格式错误,请重新输入'; span[0].className = 'danger'; return false; } span[0].innerText = '管理员账户输入正确'; span[0].className = 'success'; return true; } //真实姓名(2-4位汉字) function checkUserName(e) { if (userName.value.length == 0) { span[1].innerText = '真实姓名不能为空'; span[1].className = 'danger'; return false; } var pattern = /^[\u4e00-\u9fa5]{2,4}$/; if (!pattern.test(userName.value)) { span[1].innerText = '真实姓名格式错误,请重新输入'; span[1].className = 'danger'; return false; } span[1].innerText = '真实姓名输入正确'; span[1].className = 'success'; return true; } //登录密码(6-16位) function checkPassWord(e) { if (passWord.value.length == 0) { span[2].innerText = '密码不能为空'; span[2].className = 'danger'; return false; } var pattern = /^[A-Za-z0-9]{6,16}$/; if (!pattern.test(passWord.value)) { span[2].innerText = '密码不符合格式,请重新输入'; span[2].className = 'danger'; return false; } span[2].innerText = '密码输入正确'; span[2].className = 'success'; return true; } //重复登录密码 function checkRePassWord(e) { if (rePassWord.value.length == 0) { span[3].innerText = '重复密码不能为空'; span[3].className = 'danger'; return false; } if (rePassWord.value != passWord.value) { span[3].innerText = '两次输入的密码不一致,请重新输入'; span[3].className = 'danger'; return false; } span[3].innerText = '两次密码一致'; span[3].className = 'success'; return true; } //年龄(1-3位) function checkAge(e) { if (age.value.length == 0) { span[4].innerText = '年龄不能为空'; span[4].className = 'danger'; return false; } var pattern = /^[1-9]{1,3}$/; if (!pattern.test(age.value)) { span[4].innerText = '年龄格式错误,请重新输入'; span[4].className = 'danger'; return false; } span[4].innerText = '年龄输入正确'; span[4].className = 'success'; return true; } //成绩 function checkScore(e) { if (score.value.length == 0) { span[5].innerText = '成绩不能为空'; span[5].className = 'danger'; return false; } /* var pattern = /^[0-9]+\.?[0-9]*$/; */ var pattern = /^[0-9]+\.?[0-9]*$/; if (!pattern.test(score.value)) { span[5].innerText = '成绩格式错误,请重新输入'; span[5].className = 'danger'; return false; } span[5].innerText = '成绩输入正确'; span[5].className = 'success'; return true; } //入职时间(格式xxxx-xx-xx) function checkEnterDate(e) { if (enterDate.value.length == 0) { span[6].innerText = '入职时间不能为空'; span[6].className = 'danger'; return false; } var pattern = /^[0-9]{4}\-?[0-9]{1,2}\-?[0-9]{1,2}$/; if (!pattern.test(enterDate.value)) { span[6].innerText = '时间格式:xxxx-xx-xx'; span[6].className = 'danger'; return false; } span[6].innerText = '时间格式正确'; span[6].className = 'success'; return true; } } </script> </body> </html> AI写代码 html 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 addCourse.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head lang="en"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加学生</title> <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>"> <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script> </head> <body> <div class="nav"> <% if(request.getAttribute("error") != null){ %> <div><img src="${pageContext.request.contextPath }/images/add_course_error.jpg"></div> <% } else{ %> <div><img src="${pageContext.request.contextPath }/images/register_course.jpg"></div> <% } %> <div class="nav1"> <form action="${pageContext.request.contextPath }/addCourse.do" method="post"> <p> <label for="name">课程名称:</label> <input type="text" id="name" name="name" value=""> </p> <p> <label for="name">学分:</label> <input type="text" id="credit" name="credit" value=""> </p> <p> <label for="periodStart">开课日期:</label> <input type="text" id="periodStart" name="periodStart" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"> </p> <p> <label for="periodEnd">结课日期:</label> <input type="text" id="periodEnd" name="periodEnd" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"> </p> <div align="center"> <input type="submit" value="保存" /> </div> <div align="center"> ${error } </div> </form> </div> </div> </body> </html> AI写代码 html 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 addStudent.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head lang="en"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加学生</title> <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>"> <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath }/scripts/student.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script> </head> <body> <div class="nav"> <% if(request.getAttribute("error") != null){ %> <div><img src="${pageContext.request.contextPath }/images/add_admin_error.jpg"></div> <% } else{ %> <div><img src="${pageContext.request.contextPath }/images/register_student.jpg"></div> <% } %> <div class="nav1"> <form action="${pageContext.request.contextPath }/addStudent.do" method="post"> <p> <label for="name">学生姓名:</label> <input type="text" id="name" name="name" value=""><span>请输入学生姓名</span> </p> <p> <label for="password">密码:</label> <input type="text" id="password" name="password" value=""><span>密码为6-16位</span> </p> <p> <label for="classno">班级:</label> <select name="classno" id="classno"> <option>--请选择班级--</option> <c:forEach items="${classList }" var="clazz"> <option>--${clazz.classno}班--</option> </c:forEach> </select> <span style="margin-left: 100px">请输入班级</span> </p> <p> <label>性别:</label> <input type="radio" name="sex" value="男" checked="checked" >男 <input type="radio" name="sex" value="女">女 </p> <p> <label for="tel">关联手机号:</label> <input type="text" id="tel" name="tel" value=""><span>请输入手机号</span> </p> <p> <label for="birthday">出生年月日:</label> <input type="text" id="birthday" name="birthday" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入出生年月日</span> </p> <p> <label for="remark">评论:</label> <select name="remark" id="remark"> <option>--请选择--</option> <option>优秀</option> <option>良好</option> <option>合格</option> <option>差劲</option> </select> <span style="margin-left: 100px">请对该学生进行评论</span> </p> <button class="sub"> <img src="${pageContext.request.contextPath }/images/submit.jpg"> </button> <div align="center"> ${error } </div> </form> </div> </div> </body> </html> AI写代码 html 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 addTeacher.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head lang="en"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加教师</title> <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>"> <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath }/scripts/teacher.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/kindeditor/kindeditor-all.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/kindeditor/lang/zh_CN.js"></script> <script> KindEditor.ready(function(K) { filterMode: false,//是否开启过滤模式 window.editor = K.create('#remark-id'); }); </script> </head> <body> <div class="nav"> <% if (request.getAttribute("error") != null) { %> <div><img src="${pageContext.request.contextPath }/images/add_teacher_error.jpg"></div> <% } else { %> <div><img src="${pageContext.request.contextPath }/images/register_teacher.jpg"></div> <% } %> <div class="nav1"> <form action="${pageContext.request.contextPath }/addTeacher.do" method="post"> <p> <label for="name">教师姓名:</label> <input type="text" id="name" name="name" value=""><span>请输入教师姓名</span> </p> <p> <label for="password">教师密码:</label> <input type="text" id="password" name="password" value=""><span>密码为6-16位</span> </p> <p> <label for="tel">联系方式:</label> <input type="text" id="tel" name="tel" value=""><span>请输入手机号</span> </p> <p> <label for="hiredate">入职时间:</label> <input type="text" id="hiredate" name="hiredate" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入入职时间</span> </p> <p> <label for="remark">评论:</label> <textarea class="no" name="remark" id="remark-id" style="width: 700px; height: 200px; visibility: hidden; display: block;"> </textarea> </p> <button class="sub"> <img src="${pageContext.request.contextPath }/images/submit.jpg"> </button> <div align="center">${error }</div> </form> </div> </div> </body> </html> AI写代码 html 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 四、其他 ———————————————— 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 原文链接:https://blog.youkuaiyun.com/helongqiang/article/details/118162212进行一个总结
07-21
[root@wpf-centos7 ~]# certbot --apache -d yourdomain.com -d www.yourdomain.com /usr/lib/python2.7/site-packages/josepy/util.py:9: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.hazmat.primitives.asymmetric import rsa ^CTraceback (most recent call last): File "/usr/bin/certbot", line 9, in <module> load_entry_point('certbot==1.11.0', 'console_scripts', 'certbot')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/usr/lib/python2.7/site-packages/certbot/main.py", line 2, in <module> from certbot._internal import main as internal_main File "/usr/lib/python2.7/site-packages/certbot/_internal/main.py", line 17, in <module> from certbot import crypto_util File "/usr/lib/python2.7/site-packages/certbot/crypto_util.py", line 13, in <module> from cryptography import x509 # type: ignore File "/usr/lib64/python2.7/site-packages/cryptography/x509/__init__.py", line 8, in <module> from cryptography.x509.base import ( File "/usr/lib64/python2.7/site-packages/cryptography/x509/base.py", line 23, in <module> from cryptography.x509.extensions import Extension, ExtensionType File "/usr/lib64/python2.7/site-packages/cryptography/x509/extensions.py", line 630, in <module> class ReasonFlags(Enum): File "/usr/lib/python2.7/site-packages/enum/__init__.py", line 257, in __new__ enum_class._value2member_map_[value] = enum_member KeyboardInterrupt [root@wpf-centos7 ~]# certbot --apache -d gxlscc.fun -d www.gxlscc.fun /usr/lib/python2.7/site-packages/josepy/util.py:9: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.hazmat.primitives.asymmetric import rsa Traceback (most recent call last): File "/usr/bin/certbot", line 9, in <module> load_entry_point('certbot==1.11.0', 'console_scripts', 'certbot')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/usr/lib/python2.7/site-packages/certbot/main.py", line 2, in <module> from certbot._internal import main as internal_main File "/usr/lib/python2.7/site-packages/certbot/_internal/main.py", line 21, in <module> from certbot._internal import account File "/usr/lib/python2.7/site-packages/certbot/_internal/account.py", line 17, in <module> from acme.client import ClientBase # pylint: disable=unused-import File "/usr/lib/python2.7/site-packages/acme/client.py", line 39, in <module> requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3() # type: ignore File "/usr/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 133, in inject_into_urllib3 _validate_dependencies_met() File "/usr/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 175, in _validate_dependencies_met "'pyOpenSSL' module missing required functionality. " ImportError: 'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer. [root@wpf-centos7 ~]#
最新发布
11-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值