java连接MySQL数据库代码↓
jdbc
数据库里的user表
把user表进行实体化
package entity;
import java.io.Serializable;
/**
* @descibe User用户表
* @author xiaojian
* @date 2020年7月7日
*/
public class User implements Serializable {
//实现Serializable进行序列化操作
private static final long serialVersionUID = 7247119888988667135L; // 序列化
private Integer id; // 用户id
private String user_name; // 用户名
private String user_pwd; // 用户密码
// 构造方法
public User() {
super();
}
public User(String user_name, String user_pwd) {
super();
this.user_name = user_name;
this.user_pwd = user_pwd;
}
public User(Integer id, String user_name, String user_pwd) {
super();
this.id = id;
this.user_name = user_name;
this.user_pwd = user_pwd;
}
// get、set方法
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the user_name
*/
public String getUser_name() {
return user_name;
}
/**
* @param user_name the user_name to set
*/
public void setUser_name(String user_name) {
this.user_name = user_name;
}
/**
* @return the user_pwd
*/
public String getUser_pwd() {
return user_pwd;
}
/**
* @param user_pwd the user_pwd to set
*/
public void setUser_pwd(String user_pwd) {
this.user_pwd = user_pwd;
}
@Override
public String toString() {
return "User [id=" + id + ", user_name=" + user_name + ", user_pwd=" + user_pwd + "]";