In general, considering ErrorCode & SQLState combination to be a unique ID for a specific exception, is it a safe thing to base your code logic on?

Also to be more specific, Does DataDirect follow such a thing?

Also for an exact case which is what I need, My code is generation the following Exception:

[SQLServer JDBC Driver]Changing the default holdability is not supported...

and the following:

System.out.println(">e.getErrorCode: " + e.getErrorCode());
System.out.println(">e.getSQLState: " + e.getSQLState());

is returing:

>e.getErrorCode:  0
>e.getSQLStat: hy000

So would it be safe to assume that if I check for 0 && hy00 then I'm filtering only the exception I mentioned earlier?

It would be very helpful if I can get a reference to an official DataDirect documentation that stating such facts.

有帮助吗?

解决方案

No you cannot assume this. SQLState HY000 is simply a generic CLI SQL error (as defined by the SQL CLI standard), and errorcode 0 means 'no specific error code was set'. Usually drivers use HY000 as the SQLState when nothing more specific is available, or if the developer didn't bother the specify anything else.

And even in general a single SQLState can cover a very broad range of errors, and whether a single error code (other than 0) is used for one error or a group of errors might depend on the database and on the context of the error.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top