即使变量名正确,java servlet 输入到错误的数据库

问题描述 投票:0回答:0

我有两个不同的实体,一个是 MyCustomer,一个是 MySalesman。数据库以某种方式在角色和地址之间切换

MySalesman实体中的部分代码

@Entity
public class MySalesman implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String salesid;
    private String username;
    private int password;
    private char gender;
    private String dob;
    private String role;
    private String address;
    @OneToMany
    private ArrayList<MyTransaction> myTransaction = new ArrayList<MyTransaction>();
    @OneToMany
    private ArrayList<MyCar> myCar = new ArrayList<MyCar>();
    @ManyToMany(mappedBy = "mySalesman")
    private ArrayList<MyCustomer> myCustomer = new ArrayList<MyCustomer>();

    public MySalesman(String username, int password, char gender, String dob, String role, String address) {
        this.username = username;
        this.password = password;
        this.gender = gender;
        this.dob = dob;
        this.role = role;
        this.address = address;
    }

MyCustomer实体中的部分代码

@Entity
public class MyCustomer implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String custid;
    private String username;
    private int password;
    private char gender;
    private String dob;
    private String role;
    private String address;
    @OneToMany
    private ArrayList<MyTransaction> myTransaction = new ArrayList<MyTransaction>();
    @ManyToMany
    private ArrayList<MySalesman> mySalesman = new ArrayList<MySalesman>();

    public MyCustomer(String username, int password, char gender, String dob, String role, String address) {
        this.username = username;
        this.password = password;
        this.gender = gender;
        this.dob = dob;
        this.role = role;
        this.address = address;
    }

register.jsp中的部分代码

Register servlet中的部分代码

我的客户数据库

MySalesman 数据库

java jsp servlets
© www.soinside.com 2019 - 2024. All rights reserved.