首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

sql 简单语句有关问题

2012-05-13 
sql 简单语句问题求助在jsp中执行sql语句遇到些问题 请高手帮忙看看 谢谢rs stmt.executeQuery(select a

sql 简单语句问题求助
在jsp中执行sql语句遇到些问题 请高手帮忙看看 谢谢
rs= stmt.executeQuery("select account from card where name='"+name+"'");

  while (rs.next()){  
int account=rs.getInt("account") ;
 int nowaccount=account+samount;  
   
 out.println("充值成功,您当前余额为:"+nowaccount);
 
stmt.execute("update card set account="+nowaccount+" where name='"+name+"'");
。。。
运行后可以正常显示结果 就是结果后面有一句 Operation not allowed after ResultSet closed 请问该如何解决

另外 有一个delete语句 delete * from card where id="+id+" 比如我输入id值2 提示You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* from card where id=2' at line 1 应该如何处理

[解决办法]
1.
while(rs.next()) 


……………… 
 

rs.close(); 
st.close(); 
con.close(); 

把关闭数据库的语句写到while循环的外面就行了....

2.delete * from card where id="+id+" 
==》
delete from card where id="+id+"
[解决办法]
stmt.execute("update card set account="+nowaccount+" where name='"+name+"'");
要求其所使用的连接没有打开中的数据集。要么就的把rs先close掉,要么就得创建新的连接。



Delete的问题,要看看你完整的是怎么拼装delete语句的。

热点排行
Bad Request.