diff --git a/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml b/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml index 15329647e2..3fe34efed5 100644 --- a/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml +++ b/spring-jdbc/src/main/resources/org/springframework/jdbc/support/sql-error-codes.xml @@ -248,4 +248,44 @@ + + + + SAP DB + + + + 257,259,260,261,262,263,264,267,268,269,270,271,272,273,275,276,277,278, + 278,279,280,281,282,283,284,285,286,288,289,290,294,295,296,297,299,308,309, + 313,315,316,318,319,320,321,322,323,324,328,329,330,333,335,336,337,338,340, + 343,350,351,352,362,368 + + + + 10,258 + + + 301 + + + 461,462 + + + -813,-709,-708,1024,1025,1026,1027,1029,1030,1031 + + + -11210,582,587,588,594 + + + 131 + + + 138,143 + + + 133 + + + + diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java index 944b77c5dc..3a0e755abc 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import static org.mockito.BDDMockito.*; * * @author Rod Johnson * @author Thomas Risberg + * @author Stephane Nicoll */ public class SQLErrorCodesFactoryTests { @@ -120,6 +121,22 @@ public class SQLErrorCodesFactoryTests { assertTrue(Arrays.binarySearch(sec.getBadSqlGrammarCodes(), "-204") >= 0); } + private void assertIsHana(SQLErrorCodes sec) { + assertTrue(sec.getBadSqlGrammarCodes().length > 0); + assertTrue(sec.getDataIntegrityViolationCodes().length > 0); + + assertTrue(Arrays.binarySearch(sec.getBadSqlGrammarCodes(), "368") >= 0); + assertTrue(Arrays.binarySearch(sec.getPermissionDeniedCodes(), "10") >= 0); + assertTrue(Arrays.binarySearch(sec.getDuplicateKeyCodes(), "301") >= 0); + assertTrue(Arrays.binarySearch(sec.getDataIntegrityViolationCodes(), "461") >= 0); + assertTrue(Arrays.binarySearch(sec.getDataAccessResourceFailureCodes(), "-813") >=0); + assertTrue(Arrays.binarySearch(sec.getInvalidResultSetAccessCodes(), "582") >=0); + assertTrue(Arrays.binarySearch(sec.getCannotAcquireLockCodes(), "131") >= 0); + assertTrue(Arrays.binarySearch(sec.getCannotSerializeTransactionCodes(), "138") >= 0); + assertTrue(Arrays.binarySearch(sec.getDeadlockLoserCodes(), "133") >= 0); + + } + @Test public void testLookupOrder() { class TestSQLErrorCodesFactory extends SQLErrorCodesFactory { @@ -297,6 +314,12 @@ public class SQLErrorCodesFactoryTests { assertIsEmpty(sec); } + @Test + public void testHanaIsRecognizedFromMetadata() throws Exception { + SQLErrorCodes sec = getErrorCodesFromDataSource("SAP DB", null); + assertIsHana(sec); + } + /** * Check that wild card database name works. */