【发布时间】:2012-03-24 03:41:34
【问题描述】:
我正在 JSP-JDBC 中创建一个简单的应用程序,用于插入和更新员工的详细信息。
数据库在MySql中。主表中的主键设置为自动递增。 现在,当我插入新员工详细信息时,我想在 JSP 的文本字段中显示新生成的密钥。
有办法吗??
这是我在 DAO 类中创建的方法..
public int getMaxId()
{
int id=0;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select MAX(emp_id) from emp_details");
id = rs.getInt("emp_id");
}catch(Exception e)
{
e.printStackTrace();
}
return id;
}
但它的节目java.sql.SQLException: Column 'emp_id' not found.
【问题讨论】:
-
你可能想看看这个问题:stackoverflow.com/questions/1915166/…
标签: mysql jsp jakarta-ee jdbc