How to tell if a SQL (UPDATE,DELETE) statement is performing successfully

Source: Internet
Author: User

How to determine whether a SQL (UPDATE,DELETE) statement executes a successful catch (SQLException e) {
}
You should succeed if you don't catch the error.

=====================================================================
The statement object provides three ways to execute SQL statements.
1.ResultSet executeQuery (String sql)
Executes a query statement, such as ResultSet rs=stmt.executequery (SELECT * FROM table_name ").
2.int executeupdate (String sql)
Executes an UPDATE statement such as INSERT, UPDATE, Delete, and returns the number of records for the operation.
3.boolean execute (String sql)
Executes all SQL statements, returning the success of the execution operation.

So for insert,update, and so on, after executing with executeupdate, if the value returned is 0, it will fail, and a positive integer succeeds, and the third method will not need to say more.

How to tell if a SQL (UPDATE,DELETE) statement is performing successfully

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.