Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.jdbc.datasource.embedded;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -42,11 +43,13 @@ abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseCon
|
||||
try {
|
||||
con = dataSource.getConnection();
|
||||
if (con != null) {
|
||||
con.createStatement().execute("SHUTDOWN");
|
||||
try (Statement stmt = con.createStatement()) {
|
||||
stmt.execute("SHUTDOWN");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Could not shut down embedded database", ex);
|
||||
logger.info("Could not shut down embedded database", ex);
|
||||
}
|
||||
finally {
|
||||
if (con != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -66,20 +66,23 @@ public class CustomSQLExceptionTranslatorRegistry {
|
||||
private CustomSQLExceptionTranslatorRegistry() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a new custom translator for the specified database name.
|
||||
* @param dbName the database name
|
||||
* @param translator the custom translator
|
||||
*/
|
||||
public void registerTranslator(String dbName, SQLExceptionTranslator translator) {
|
||||
SQLExceptionTranslator replaced = translatorMap.put(dbName, translator);
|
||||
if (replaced != null) {
|
||||
logger.warn("Replacing custom translator [" + replaced + "] for database '" + dbName +
|
||||
"' with [" + translator + "]");
|
||||
}
|
||||
else {
|
||||
logger.info("Adding custom translator of type [" + translator.getClass().getName() +
|
||||
"] for database '" + dbName + "'");
|
||||
SQLExceptionTranslator replaced = this.translatorMap.put(dbName, translator);
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (replaced != null) {
|
||||
logger.debug("Replacing custom translator [" + replaced + "] for database '" + dbName +
|
||||
"' with [" + translator + "]");
|
||||
}
|
||||
else {
|
||||
logger.debug("Adding custom translator of type [" + translator.getClass().getName() +
|
||||
"] for database '" + dbName + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user