use of org.flywaydb.core.internal.jdbc.Results in project flyway by flyway.
the class InsertRowLock method insertLockingRow.
private boolean insertLockingRow(String insertStatementTemplate, String booleanTrue) {
String insertStatement = String.format(insertStatementTemplate.replace("?", "%s"), -100, "'" + tableLockString + "'", "'flyway-lock'", "''", "''", 0, "''", 0, booleanTrue);
// Insert the locking row - the primary key-ness of 'installed_rank' will prevent us having two
Results results = jdbcTemplate.executeStatement(insertStatement);
// Succeed if there were no errors
return results.getException() == null;
}
use of org.flywaydb.core.internal.jdbc.Results in project flyway by flyway.
the class SybaseASEDatabase method getDdlInTranOption.
boolean getDdlInTranOption() {
try {
// http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36273.1600/doc/html/san1393052037182.html
String databaseName = getDatabaseName();
// The Sybase driver (v7.07) concatenates "null" to this query and we can't see why. By adding a one-line
// comment marker we can at least prevent this causing us problems until we get a resolution.
String getDatabaseMetadataQuery = "sp_helpdb " + databaseName + " -- ";
Results results = getMainConnection().getJdbcTemplate().executeStatement(getDatabaseMetadataQuery);
for (int resultsIndex = 0; resultsIndex < results.getResults().size(); resultsIndex++) {
List<String> columns = results.getResults().get(resultsIndex).getColumns();
if (columns != null) {
int statusIndex = getStatusIndex(columns);
if (statusIndex > -1) {
String options = results.getResults().get(resultsIndex).getData().get(0).get(statusIndex);
return options.contains("ddl in tran");
}
}
}
return false;
} catch (Exception e) {
throw new FlywayException(e);
}
}
use of org.flywaydb.core.internal.jdbc.Results in project flyway by flyway.
the class DefaultSqlScriptExecutor method executeStatement.
protected void executeStatement(JdbcTemplate jdbcTemplate, SqlScript sqlScript, SqlStatement sqlStatement) {
logStatementExecution(sqlStatement);
String sql = sqlStatement.getSql() + sqlStatement.getDelimiter();
Results results = sqlStatement.execute(jdbcTemplate);
if (results.getException() != null) {
printWarnings(results);
handleException(results, sqlScript, sqlStatement);
return;
}
printWarnings(results);
handleResults(results);
}
use of org.flywaydb.core.internal.jdbc.Results in project flyway by flyway.
the class PostgreSQLCopyParsedStatement method execute.
@Override
public Results execute(JdbcTemplate jdbcTemplate) {
// #2355: Use reflection to ensure this works in cases where the PostgreSQL driver classes were loaded in a
// child URLClassLoader instead of the system classloader.
Object baseConnection;
Object copyManager;
Method copyManagerCopyInMethod;
try {
Connection connection = jdbcTemplate.getConnection();
ClassLoader classLoader = connection.getClass().getClassLoader();
Class<?> baseConnectionClass = classLoader.loadClass("org.postgresql.core.BaseConnection");
baseConnection = connection.unwrap(baseConnectionClass);
Class<?> copyManagerClass = classLoader.loadClass("org.postgresql.copy.CopyManager");
Constructor<?> copyManagerConstructor = copyManagerClass.getConstructor(baseConnectionClass);
copyManagerCopyInMethod = copyManagerClass.getMethod("copyIn", String.class, Reader.class);
copyManager = copyManagerConstructor.newInstance(baseConnection);
} catch (Exception e) {
throw new FlywayException("Unable to find PostgreSQL CopyManager class", e);
}
Results results = new Results();
try {
try {
Long updateCount = (Long) copyManagerCopyInMethod.invoke(copyManager, getSql(), new StringReader(copyData));
results.addResult(new Result(updateCount, null, null, getSql()));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new SQLException("Unable to execute COPY operation", e);
}
} catch (SQLException e) {
jdbcTemplate.extractErrors(results, e);
}
return results;
}
use of org.flywaydb.core.internal.jdbc.Results in project flyway by flyway.
the class SpannerSchema method doAllForeignKeys.
private List<String[]> doAllForeignKeys() {
List<String[]> foreignKeyAndTableList = new ArrayList<>();
Results foreignKeyRs = jdbcTemplate.executeStatement("SELECT CONSTRAINT_NAME, TABLE_NAME " + "FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS " + "WHERE CONSTRAINT_TYPE='FOREIGN KEY'");
for (Result result : foreignKeyRs.getResults()) {
for (List<String> row : result.getData()) {
String[] foreignKeyAndTable = { row.get(0), row.get(1) };
foreignKeyAndTableList.add(foreignKeyAndTable);
}
}
return foreignKeyAndTableList;
}
Aggregations