sqlite-jdbc icon indicating copy to clipboard operation
sqlite-jdbc copied to clipboard

Use SQLSTATE codes

Open ott opened this issue 10 years ago • 7 comments

It would be helpful if sqlite-jdbc could map SQLite error codes and conditions to SQLSTATE codes so that it is possible to determine the reason for a SQLException without parsing the error message. A common use case for this are serialization and locking errors.

ott avatar Nov 30 '15 13:11 ott

Is there any standard for SQLSTATE codes?

xerial avatar Nov 30 '15 19:11 xerial

The SQL standard defines the SQLSTATE codes. Various vendors document their SQLSTATE codes themselves because the SQL standard can only be purchased at a high price through the ISO and its members. A late draft of SQL:2003 and final drafts of SQL:2011 seem to be freely available on the Internet and SQL-92 also defines several SQLSTATE codes. However, I'm not sure whether all SQLite errors can be represented as standardized SQLSTATE codes and which revision of the SQL standard would be necessary to reference the codes.

ott avatar Dec 01 '15 11:12 ott

OK. What types of SQLSTATE do you usually use?

xerial avatar Dec 01 '15 16:12 xerial

I think classes 08, 09, 22, 23, 27 and 40 could apply. Class 23 looks very broad but most errors do not apply to SQLite. Classes 08 and 40 are the most important to me.

ott avatar Dec 02 '15 10:12 ott

Is this still relevant?

gotson avatar Jul 29 '22 06:07 gotson

If it has not changed, it is still relevant. However, I ended up writing my own JDBC driver.

ott avatar Jul 30 '22 20:07 ott

If it has not changed, it is still relevant

I am asking as i am now helping to maintain this repo, but i can't go through the whole history for every single issue, especially those that are a few years old.

However, I ended up writing my own JDBC driver.

Nice, would you mind sharing this for information ? Did that solve the SQLState thing ?

gotson avatar Aug 01 '22 03:08 gotson

Unfortunately, I can't share this for information. However, I did solve the issue with SQLSTATE by mapping the SQLite error codes as best as I could.

ott avatar Aug 17 '22 23:08 ott

@ott do you still need this ticket, or can we close it?

gotson avatar Aug 18 '22 00:08 gotson

I don't use this driver anymore and your question illustrates the reason for this decision. So if you don't wan to implement SQLSTATE codes and have a JDBC compliant driver, this ticket can be closed.

ott avatar Aug 18 '22 07:08 ott