db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jørgen Løland <Jorgen.Lol...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-3523) sql states (X0Y63, X0Y63, X0Y63.S) related to nulls in unique constraints are associated with wrong message texts
Date Wed, 12 Mar 2008 07:10:35 GMT
Mike Matrigali wrote:
 > It does seem like the best case would be for the error message system to
 > somehow return a different error message for the same number if it is
 > in soft upgrade vs. hard upgrade.  Does the error message system support
 > such a thing?

Yes, it does. If you want multiple messages with the same SQL state, you 
need to add the ".<severity>.<#>" information to the error state in 
SQLState.java. E.g, all these messages have SQL State 08004:

----- snip from SQLState.java ----
String LOGIN_FAILED = "08004";
String NET_CONNECT_AUTH_FAILED                          = "08004.C.1";
String NET_DATABASE_NOT_FOUND                           = "08004.C.2";
String AUTH_DATABASE_CONNECTION_REFUSED                 = "08004.C.3";
String AUTH_SHUTDOWN_NOT_DB_OWNER                       = "08004.C.4";
String AUTH_ENCRYPT_NOT_DB_OWNER                        = "08004.C.5";
----- snip -------

If, e.g., both these messages

'{0}' cannot be a column of a primary key or unique key because it can 
contain null values.
'{0}' cannot be a column of a primary key because it can contain null 

... should have the same 42831 error code, you would need something like 
this in the SQLState.java file:


'S' because 42831 is statement severity level (see class javadoc in 
SQLState.java), while 1 and 2 are used to tell the messages apart. 
messages.xml also needs to be updated, of course.

View raw message