Polishing

This commit is contained in:
Juergen Hoeller
2020-03-24 00:56:36 +01:00
parent 9f71c98871
commit e51f660286
6 changed files with 51 additions and 79 deletions

View File

@@ -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.
@@ -138,6 +138,7 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
afterPropertiesSet();
}
/**
* Set the JDBC DataSource that this instance should manage transactions for.
* <p>This will typically be a locally defined DataSource, for example an
@@ -409,13 +410,9 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
throws SQLException {
if (isEnforceReadOnly() && definition.isReadOnly()) {
Statement stmt = con.createStatement();
try {
try (Statement stmt = con.createStatement()) {
stmt.executeUpdate("SET TRANSACTION READ ONLY");
}
finally {
stmt.close();
}
}
}