use of org.flywaydb.core.internal.jdbc.Result in project flyway by flyway.
the class DefaultSqlScriptExecutor method handleResults.
protected void handleResults(Results results) {
for (Result result : results.getResults()) {
long updateCount = result.getUpdateCount();
if (updateCount != -1) {
handleUpdateCount(updateCount);
}
outputQueryResult(result);
}
}
use of org.flywaydb.core.internal.jdbc.Result 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.Result 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