use of cascading.tap.TapException in project SpyGlass by ParallelAI.
the class JDBCTap method executeUpdate.
/**
* Method executeUpdate allows for ad-hoc update statements to be sent to the remote RDBMS. The number of
* rows updated will be returned, if applicable.
*
* @param updateString of type String
* @return int
*/
public int executeUpdate(String updateString) {
Connection connection = null;
int result;
try {
connection = createConnection();
try {
LOG.info("executing update: {}", updateString);
Statement statement = connection.createStatement();
result = statement.executeUpdate(updateString);
connection.commit();
statement.close();
} catch (SQLException exception) {
throw new TapException("unable to execute update statement: " + updateString, exception);
}
} finally {
try {
if (connection != null)
connection.close();
} catch (SQLException exception) {
// ignore
LOG.warn("ignoring connection close exception", exception);
}
}
return result;
}
use of cascading.tap.TapException in project SpyGlass by ParallelAI.
the class JDBCTap method executeQuery.
/**
* Method executeQuery allows for ad-hoc queries to be sent to the remove RDBMS. A value
* of -1 for returnResults will return a List of all results from the query, a value of 0 will return an empty List.
*
* @param queryString of type String
* @param returnResults of type int
* @return List
*/
public List<Object[]> executeQuery(String queryString, int returnResults) {
Connection connection = null;
List<Object[]> result = Collections.emptyList();
try {
connection = createConnection();
try {
LOG.info("executing query: {}", queryString);
Statement statement = connection.createStatement();
// we don't care about results
ResultSet resultSet = statement.executeQuery(queryString);
if (returnResults != 0)
result = copyResultSet(resultSet, returnResults == -1 ? Integer.MAX_VALUE : returnResults);
connection.commit();
statement.close();
} catch (SQLException exception) {
throw new TapException("unable to execute query statement: " + queryString, exception);
}
} finally {
try {
if (connection != null)
connection.close();
} catch (SQLException exception) {
// ignore
LOG.warn("ignoring connection close exception", exception);
}
}
return result;
}
use of cascading.tap.TapException in project SpyGlass by ParallelAI.
the class JDBCTapCollector method close.
@Override
public void close() {
try {
LOG.info("closing tap collector for: {}", tap);
writer.close(reporter);
} catch (IOException exception) {
LOG.warn("exception closing: {}", exception);
throw new TapException("exception closing JDBCTapCollector", exception);
} finally {
super.close();
}
}
Aggregations