Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13424 fixes the mysql lockup issue #13426

Merged
merged 2 commits into from
Jan 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 18 additions & 38 deletions dotCMS/src/main/java/com/dotmarketing/common/db/DotConnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.dotmarketing.util.json.JSONObject;
import static com.dotcms.util.CollectionsUtils.*;

import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'com.dotcms.business.WrapInTransaction'. rule


/**
* Description of the Class
*
Expand Down Expand Up @@ -1114,42 +1117,15 @@ public int executeUpdate (final String preparedStatement,
* @return int rows affected
* @throws DotDataException
*/

public int executeUpdate (final String preparedStatement, Boolean logException,
final Object... parameters) throws DotDataException {

final boolean isNewTransaction = DbConnectionFactory.startTransactionIfNeeded();
Connection connection = null;
int rowsAffected = 0;

try {

connection = DbConnectionFactory.getConnection();
rowsAffected = this.executeUpdate(connection,
preparedStatement, logException, parameters);
return this.executeUpdate(DbConnectionFactory.getConnection(),
preparedStatement, logException, parameters);

if (isNewTransaction) {
connection.commit();
}
} catch (DotDataException e) {

if (isNewTransaction) {
this.rollback(connection);
}
throw e;
} catch (Exception e) {

if (logException) {
Logger.error(DotConnect.class, e.getMessage(), e);
}
throw new DotDataException(e.getMessage(), e);
} finally {

if (isNewTransaction) {
closeQuietly(connection);
}
}

return rowsAffected;
} // executeUpdate.

protected void rollback(final Connection connection) throws DotDataException {
Expand Down Expand Up @@ -1186,29 +1162,33 @@ public int executeUpdate (final Connection connection, final String preparedStat
* @return int rows affected
* @throws DotDataException
*/
@CloseDBIfOpened
public int executeUpdate (final Connection connection, final String preparedStatementString, Boolean logException,
final Object... parameters) throws DotDataException {


PreparedStatement preparedStatement = null;
int rowsAffected = 0;

PreparedStatement preparedStatement = null;
try {

preparedStatement = connection.prepareStatement(preparedStatementString);
this.setParams(preparedStatement, parameters);
rowsAffected = preparedStatement.executeUpdate();
return preparedStatement.executeUpdate();
} catch (SQLException e) {
if (logException) {
Logger.error(DotConnect.class, e.getMessage(), e);
}
throw new DotDataException(e.getMessage(), e);
} finally {

closeQuietly(preparedStatement);
if(null!= preparedStatement ) {
try {
preparedStatement.close();
} catch (SQLException e) {
Logger.debug(this.getClass(), e.getMessage(),e);
}
}
}

return rowsAffected;

} // executeUpdate.

private static void setTimestampWithTimezone(PreparedStatement statement, int parameterIndex, Object timestamp) {
Expand All @@ -1224,4 +1204,4 @@ private static void setTimestampWithTimezone(PreparedStatement statement, int pa
}
}

}
}