@Test public void testExecuteSqlQueryTabularIsNetcool() throws Exception { sqlInputs.setDbType(ORACLE_DB_TYPE); sqlInputs.setDbPort(30); sqlInputs.setDbServer("localhost"); sqlInputs.setDbName("/dbName"); sqlInputs.setTimeout(QUYERY_TIMEOUT); sqlInputs.setNetcool(true); sqlInputs.setSqlCommand(SQL_COMMAND); final String execSqlQueryTabular = SQLQueryTabularService.execSqlQueryTabular(sqlInputs); assertEquals("\n\n", execSqlQueryTabular); verify(connectionMock, Mockito.times(1)).setReadOnly(true); verify(statementMock, Mockito.times(1)).setQueryTimeout(QUYERY_TIMEOUT); verify(statementMock, Mockito.times(1)).executeQuery(SQL_COMMAND); verify(resultSetMock, Mockito.times(1)).close(); }
public static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)){ connection.setReadOnly(true); final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToTable = Format.resultSetToTable(resultSet, sqlInputs.isNetcool()); resultSet.close(); return resultSetToTable; } }
SQLQueryTabularService { public static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)){ connection.setReadOnly(true); final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToTable = Format.resultSetToTable(resultSet, sqlInputs.isNetcool()); resultSet.close(); return resultSetToTable; } } }
SQLQueryTabularService { public static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)){ connection.setReadOnly(true); final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToTable = Format.resultSetToTable(resultSet, sqlInputs.isNetcool()); resultSet.close(); return resultSetToTable; } }  }
SQLQueryTabularService { public static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)){ connection.setReadOnly(true); final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToTable = Format.resultSetToTable(resultSet, sqlInputs.isNetcool()); resultSet.close(); return resultSetToTable; } }  static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs); }
SQLQueryTabularService { public static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs) throws Exception { ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)){ connection.setReadOnly(true); final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand()); final String resultSetToTable = Format.resultSetToTable(resultSet, sqlInputs.isNetcool()); resultSet.close(); return resultSetToTable; } }  static String execSqlQueryTabular(@NotNull final SQLInputs sqlInputs);  }