'return value of update statement in sqlite
what kind of value does a update statement in sql lite return when invoked via java? is it boolean?
i'm trying to update a few rows and want to fetch whether it worked correctly or threw exceptions.
thanks in advance
Solution 1:[1]
If you run the sentence with iOS you get the number of rows modified, I think in Java will be similar
Solution 2:[2]
int executeUpdate() throws SQLExceptionSQLException
Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement returns a ResultSet object
SQLTimeoutException - when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | xarly |
| Solution 2 | PUCHIE4BHAWAII |
