
filldb.core.DB Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of filldb Show documentation
Show all versions of filldb Show documentation
A tool for filling a mariadb database with test data
The newest version!
package filldb.core;
import filldb.model.CliArguments;
import org.mariadb.jdbc.Driver;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
public enum DB {;
public static Properties toDbDriverProperties(final CliArguments arguments) {
final Properties props = new Properties();
props.setProperty("user", arguments.username);
props.setProperty("password", arguments.password);
return props;
}
public static Connection connect(final String jdbcUrl, final Properties properties) throws SQLException {
final Driver driver = new Driver();
return driver.connect(jdbcUrl, properties);
}
public static void executeQueries(final Connection connection, final List queries) throws SQLException {
for (final var query : queries) {
if (query.isEmpty()) continue;
try (final var statement = connection.createStatement()) {
statement.executeUpdate(query);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy