@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2020 the original author or authors .
* Copyright 2002 - 2022 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 .
@ -20,7 +20,6 @@ import java.sql.SQLException;
import javax.sql.DataSource ;
import javax.sql.DataSource ;
import org.springframework.core.SpringProperties ;
import org.springframework.dao.DataAccessException ;
import org.springframework.dao.DataAccessException ;
import org.springframework.jdbc.datasource.DataSourceTransactionManager ;
import org.springframework.jdbc.datasource.DataSourceTransactionManager ;
import org.springframework.lang.Nullable ;
import org.springframework.lang.Nullable ;
@ -53,14 +52,6 @@ import org.springframework.lang.Nullable;
@SuppressWarnings ( "serial" )
@SuppressWarnings ( "serial" )
public class JdbcTransactionManager extends DataSourceTransactionManager {
public class JdbcTransactionManager extends DataSourceTransactionManager {
/ * *
* 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" ) ;
@Nullable
@Nullable
private volatile SQLExceptionTranslator exceptionTranslator ;
private volatile SQLExceptionTranslator exceptionTranslator ;
@ -97,9 +88,12 @@ public class JdbcTransactionManager extends DataSourceTransactionManager {
* @see java . sql . DatabaseMetaData # getDatabaseProductName ( )
* @see java . sql . DatabaseMetaData # getDatabaseProductName ( )
* /
* /
public void setDatabaseProductName ( String dbName ) {
public void setDatabaseProductName ( String dbName ) {
if ( ! shouldIgnoreXml ) {
if ( SQLErrorCodeSQLExceptionTranslator . hasUserProvidedErrorCodesFile ( ) ) {
this . exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( dbName ) ;
this . exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( dbName ) ;
}
}
else {
this . exceptionTranslator = new SQLExceptionSubclassTranslator ( ) ;
}
}
}
/ * *
/ * *
@ -128,11 +122,11 @@ public class JdbcTransactionManager extends DataSourceTransactionManager {
synchronized ( this ) {
synchronized ( this ) {
exceptionTranslator = this . exceptionTranslator ;
exceptionTranslator = this . exceptionTranslator ;
if ( exceptionTranslator = = null ) {
if ( exceptionTranslator = = null ) {
if ( shouldIgnoreXml ) {
if ( SQLErrorCodeSQLExceptionTranslator . hasUserProvidedErrorCodesFile ( ) ) {
exceptionTranslator = new SQLExceptionSubclassTranslator ( ) ;
exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( obtainDataSource ( ) ) ;
}
}
else {
else {
exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator ( obtainDataSource ( ) ) ;
exceptionTranslator = new SQLExceptionSubclassTranslator ( ) ;
}
}
this . exceptionTranslator = exceptionTranslator ;
this . exceptionTranslator = exceptionTranslator ;
}
}