向数据库存储数据报错

com.microsoft.sqlserver.jdbc.SQLServerException:该语句没有返回结果集

  错误代码

rs=stmt.executeQuery(sql);

  解决方法

int count=stmt.executeUpdate(sql);

  

总结:

  1. stmt.executeUpdate(sql);用于更新,sql必须是一个更新语句

    返回数据库受影响行数

  2. stmt.executeQuery(sql);用于查询,sql必须是一个查询语句

    返回查询结果

 



 

相关文章:

  • 2021-11-29
  • 2021-07-29
  • 2022-12-23
  • 2021-08-21
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-29
  • 2021-07-08
  • 2021-10-18
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案