I am creating a REST API and working on returning the correct status code to the customer. I have a SQLite database and have created a table like this:
create table view (id integer primary key autoincreent, name varchar (10) is not unique, data varchar (10) not Faucet)
The connection to the database works fine. I can also add a visual unit to the table. When I run prepstmnt.execute () to present another view as a scene before same , I get a SQLException as expected (since the name is unique).
Because this method can throw SQLException for a variety of reasons, so I want to know when the reason is a violation of the barrier, so I can return the HTTP status code. 409 Clash I struggled for it Trying to do it by arrackcode () and getMessage ():
hold (SQLException e) {System.out.println (e.getErrorCode () + ":" + e.getMessage () ); 0: [SQLITE_CONSTRAINT] Revoke due to constraint violation (column name is not unique) As you can see that I get the error code 0. SQLite documentation according to the result code 0 mean ok is.
Instead, I should get code 1 for SQLITE_CONSTRAINT. The message sounds fine, but I did not want to parse the message. In the SQLite error code, there is a subset of the result code, does it take the JDBC account or the error code is completely different? How do I get the result code from SQLException or a prepared statement?
No comments:
Post a Comment