zoukankan      html  css  js  c++  java
  • 个人作业2 后端1

    1、bean实体层

    package bean;

    public class Bean {
    private String title;
    private String Abstract;
    private String link;
    private String keyWords;
    public String getTitle() {
    return title;
    }
    public void setTitle(String title) {
    this.title = title;
    }
    public String getAbstract() {
    return Abstract;
    }
    public void setAbstract(String abstract1) {
    Abstract = abstract1;
    }
    public String getLink() {
    return link;
    }
    public void setLink(String link) {
    this.link = link;
    }
    public String getKeyWord() {
    return keyWords;
    }
    public void setKeyWord(String keyWord) {
    this.keyWords = keyWord;
    }
    public Bean(String title, String abstract1, String link, String keyWord) {
    super();
    this.title = title;
    Abstract = abstract1;
    this.link = link;
    this.keyWords = keyWord;
    }
    public Bean() {
    super();
    }
    }

    2、数据库连接驱动

    package dao;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class Util {
    private Util() {}
    static {
    try {
    Class.forName("com.mysql.cj.jdbc.Driver");
    }catch(ClassNotFoundException e) {
    e.printStackTrace();
    }
    }
    public static Connection getConnection() throws SQLException{
    return DriverManager.getConnection("jdbc:mysql://localhost:3306/users?serverTimezone=UTC&useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8","root","lin0613");
    }
    public static void close(Connection conn,Statement ps,ResultSet rs) {
    if(rs!=null) {
    try {
    rs.close();
    }catch(SQLException s) {
    s.printStackTrace();
    }
    }
    if(ps!=null) {
    try {
    ps.close();
    }catch(SQLException s) {
    s.printStackTrace();
    }
    }
    if(conn!=null) {
    try {
    conn.close();
    }catch(SQLException s) {
    s.printStackTrace();
    }
    }
    }
    }

  • 相关阅读:
    【Asp.Net从零开始】:上传文件(FileUpload)
    JavaScript变量声明及赋值
    427 类型数据
    427 自适应量化
    428 x264_reference_update
    427 expand_border
    426 pixel赋值问题 mbcmp函数 宏定义
    427 mb中一些参数记录备忘
    427 参考帧管理
    427 参数原来还有很多没有理解 比较详细的解释
  • 原文地址:https://www.cnblogs.com/lx06/p/14907898.html
Copyright © 2011-2022 走看看