@Test(groups = SMALL) public void testGetTableColumnNamesUsesConnection() throws SQLException { tableMetadata.getColumnNames(TEST_TABLE_NAME); verify(mockedConnectionProvider).getConnection(); verify(mockedConnection).prepareStatement(anyString()); verify(mockedStmt).executeQuery(); }
List<String> getColumnNames(String tableName) throws SQLException { List<String> result = Lists.newArrayList(); try ( Connection connection = connectionProvider.getConnection(); PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) { stmt.setString(1, tableName); ResultSet rs = stmt.executeQuery(); while (rs.next()) { result.add(rs.getString(1)); } return result; } catch (SQLException sqle) { throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle); } }
TableMetadata { List<String> getColumnNames(String tableName) throws SQLException { List<String> result = Lists.newArrayList(); try ( Connection connection = connectionProvider.getConnection(); PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) { stmt.setString(1, tableName); ResultSet rs = stmt.executeQuery(); while (rs.next()) { result.add(rs.getString(1)); } return result; } catch (SQLException sqle) { throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle); } } }
TableMetadata { List<String> getColumnNames(String tableName) throws SQLException { List<String> result = Lists.newArrayList(); try ( Connection connection = connectionProvider.getConnection(); PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) { stmt.setString(1, tableName); ResultSet rs = stmt.executeQuery(); while (rs.next()) { result.add(rs.getString(1)); } return result; } catch (SQLException sqle) { throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle); } } TableMetadata(ConnectionProvider connectionProvider); }
TableMetadata { List<String> getColumnNames(String tableName) throws SQLException { List<String> result = Lists.newArrayList(); try ( Connection connection = connectionProvider.getConnection(); PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) { stmt.setString(1, tableName); ResultSet rs = stmt.executeQuery(); while (rs.next()) { result.add(rs.getString(1)); } return result; } catch (SQLException sqle) { throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle); } } TableMetadata(ConnectionProvider connectionProvider);  }
TableMetadata { List<String> getColumnNames(String tableName) throws SQLException { List<String> result = Lists.newArrayList(); try ( Connection connection = connectionProvider.getConnection(); PreparedStatement stmt = connection.prepareStatement(GET_COLUMN_NAMES_QUERY)) { stmt.setString(1, tableName); ResultSet rs = stmt.executeQuery(); while (rs.next()) { result.add(rs.getString(1)); } return result; } catch (SQLException sqle) { throw new DataAccessException(COLUMN_NAMES_ERROR + tableName, sqle); } } TableMetadata(ConnectionProvider connectionProvider);   }