help me!!

hotsmile 2004-02-26 10:41:56
我对一张表尽心插入操作,然后,去取系统生成的id ,出现如下错误
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid operation for the current cursor position.
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:526)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:467)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
我得数据库操作如下
public String getStaffId(SignupForm form) throws Exception{
Connection con = CreateConnection.getConnection();
Statement smt = con.createStatement();
String COURSE_SYS_ID=Until.toGBK(form.getCOURSE_SYS_ID()) ;
String COURSE_CODE=Until.toGBK(form.getCOURSE_CODE());
String SIGN_DATE=form.getSIGN_DATE() ;
String Name=Until.toGBK(form.getName()) ;
String ID_CODE=Until.toGBK(form.getID_CODE() );
String PHONE=Until.toGBK(form.getPHONE()) ;
String BIRTH_DATE=Until.toGBK(form.getBIRTH_DATE());
String EMAIL=Until.toGBK(form.getEMAIL() );
String DIPLOMA=Until.toGBK(form.getDIPLOMA() );
String SPECIALTY=Until.toGBK(form.getSPECIALTY() );
String UNIT_ADDR=Until.toGBK(form.getUNIT_ADDR() );
String POST_CODE=Until.toGBK(form.getPOST_CODE() );
String JOB_RESUME=Until.toGBK(form.getJOB_RESUME() );
String SEX=Until.toGBK(form.getSEX() );
String EXER_STAFF_NAME=Until.toGBK(form.getEXER_STAFF_NAME() );
String RETAIN_UNIT_SYS_ID=Until.toGBK(form.getRETAIN_UNIT_SYS_ID());
String sql="select * from T_EXERCISE_STAFF where ID_CODE="+ID_CODE;
String sql1="insert into T_EXERCISE_STAFF (EXER_STAFF_NAME,ID_CODE,PHONE,EMAIL,DIPLOMA,SPECIALTY,POST_CODE,JOB_RESUME,SEX,RETAIN_UNIT_SYS_ID) values('"
+EXER_STAFF_NAME+"',"+
"'"+ID_CODE+"',"
+"'"+PHONE+"',"
+"'"+EMAIL+"',"
+"'"+DIPLOMA+"',"
+"'"+SPECIALTY+"',"
+"'"+POST_CODE+"',"
+"'"+JOB_RESUME+"',"
+"'"+SEX+"',"
+"'"+RETAIN_UNIT_SYS_ID+"')";
ResultSet rs=smt.executeQuery(sql) ;
if(rs.next() ){
String id=rs.getString(1);
System.out .println("system already exist the staff!!");
return id;
}
else{
System.out .println("insert record=========="+sql1);
smt.execute(sql1);
// con.commit();
rs=smt.executeQuery(sql);
String id=rs.getString(1);
con.close() ;
return id;
}
}

...全文
7 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2004-02-26 10:41
社区公告
暂无公告