正如您所看到的,我正在使用' enum'在employee_detail以及gender.java中。 这是我的pojo类和枚举类: //Employee.java
package com.myp.ems.model;
import com.myp.ems.model.Gender;
import java.util.Date;
import java.util.Enumeration;
public class Employee{
private int empId;
private String firstName;
private String lastName;
private String emailId;
private Date dob;
private Gender gender;
private double salary;
private long contact_no;
private String occupation;
private String designation;
private Date doj;
/**
* Setter Methods
*/
public void setEmpId(int empId){
this.empId = empId;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}
public void setEmailID(String emailId){
this.emailId = emailId;
}
public void setDOB(Date dob){
this.dob = dob;
}
public void setGender(Gender gender){
gender = gender;
}
public void setSalary(double salary){
this.salary = salary;
}
public void setContactNumber(long contact_no){
this.contact_no = contact_no;
}
public void setoccupation(String occupation){
this.occupation = occupation;
}
public void setDesignation(String designation){
this.designation = designation;
}
public void setDOJ(Date doj){
this.doj = doj;
}
/**
* Getter Methods
*/
public int getEmpId(){
return empId;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getEmailId(){
return emailId;
}
public Date getDOB(){
return dob;
}
public Gender getGender(){
return gender;
}
public double getSalary(){
return salary;
}
public long getContactNumber(){
return contact_no;
}
public String getOccupation(){
return occupation;
}
public String getDesignation(){
return designation;
}
public Date getDOJ(){
return doj;
}
}
// Gender.java:
package com.myp.ems.model;
import java.util.Enumeration;
public enum Gender{
Male, Female, Transgender;
}
// Employee.sql:
CREATE TABLE EMPLOYEE_DETAIL(
EMP_ID INT(10) NOT NULL PRIMARY KEY,
FIRST_NAME VARCHAR(32) NOT NULL,
LAST_NAME VARCHAR(32) NOT NULL,
EMAIL_ID VARCHAR(64) NOT NULL,
EMP_DOB DATE NOT NULL,
GENDER ENUM('MALE','FEMALE','TRANSGENDER'),
EMP_SALARY DECIMAL(10,2) NOT NULL,
CONTACT_NO BIGINT (10) NOT NULL,
OCCUPATION VARCHAR(64) NOT NULL,
DESIGNATION VARCHAR(32) NOT NULL,
DATE_OF_JOINING DATE NOT NULL
);
任何人都可以告诉我该程序和表格有什么问题,请为我提供最好的解决方案,以便克服这个问题。还有其他方法可以让我的程序最佳吗?