DatabaseJoin: prepared statement not closed when transform finishes processing
@@ -19,6 +19,7 @@ package org.apache.hop.pipeline.transforms.databasejoin;
import org.apache.hop.core.database.Database;
import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.core.exception.HopDatabaseException;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.exception.HopTransformException;
import org.apache.hop.core.row.IRowMeta;
@@ -244,7 +245,8 @@ public class DatabaseJoin extends BaseTransform<DatabaseJoinMeta, DatabaseJoinDa
DatabaseMeta databaseMeta = getPipelineMeta().findDatabase(meta.getConnection(), variables);
if (databaseMeta == null) {
logError(
- BaseMessages.getString(PKG, "DatabaseJoin.Init.ConnectionMissing", getTransformName()));
+ BaseMessages.getString(
+ PKG, "DatabaseJoin.Init.ConnectionMissing", getTransformName()));
return false;
}
@@ -270,7 +272,8 @@ public class DatabaseJoin extends BaseTransform<DatabaseJoinMeta, DatabaseJoinDa
return true;
} catch (HopException e) {
- logError(BaseMessages.getString(PKG, "DatabaseJoin.Log.DatabaseError") + e.getMessage(), e);
+ logError(
+ BaseMessages.getString(PKG, "DatabaseJoin.Log.DatabaseError") + e.getMessage(), e);
if (data.db != null) {
data.db.disconnect();
}
@@ -286,15 +289,21 @@ public class DatabaseJoin extends BaseTransform<DatabaseJoinMeta, DatabaseJoinDa
@Override
public void dispose() {
dbLock.lock();
-
try {
+ if (data.pstmt != null) {
+ data.db.closePreparedStatement(data.pstmt);
+ data.pstmt = null;
+ }
+ super.dispose();
+ } catch (HopDatabaseException e) {
+ logError("Unexpected error closing statement : " + e.toString());
+ setErrors(1);
+ stopAll();
+ } finally {
if (data.db != null) {
data.db.disconnect();
data.db = null;
}
-
- super.dispose();
- } finally{
dbLock.unlock();
}
}
