关于在jsp中执行两条sql语句的问题,求助高手

cody2002 2003-05-09 04:17:59
我在一张页面上需要执行两条sql语句。因此我定义了stm1和stm2,但是系统会报错。一般的话一张页面只执行一条sql语句,请问怎么样才能执行两条。谢谢!!!



...全文
110 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cody2002 2003-05-09
  • 打赏
  • 举报
回复
行了
谢谢leshui(大象无形)(有物混成,先天地生) 的代码
acefr 2003-05-09
  • 打赏
  • 举报
回复
只要
String sql = "select * from yourtable";
String sql1 = "update yourtable1 set ......";
stmt.executeQuery(sql);
or
stmt.executeUpdate(sql1);
...
...

leshui 2003-05-09
  • 打赏
  • 举报
回复
可以执行多条sql语句啊
mSql="select * from t_flow_f where id='"+mId+"'";
result=DbaObj.ExecuteQuery(mSql);
result.next();
myFlowNo=result.getInt("flowno");
mFlowSort=result.getString("flowsort");

mSql="select * from t_flow_f where file_source_id= '"+file_source_id+"' and flowsort= '"+mFlowSort+"' order by flowno desc";
result=DbaObj.ExecuteQuery(mSql);
result.next();
flowNo=result.getInt("flowno");
if(flowNo!=myFlowNo)
{
myFlowNo=myFlowNo+1;

mSql="update t_flow_f set enable='1' where ad_type='核稿' and flowsort= '"+mFlowSort+"' and file_source_id='"+file_source_id+"' and flowno='"+myFlowNo+"'";
prestmt=DbaObj.Conn.prepareStatement(mSql);
DbaObj.Conn.setAutoCommit(true) ;
prestmt.executeUpdate();
DbaObj.Conn.commit();
acefr 2003-05-09
  • 打赏
  • 举报
回复
??
执行n条都可以呀,一个stmt就够了呀。
匪六哥 2003-05-09
  • 打赏
  • 举报
回复
不是吧?我就用过两个以上,怎么会出错呢?!!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧