@Test public void testExecuteQueryAllRows() throws Exception { sqlInputs.setDbType(ORACLE_DB_TYPE); sqlInputs.setDbPort(30); sqlInputs.setDbServer("localhost"); sqlInputs.setDbName("/dbName"); sqlInputs.setRowDelimiter(","); sqlInputs.setColDelimiter("|"); sqlInputs.setTimeout(QUYERY_TIMEOUT); sqlInputs.setSqlCommand(SQL_QUERY); final String execQueryAllRows = SQLQueryAllRowsService.execQueryAllRows(sqlInputs); assertEquals("", execQueryAllRows); verify(connectionMock, Mockito.times(1)).setReadOnly(true); verify(statementMock, Mockito.times(1)).setQueryTimeout(QUYERY_TIMEOUT); verify(statementMock, Mockito.times(1)).executeQuery(SQL_QUERY); verify(resultSetMock, Mockito.times(1)).close(); }
public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter()); if (resultSet != null) { resultSet.close(); } return resultSetToDelimitedColsAndRows; } }
SQLQueryAllRowsService { public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter()); if (resultSet != null) { resultSet.close(); } return resultSetToDelimitedColsAndRows; } } }
SQLQueryAllRowsService { public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter()); if (resultSet != null) { resultSet.close(); } return resultSetToDelimitedColsAndRows; } }  }
SQLQueryAllRowsService { public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter()); if (resultSet != null) { resultSet.close(); } return resultSetToDelimitedColsAndRows; } }  static String execQueryAllRows(@NotNull final SQLInputs sqlInputs); }
SQLQueryAllRowsService { public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter()); if (resultSet != null) { resultSet.close(); } return resultSetToDelimitedColsAndRows; } }  static String execQueryAllRows(@NotNull final SQLInputs sqlInputs);  }