项目名:exam

心得:

  • 1、在创建实体类时,使用LocalDate 代替之前的java.util.Date

项目流程

image.png

连接数据库

Jdbc.properties

  1. jdbc.connection.mysql.driver = com.mysql.cj.jdbc.Driver
  2. jdbc.connection.mysql.url = jdbc:mysql://localhost:3306/oracle?serverTimezone=Asia/Shanghai&useSSL=false&useServerPrepStmts=true&cachePrepStmts=true&allowPublicKeyRetrieval=true
  3. jdbc.connection.mysql.username = root
  4. jdbc.connection.mysql.password = 702126

增删改查

cn.edu.ecut.test目录

登录密码加密

  1. public boolean save( Student s ) {
  2. JdbcHelper h = JdbcHelper.getInstance( DatabaseType.MYSQL );
  3. String password = s.getPassword(); // 原始密码
  4. // 对密码进行加密
  5. String encrypted = EncryptHelper.encrypt( password , EncryptType.SHA1 );
  6. // 向数据库插入的是加密后的密码
  7. int count = h.update( INSERT , s.getLoginName() , encrypted );
  8. h.release();
  9. return count > 0 ;
  10. }