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();
}
}
}
}