Home  >  Article  >  Database  >  解决插入语句问题:com.microsoft.sqlserver.jdbc.SQLServerExce

解决插入语句问题:com.microsoft.sqlserver.jdbc.SQLServerExce

WBOY
WBOYOriginal
2016-06-07 15:25:411582browse

问题描述:使用SqlServer2008,当要向数据库插入数据时,总是会抛出异常:com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。但是数据还是成功的插 入到数据库中。 原因分析: 查资料发现原来SqlServer2008的驱动会关注到存储过程执

问题描述:使用SqlServer2008,当要向数据库插入数据时,总是会抛出异常:com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。但是数据还是成功的插                    入到数据库中。


原因分析:查资料发现原来SqlServer2008的驱动会关注到存储过程执行过程中返回的“影响多少行”这些信息,有这些信息存在,就会抛出以上异常。

问题解决:知道原因以后就很好解决了。插入不要用executeQuery();用 executeUpdate(String sql) ,返回值是一个整型,即插入成功的行的个数。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn