@Test public void testGetTableRowCount() throws Exception { assertEquals("Table " + table + " is expected to be empty.", NUMBER_OF_ROWS, executor.getTableRowCount(table)); }
public long getTableRowCount(String tableName) { ResultSet resultSet = executeQuery("SELECT COUNT(1) FROM " + tableName); try { resultSet.next(); return resultSet.getLong(1); } catch(SQLException e) { throw new SqoopException( GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e); } finally { try { if(resultSet != null) resultSet.close(); } catch(SQLException e) { logSQLException(e, "Got SQLException while closing resultset."); } } }
GenericJdbcExecutor { public long getTableRowCount(String tableName) { ResultSet resultSet = executeQuery("SELECT COUNT(1) FROM " + tableName); try { resultSet.next(); return resultSet.getLong(1); } catch(SQLException e) { throw new SqoopException( GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e); } finally { try { if(resultSet != null) resultSet.close(); } catch(SQLException e) { logSQLException(e, "Got SQLException while closing resultset."); } } } }
GenericJdbcExecutor { public long getTableRowCount(String tableName) { ResultSet resultSet = executeQuery("SELECT COUNT(1) FROM " + tableName); try { resultSet.next(); return resultSet.getLong(1); } catch(SQLException e) { throw new SqoopException( GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e); } finally { try { if(resultSet != null) resultSet.close(); } catch(SQLException e) { logSQLException(e, "Got SQLException while closing resultset."); } } } GenericJdbcExecutor(LinkConfig linkConfig); }
GenericJdbcExecutor { public long getTableRowCount(String tableName) { ResultSet resultSet = executeQuery("SELECT COUNT(1) FROM " + tableName); try { resultSet.next(); return resultSet.getLong(1); } catch(SQLException e) { throw new SqoopException( GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e); } finally { try { if(resultSet != null) resultSet.close(); } catch(SQLException e) { logSQLException(e, "Got SQLException while closing resultset."); } } } GenericJdbcExecutor(LinkConfig linkConfig); ResultSet executeQuery(String sql); PreparedStatement createStatement(String sql); void setAutoCommit(boolean autoCommit); void deleteTableData(String tableName); void migrateData(String fromTable, String toTable); long getTableRowCount(String tableName); void executeUpdate(String sql); void beginBatch(String sql); void addBatch(Object[] array, Schema schema); void executeBatch(boolean commit); void endBatch(); String getPrimaryKey(String table); String[] getQueryColumns(String query); boolean existTable(String table); String qualify(String name, String qualifier); String[] dequalify(String name); String delimitIdentifier(String name); void close(); }
GenericJdbcExecutor { public long getTableRowCount(String tableName) { ResultSet resultSet = executeQuery("SELECT COUNT(1) FROM " + tableName); try { resultSet.next(); return resultSet.getLong(1); } catch(SQLException e) { throw new SqoopException( GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e); } finally { try { if(resultSet != null) resultSet.close(); } catch(SQLException e) { logSQLException(e, "Got SQLException while closing resultset."); } } } GenericJdbcExecutor(LinkConfig linkConfig); ResultSet executeQuery(String sql); PreparedStatement createStatement(String sql); void setAutoCommit(boolean autoCommit); void deleteTableData(String tableName); void migrateData(String fromTable, String toTable); long getTableRowCount(String tableName); void executeUpdate(String sql); void beginBatch(String sql); void addBatch(Object[] array, Schema schema); void executeBatch(boolean commit); void endBatch(); String getPrimaryKey(String table); String[] getQueryColumns(String query); boolean existTable(String table); String qualify(String name, String qualifier); String[] dequalify(String name); String delimitIdentifier(String name); void close(); static final String JDBC_PROPERTY_USERNAME; static final String JDBC_PROPERTY_PASSWORD; }