Merge branch '1.5.x'

pull/8568/head
Stephane Nicoll 8 years ago
commit 4f7e5efac8

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,6 +36,7 @@ import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
* @author Lukas Eder * @author Lukas Eder
* @author Andreas Ahlenstorf * @author Andreas Ahlenstorf
* @author Phillip Webb * @author Phillip Webb
* @author Stephane Nicoll
*/ */
class JooqExceptionTranslator extends DefaultExecuteListener { class JooqExceptionTranslator extends DefaultExecuteListener {
@ -58,8 +59,10 @@ class JooqExceptionTranslator extends DefaultExecuteListener {
private SQLExceptionTranslator getTranslator(ExecuteContext context) { private SQLExceptionTranslator getTranslator(ExecuteContext context) {
SQLDialect dialect = context.configuration().dialect(); SQLDialect dialect = context.configuration().dialect();
if (dialect != null && dialect.thirdParty() != null) { if (dialect != null && dialect.thirdParty() != null) {
return new SQLErrorCodeSQLExceptionTranslator( String dbName = dialect.thirdParty().springDbName();
dialect.thirdParty().springDbName()); if (dbName != null) {
return new SQLErrorCodeSQLExceptionTranslator(dbName);
}
} }
return new SQLStateSQLExceptionTranslator(); return new SQLStateSQLExceptionTranslator();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -58,7 +58,8 @@ public class JooqExceptionTranslatorTests {
new Object[] { SQLDialect.POSTGRES, sqlException("03000") }, new Object[] { SQLDialect.POSTGRES, sqlException("03000") },
new Object[] { SQLDialect.POSTGRES_9_3, sqlException("03000") }, new Object[] { SQLDialect.POSTGRES_9_3, sqlException("03000") },
new Object[] { SQLDialect.POSTGRES_9_4, sqlException("03000") }, new Object[] { SQLDialect.POSTGRES_9_4, sqlException("03000") },
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") } }; new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") },
new Object[] { SQLDialect.SQLITE, sqlException("21000") }};
} }
private static SQLException sqlException(String sqlState) { private static SQLException sqlException(String sqlState) {

Loading…
Cancel
Save