Skip to content

Commit 5d27c7e

Browse files
committed
Handle non supported JOOQ dialect
This commit uses a fallback translator if the JOOQ Dialect in use is not one we support. Closes spring-projectsgh-8521
1 parent cbde6ed commit 5d27c7e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
* @author Lukas Eder
3737
* @author Andreas Ahlenstorf
3838
* @author Phillip Webb
39+
* @author Stephane Nicoll
3940
*/
4041
class JooqExceptionTranslator extends DefaultExecuteListener {
4142

@@ -58,8 +59,10 @@ public void exception(ExecuteContext context) {
5859
private SQLExceptionTranslator getTranslator(ExecuteContext context) {
5960
SQLDialect dialect = context.configuration().dialect();
6061
if (dialect != null && dialect.thirdParty() != null) {
61-
return new SQLErrorCodeSQLExceptionTranslator(
62-
dialect.thirdParty().springDbName());
62+
String dbName = dialect.thirdParty().springDbName();
63+
if (dbName != null) {
64+
return new SQLErrorCodeSQLExceptionTranslator(dbName);
65+
}
6366
}
6467
return new SQLStateSQLExceptionTranslator();
6568
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,7 +58,8 @@ public static Object[] parameters() {
5858
new Object[] { SQLDialect.POSTGRES, sqlException("03000") },
5959
new Object[] { SQLDialect.POSTGRES_9_3, sqlException("03000") },
6060
new Object[] { SQLDialect.POSTGRES_9_4, sqlException("03000") },
61-
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") } };
61+
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") },
62+
new Object[] { SQLDialect.SQLITE, sqlException("21000") }};
6263
}
6364

6465
private static SQLException sqlException(String sqlState) {

0 commit comments

Comments
 (0)