实际上,我在这个问题上有压力。 我有一张图片
所以我在这里遇到了两个问题。
我是Java MVC GUI的新手。任何人都可以帮我找到一个好的解决方案 先谢谢
这是我的数据访问对象文件。
包装模型; import java.sql。*; import java.util.ArrayList; import javax.swing.JOptionPane;
public class SchoolDAO{
Conexion conexion;
public SchoolDAO(){
conexion = new Conexion();
}
/////INSERT TEACHER
public String insertTeacher(String tbno, String tbname, String tbphone, String tbqualification, String tbexp){
String rptaAdd = null;
try {
Connection accessDB = conexion.getConexion();
CallableStatement cs = accessDB.prepareCall ("{call teacher_insert(?,?,?,?,?)}");
cs.setString(1, tbno);
cs.setString(2, tbname);
cs.setString(3, tbphone);
cs.setString(4, tbqualification);
cs.setString(5, tbexp);
int numFAeffect = cs.executeUpdate();
if(numFAeffect>0){
rptaAdd ="Add successful.";
}
} catch (Exception e){
JOptionPane.showMessageDialog(null, e.toString());
}
return rptaAdd;
}
public ArrayList<School> listTeacher(){
ArrayList listaTeacher = new ArrayList();
School school;
try{
Connection accessDB = conexion.getConexion();
PreparedStatement ps = accessDB.prepareStatement("select * from teacher");
ResultSet rs = ps.executeQuery();
while(rs.next()){
school = new School();
school.setTno(rs.getString(1));
school.setTname(rs.getString(2));
school.setTphone(rs.getString(3));
school.setTqualification(rs.getString(4));
school.setTexp(rs.getString(5));
listaTeacher.add(school);
}
}catch (Exception e){
}
return listaTeacher;
}
}
答案 0 :(得分:0)
将ID作为从序列或其他机制递增的数字发送,这将使您自动递增数字&#34; T&#34; +左边填充的字符串,用零填充到所需的值。
"T" + StringUtils.leftpad(id + "", 5, "0"); // your ID
从教师表中选择计数(*)。