Skip to content

Commit

Permalink
Merge pull request CodePhiliaX#1182 from openai0229/issue#1135
Browse files Browse the repository at this point in the history
transaction support
  • Loading branch information
Chat2DB-Pro authored Feb 26, 2024
2 parents c2b5fed + 8ba00fe commit cb0b614
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@

public class MysqlDBManage extends DefaultDBManage implements DBManage {
@Override
public void updateProcedure(Connection connection, String databaseName, String schemaName, Procedure procedure) {
String sql = "DROP PROCEDURE " + procedure.getProcedureName();
SQLExecutor.getInstance().execute(connection, sql, resultSet -> {});
String procedureBody = procedure.getProcedureBody();
SQLExecutor.getInstance().execute(connection, procedureBody, resultSet -> {});
public void updateProcedure(Connection connection, String databaseName, String schemaName, Procedure procedure) throws SQLException {
try {
connection.setAutoCommit(false);
String sql = "DROP PROCEDURE " + procedure.getProcedureName();
SQLExecutor.getInstance().execute(connection, sql, resultSet -> {});
String procedureBody = procedure.getProcedureBody();
SQLExecutor.getInstance().execute(connection, procedureBody, resultSet -> {});
connection.commit();
} catch (Exception e) {
connection.rollback();
throw new RuntimeException(e);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.validation.constraints.NotNull;

import java.sql.Connection;
import java.sql.SQLException;

/**
* @author jipengfei
Expand Down Expand Up @@ -119,5 +120,5 @@ void dropProcedure(Connection connection, @NotEmpty String databaseName, String
* @param schemaName
* @param procedure
*/
void updateProcedure(Connection connection, @NotEmpty String databaseName, String schemaName, @NotNull Procedure procedure);
void updateProcedure(Connection connection, @NotEmpty String databaseName, String schemaName, @NotNull Procedure procedure) throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void dropProcedure(Connection connection, String databaseName, String sch
}

@Override
public void updateProcedure(Connection connection, String databaseName, String schemaName, Procedure procedure) {
public void updateProcedure(Connection connection, String databaseName, String schemaName, Procedure procedure) throws SQLException {

}

Expand Down

0 comments on commit cb0b614

Please sign in to comment.