Skip to content

Commit

Permalink
use a local connection object in DBSplitter
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Jul 27, 2022
1 parent be612a8 commit cda7562
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public class DBSplitter {

private final DatabaseConnectionPool connectionPool;
private final AbstractDatabaseAdapter databaseAdapter;
private final Connection connection;
private final String schema;
private final SchemaMapping schemaMapping;
private final SQLQueryBuilder builder;
Expand Down Expand Up @@ -137,8 +136,6 @@ public DBSplitter(FeatureWriter writer,

connectionPool = DatabaseConnectionPool.getInstance();
databaseAdapter = connectionPool.getActiveDatabaseAdapter();
connection = connectionPool.getConnection();
connection.setAutoCommit(false);
schema = databaseAdapter.getConnectionDetails().getSchema();

GeneralOptions generalOptions = config.getExportConfig().getGeneralOptions();
Expand Down Expand Up @@ -187,12 +184,16 @@ public void shutdown() {
}

public void startQuery() throws SQLException, QueryBuildException, FilterException, FeatureWriteException {
Connection connection = null;
try {
connection = connectionPool.getConnection();
connection.setAutoCommit(false);

FeatureType cityObjectGroupType = schemaMapping.getFeatureType("CityObjectGroup", CityObjectGroupModule.v2_0_0.getNamespaceURI());
Map<Long, DBSplittingResult> cityObjectGroups = new LinkedHashMap<>();
sequenceId = 0;

queryCityObject(cityObjectGroupType, cityObjectGroups);
queryCityObject(cityObjectGroupType, cityObjectGroups, connection);

if (shouldRun) {
try {
Expand All @@ -203,7 +204,7 @@ public void startQuery() throws SQLException, QueryBuildException, FilterExcepti
}

if (!cityObjectGroups.isEmpty()) {
queryCityObjectGroups(cityObjectGroupType, cityObjectGroups);
queryCityObjectGroups(cityObjectGroupType, cityObjectGroups, connection);

if (shouldRun) {
try {
Expand All @@ -224,7 +225,7 @@ public void startQuery() throws SQLException, QueryBuildException, FilterExcepti
}
}

private void queryCityObject(FeatureType cityObjectGroupType, Map<Long, DBSplittingResult> cityObjectGroups) throws SQLException, QueryBuildException, FeatureWriteException {
private void queryCityObject(FeatureType cityObjectGroupType, Map<Long, DBSplittingResult> cityObjectGroups, Connection connection) throws SQLException, QueryBuildException, FeatureWriteException {
if (!shouldRun)
return;

Expand Down Expand Up @@ -344,7 +345,7 @@ private void queryCityObject(FeatureType cityObjectGroupType, Map<Long, DBSplitt
}
}

private void queryCityObjectGroups(FeatureType cityObjectGroupType, Map<Long, DBSplittingResult> cityObjectGroups) throws SQLException, FilterException, QueryBuildException {
private void queryCityObjectGroups(FeatureType cityObjectGroupType, Map<Long, DBSplittingResult> cityObjectGroups, Connection connection) throws SQLException, FilterException, QueryBuildException {
if (!shouldRun)
return;

Expand Down

0 comments on commit cda7562

Please sign in to comment.