Class MySqlDumpRunner
java.lang.Object
br.net.dd.netherwingcore.database.parser.MySqlDumpRunner
MySqlDumpRunner is a utility class designed to execute SQL dump files against a MySQL database connection.
It reads SQL statements from a specified dump file, handles comments and string literals correctly,
and executes the statements while managing transactions and error handling.
The class includes an inner static class, SqlStatementIterator, which is responsible for parsing the SQL dump file
and iterating over individual SQL statements, taking into account MySQL-specific syntax such as comments,
string literals, and custom delimiters.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidrunSqlDump(Connection conn, Path dumpFile) Executes the SQL statements contained in the specified dump file against the provided database connection.
-
Constructor Details
-
MySqlDumpRunner
public MySqlDumpRunner()
-
-
Method Details
-
runSqlDump
Executes the SQL statements contained in the specified dump file against the provided database connection. The method manages transactions, disables foreign key and unique checks for performance, and ensures that any errors during execution are properly handled with rollbacks.- Parameters:
conn- the Connection object representing the database connection to execute the SQL statements ondumpFile- the Path object representing the location of the SQL dump file to be executed- Throws:
IOException- if there is an error reading the dump fileSQLException- if there is an error executing any of the SQL statements
-