@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2018 the original author or authors .
* Copyright 2002 - 2020 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 .
@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory ;
import org.springframework.beans.factory.InitializingBean ;
import org.springframework.core.SpringProperties ;
import org.springframework.lang.Nullable ;
import org.springframework.util.Assert ;
@ -34,11 +35,19 @@ import org.springframework.util.Assert;
@@ -34,11 +35,19 @@ import org.springframework.util.Assert;
* See { @link org . springframework . jdbc . core . JdbcTemplate } .
*
* @author Juergen Hoeller
* @author Sebastien Deleuze
* @since 28 . 11 . 2003
* @see org . springframework . jdbc . core . JdbcTemplate
* /
public abstract class JdbcAccessor implements InitializingBean {
/ * *
* Boolean flag controlled by a { @code spring . xml . ignore } system property that instructs Spring to
* ignore XML , i . e . to not initialize the XML - related infrastructure .
* < p > The default is "false" .
* /
private static final boolean shouldIgnoreXml = SpringProperties . getFlag ( "spring.xml.ignore" ) ;
/** Logger available to subclasses. */
protected final Log logger = LogFactory . getLog ( getClass ( ) ) ;
@ -87,7 +96,9 @@ public abstract class JdbcAccessor implements InitializingBean {
@@ -87,7 +96,9 @@ public abstract class JdbcAccessor implements InitializingBean {
* @see java . sql . DatabaseMetaData # getDatabaseProductName ( )
* /
public void setDatabaseProductName ( String dbName ) {
this . exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( dbName ) ;
if ( ! shouldIgnoreXml ) {
this . exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( dbName ) ;
}
}
/ * *
@ -118,7 +129,10 @@ public abstract class JdbcAccessor implements InitializingBean {
@@ -118,7 +129,10 @@ public abstract class JdbcAccessor implements InitializingBean {
exceptionTranslator = this . exceptionTranslator ;
if ( exceptionTranslator = = null ) {
DataSource dataSource = getDataSource ( ) ;
if ( dataSource ! = null ) {
if ( shouldIgnoreXml ) {
exceptionTranslator = new SQLExceptionSubclassTranslator ( ) ;
}
else if ( dataSource ! = null ) {
exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( dataSource ) ;
}
else {