PreparedStatement Execute performs INSERT success but returns false

Source: Internet
Author: User

Execution of the SQL INSERT statement using the PreparedStatement Execute method succeeds, but the return result is false.

Boolean Execute ()
Throws SqlException executes the SQL statement in this PreparedStatement object, which can be any kind of SQL statement. Some specially processed statements return multiple results, and the Execute method handles these complex statements, executequery and executeupdate simpler statements.
The Execute method returns a Boolean value to indicate the form of the first result. You must call the Getresultset or Getupdatecount method to retrieve the results, and you must call the Getmoreresults to move to any subsequent results.
Return:
Returns true if the first result is a ResultSet object, or False if the first result is an update count or no result

This means that if the query returns TRUE, it returns False if it is updated or inserted;


Therefore, the Execute INSERT or UPDATE statement should use Executeupdate.


Reference http://blog.sina.com.cn/s/blog_963fb3af01013rcs.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.