List of usage examples for java.sql SQLException toString
public String toString()
From source file:dbProcs.Getter.java
/** * This method is used to determine if a CSRF level has been completed. * A call is made to the DB that returns the CSRF counter for a level. * If this counter is greater than 0, the level has been completed * @param applicationRoot Running context of the application * @param moduleHash Hash ID of the CSRF module you wish to check if a user has completed * @param userId the ID of the user to check * @return True or False value depicting if the user has completed the module *//*from w ww . j a va2s . c o m*/ public static boolean isCsrfLevelComplete(String applicationRoot, String moduleId, String userId) { log.debug("*** Setter.isCsrfLevelComplete ***"); boolean result = false; Connection conn = Database.getCoreConnection(applicationRoot); try { log.debug("Preparing csrfLevelComplete call"); CallableStatement callstmnt = conn.prepareCall("call csrfLevelComplete(?, ?)"); callstmnt.setString(1, moduleId); callstmnt.setString(2, userId); log.debug("moduleId: " + moduleId); log.debug("userId: " + userId); log.debug("Executing csrfLevelComplete"); ResultSet resultSet = callstmnt.executeQuery(); resultSet.next(); result = resultSet.getInt(1) > 0; // If Result is > 0, then the CSRF level is complete if (result) log.debug("CSRF Level is complete"); } catch (SQLException e) { log.error("csrfLevelComplete Failure: " + e.toString()); result = false; } Database.closeConnection(conn); log.debug("*** END isCsrfLevelComplete ***"); return result; }
From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
@Test public void ChainedCursorFunctionTest() { this.logger.info("ChainedFunctionTest"); try {//from w w w . j ava 2 s . co m BQScrollableResultSetFunctionTest.Result.beforeFirst(); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(10)); Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } try { Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.first()); Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.isFirst()); Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.previous()); BQScrollableResultSetFunctionTest.Result.afterLast(); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.isAfterLast()); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(-1)); Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.relative(-5)); Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.relative(6)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } this.logger.info("chainedfunctiontest end"); }
From source file:dbProcs.Getter.java
/** * This method retrieves the i18n local key for a module's name. * @param applicationRoot Application Running Context * @param moduleId ID of the module to lookup * @return Locale key for the Module's Name. *///from w ww. ja v a2s . c o m public static String getModuleNameLocaleKey(String applicationRoot, String moduleId) { log.debug("*** Getter.getModuleNameLocaleKey ***"); String result = new String(); Connection conn = Database.getCoreConnection(applicationRoot); try { CallableStatement callstmt = conn.prepareCall("call moduleGetNameLocale(?)"); log.debug("Gathering moduleGetNameLocale ResultSet"); callstmt.setString(1, moduleId); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from moduleGetNameLocale"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute moduleGetNameLocale: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getModuleNameLocaleKey ***"); return result; }
From source file:dbProcs.Getter.java
/** * Used to present the progress of a class in a series of loading bars * @param applicationRoot The current running context of the application * @param classId The identifier of the class to use in lookup * @return A HTML representation of a class's progress in the application *//*from ww w .j av a2 s. c o m*/ public static String getProgress(String applicationRoot, String classId) { log.debug("*** Getter.getProgress ***"); String result = new String(); Encoder encoder = ESAPI.encoder(); Connection conn = Database.getCoreConnection(applicationRoot); try { log.debug("Preparing userProgress call"); CallableStatement callstmnt = conn.prepareCall("call userProgress(?)"); callstmnt.setString(1, classId); log.debug("Executing userProgress"); ResultSet resultSet = callstmnt.executeQuery(); int resultAmount = 0; while (resultSet.next()) //For each user in a class { resultAmount++; if (resultSet.getString(1) != null) { result += "<tr><td>" + encoder.encodeForHTML(resultSet.getString(1)) + //Output their progress "</td><td><div style='background-color: #A878EF; heigth: 25px; width: " + widthOfUnitBar * resultSet.getInt(2) + "px;'>" + "<font color='white'><strong>" + resultSet.getInt(2); if (resultSet.getInt(2) > 6) result += " Modules"; result += "</strong></font></div></td></tr>"; } } if (resultAmount > 0) result = "<table><tr><th>Player</th><th>Progress</th></tr>" + result + "</table>"; else result = new String(); } catch (SQLException e) { log.error("getProgress Failure: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getProgress ***"); return result; }
From source file:org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.java
public SampleResult sample(Entry e) { log.debug("sampling jdbc"); SampleResult res = new SampleResult(); res.setSampleLabel(getName());//from w w w . jav a 2s . c om res.setSamplerData(toString()); res.setDataType(SampleResult.TEXT); res.setContentType("text/plain"); // $NON-NLS-1$ res.setDataEncoding(ENCODING); // Assume we will be successful res.setSuccessful(true); res.setResponseMessageOK(); res.setResponseCodeOK(); res.sampleStart(); Connection conn = null; Statement stmt = null; try { try { conn = DataSourceElement.getConnection(getDataSource()); } finally { res.latencyEnd(); // use latency to measure connection time } res.setResponseHeaders(conn.toString()); // Based on query return value, get results String _queryType = getQueryType(); if (SELECT.equals(_queryType)) { stmt = conn.createStatement(); ResultSet rs = null; try { rs = stmt.executeQuery(getQuery()); res.setResponseData(getStringFromResultSet(rs).getBytes(ENCODING)); } finally { close(rs); } } else if (CALLABLE.equals(_queryType)) { CallableStatement cstmt = getCallableStatement(conn); int out[] = setArguments(cstmt); // A CallableStatement can return more than 1 ResultSets // plus a number of update counts. boolean hasResultSet = cstmt.execute(); String sb = resultSetsToString(cstmt, hasResultSet, out); res.setResponseData(sb.getBytes(ENCODING)); } else if (UPDATE.equals(_queryType)) { stmt = conn.createStatement(); stmt.executeUpdate(getQuery()); int updateCount = stmt.getUpdateCount(); String results = updateCount + " updates"; res.setResponseData(results.getBytes(ENCODING)); } else if (PREPARED_SELECT.equals(_queryType)) { PreparedStatement pstmt = getPreparedStatement(conn); setArguments(pstmt); pstmt.executeQuery(); String sb = resultSetsToString(pstmt, true, null); res.setResponseData(sb.getBytes(ENCODING)); } else if (PREPARED_UPDATE.equals(_queryType)) { PreparedStatement pstmt = getPreparedStatement(conn); setArguments(pstmt); pstmt.executeUpdate(); String sb = resultSetsToString(pstmt, false, null); res.setResponseData(sb.getBytes(ENCODING)); } else if (ROLLBACK.equals(_queryType)) { conn.rollback(); res.setResponseData(ROLLBACK.getBytes(ENCODING)); } else if (COMMIT.equals(_queryType)) { conn.commit(); res.setResponseData(COMMIT.getBytes(ENCODING)); } else if (AUTOCOMMIT_FALSE.equals(_queryType)) { conn.setAutoCommit(false); res.setResponseData(AUTOCOMMIT_FALSE.getBytes(ENCODING)); } else if (AUTOCOMMIT_TRUE.equals(_queryType)) { conn.setAutoCommit(true); res.setResponseData(AUTOCOMMIT_TRUE.getBytes(ENCODING)); } else { // User provided incorrect query type String results = "Unexpected query type: " + _queryType; res.setResponseMessage(results); res.setSuccessful(false); } } catch (SQLException ex) { final String errCode = Integer.toString(ex.getErrorCode()); res.setResponseMessage(ex.toString()); res.setResponseCode(ex.getSQLState() + " " + errCode); res.setSuccessful(false); } catch (UnsupportedEncodingException ex) { res.setResponseMessage(ex.toString()); res.setResponseCode("000"); // TODO - is this correct? res.setSuccessful(false); } catch (IOException ex) { res.setResponseMessage(ex.toString()); res.setResponseCode("000"); // TODO - is this correct? res.setSuccessful(false); } finally { close(stmt); close(conn); } // TODO: process warnings? Set Code and Message to success? res.sampleEnd(); return res; }
From source file:controlador.Peticiones.java
private void agregarProducto(int idmesa, int idProducto) { String usuario = "admin"; pedido = 0;/*from ww w. j av a 2s .co m*/ estado = 1; String consulta = ""; String fechaHora = getFecha(); consulta = "SELECT * FROM caja WHERE estadoCaja=0"; r = bd.ejecutarSelect(consulta); try { if (!r.next()) { consulta = "insert into caja (fechaApertura, cantidadApertura, cantidadCierre, estadoCaja) values ('" + fechaHora + "', 0, 0, 0)"; bd.ejecutarInsert(consulta); } } catch (SQLException ex) { } r = bd.ejecutarSelect("select * from pedidos where mesas_idmesa=" + idmesa + " order by fechapedido desc"); try { if (r.next()) { pedido = r.getInt("idpedido"); estado = r.getInt("estadopedido"); ; } } catch (SQLException ex) { System.out.println(ex.toString()); } if (pedido == 0 || estado == 1) { fechaHora = getFecha(); consulta = "insert into pedidos values(0, '" + fechaHora + "', 0, 0, 1, '" + usuario + "', " + idmesa + ", 1, 0)"; bd.ejecutarInsert(consulta); primerInsert(idmesa); } int producto = idProducto; consulta = "SELECT count(*) as lineas " + "FROM lineapedidos " + "WHERE pedidos_idpedido=" + pedido + " and productos_idproducto=" + producto; r = bd.ejecutarSelect(consulta); try { r.next(); if (r.getInt("lineas") == 0) { consulta = "insert into lineapedidos values(0,1,1,0," + pedido + "," + producto + ")"; bd.ejecutarInsert(consulta); } else { ResultSet cantidad = bd.ejecutarSelect("SELECT cantidadlinea " + "FROM lineapedidos " + "WHERE pedidos_idpedido=" + pedido + " and productos_idproducto=" + producto); cantidad.next(); consulta = "update lineapedidos set cantidadlinea=" + (1 + cantidad.getInt("cantidadlinea")) + " where pedidos_idpedido=" + pedido + " and productos_idproducto=" + producto; bd.ejecutarUpdate(consulta); } } catch (SQLException ex) { } }
From source file:dbProcs.Getter.java
/** * Use to return the current progress of a class in JSON format with information like user name, score and completed modules * @param applicationRoot The current running context of the application * @param classId The identifier of the class to use in lookup * @return A JSON representation of a class's progress in the application *//* w w w. jav a 2 s . c o m*/ @SuppressWarnings("unchecked") public static String getProgressJSON(String applicationRoot, String classId) { log.debug("*** Getter.getProgressJSON ***"); String result = new String(); Encoder encoder = ESAPI.encoder(); Connection conn = Database.getCoreConnection(applicationRoot); try { log.debug("Preparing userProgress call"); //Returns User's: Name, # of Completed modules and Score CallableStatement callstmnt = conn.prepareCall("call userProgress(?)"); callstmnt.setString(1, classId); log.debug("Executing userProgress"); ResultSet resultSet = callstmnt.executeQuery(); JSONArray json = new JSONArray(); JSONObject jsonInner = new JSONObject(); int resultAmount = 0; while (resultSet.next()) //For each user in a class { resultAmount++; jsonInner = new JSONObject(); if (resultSet.getString(1) != null) { jsonInner.put("userName", new String(encoder.encodeForHTML(resultSet.getString(1)))); //User Name jsonInner.put("progressBar", new Integer(resultSet.getInt(2) * widthOfUnitBar)); //Progress Bar Width jsonInner.put("score", new Integer(resultSet.getInt(3))); //Score log.debug("Adding: " + jsonInner.toString()); json.add(jsonInner); } } if (resultAmount > 0) result = json.toString(); else result = new String(); } catch (SQLException e) { log.error("getProgressJSON Failure: " + e.toString()); result = null; } catch (Exception e) { log.error("getProgressJSON Unexpected Failure: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getProgressJSON ***"); return result; }
From source file:com.streamsets.pipeline.stage.origin.jdbc.JdbcSource.java
@Override public String produce(String lastSourceOffset, int maxBatchSize, BatchMaker batchMaker) throws StageException { int batchSize = Math.min(this.commonSourceConfigBean.maxBatchSize, maxBatchSize); String nextSourceOffset = lastSourceOffset == null ? initialOffset : lastSourceOffset; long now = System.currentTimeMillis(); long delay = Math.max(0, (lastQueryCompletedTime + queryIntervalMillis) - now); if (delay > 0) { // Sleep in one second increments so we don't tie up the app. LOG.debug("{}ms remaining until next fetch.", delay); ThreadUtil.sleep(Math.min(delay, 1000)); } else {/*from w w w . j a v a 2 s . com*/ Statement statement = null; Hasher hasher = HF.newHasher(); try { if (null == resultSet || resultSet.isClosed()) { // The result set got closed outside of us, so we also clean up the connection (if any) closeQuietly(connection); connection = dataSource.getConnection(); if (!txnColumnName.isEmpty()) { // CDC requires scrollable cursors. statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } else { statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } int fetchSize = batchSize; // MySQL does not support cursors or fetch size except 0 and "streaming" (1 at a time). if (hikariConfigBean.getConnectionString().toLowerCase().contains("mysql")) { // Enable MySQL streaming mode. fetchSize = Integer.MIN_VALUE; } LOG.debug("Using query fetch size: {}", fetchSize); statement.setFetchSize(fetchSize); if (getContext().isPreview()) { statement.setMaxRows(batchSize); } preparedQuery = prepareQuery(query, lastSourceOffset); LOG.trace("Executing query: " + preparedQuery); hashedQuery = hasher.putString(preparedQuery, Charsets.UTF_8).hash().toString(); LOG.debug("Executing query: " + hashedQuery); resultSet = statement.executeQuery(preparedQuery); queryRowCount = 0; numQueryErrors = 0; firstQueryException = null; } // Read Data and track last offset int rowCount = 0; String lastTransactionId = ""; boolean haveNext = true; while (continueReading(rowCount, batchSize) && (haveNext = resultSet.next())) { final Record record = processRow(resultSet, rowCount); if (null != record) { if (!txnColumnName.isEmpty()) { String newTransactionId = resultSet.getString(txnColumnName); if (lastTransactionId.isEmpty()) { lastTransactionId = newTransactionId; batchMaker.addRecord(record); } else if (lastTransactionId.equals(newTransactionId)) { batchMaker.addRecord(record); } else { // The Transaction ID Column Name config should not be used with MySQL as it // does not provide a change log table and the JDBC driver may not support scrollable cursors. resultSet.relative(-1); break; // Complete this batch without including the new record. } } else { batchMaker.addRecord(record); } } // Get the offset column value for this record if (isIncrementalMode) { nextSourceOffset = resultSet.getString(offsetColumn); } else { nextSourceOffset = initialOffset; } ++rowCount; ++queryRowCount; ++noMoreDataRecordCount; shouldFire = true; } LOG.debug("Processed rows: " + rowCount); if (!haveNext || rowCount == 0) { // We didn't have any data left in the cursor. Close everything // We may not have the statement here if we're not producing the // same batch as when we got it, so get it from the result set // Get it before we close the result set, just to be safe! statement = resultSet.getStatement(); closeQuietly(resultSet); closeQuietly(statement); closeQuietly(connection); lastQueryCompletedTime = System.currentTimeMillis(); LOG.debug("Query completed at: {}", lastQueryCompletedTime); QUERY_SUCCESS.create(getContext()).with(QUERY, preparedQuery) .with(TIMESTAMP, lastQueryCompletedTime).with(ROW_COUNT, queryRowCount) .with(SOURCE_OFFSET, nextSourceOffset).createAndSend(); // In case of non-incremental mode, we need to generate no-more-data event as soon as we hit end of the // result set. Incremental mode will try to run the query again and generate the event if and only if // the next query results in zero rows. if (!isIncrementalMode) { generateNoMoreDataEvent(); } } /* * We want to generate no-more data event on next batch if: * 1) We run a query in this batch and returned empty. * 2) We consumed at least some data since last time (to not generate the event all the time) */ if (isIncrementalMode && rowCount == 0 && !haveNext && shouldFire && !firstTime) { generateNoMoreDataEvent(); shouldFire = false; } firstTime = false; } catch (SQLException e) { if (++numQueryErrors == 1) { firstQueryException = e; } String formattedError = jdbcUtil.formatSqlException(e); LOG.error(formattedError, e); if (resultSet != null) { try { statement = resultSet.getStatement(); } catch (SQLException e1) { LOG.debug("Error while getting statement from result set: {}", e1.toString(), e1); } closeQuietly(resultSet); closeQuietly(statement); } closeQuietly(connection); lastQueryCompletedTime = System.currentTimeMillis(); QUERY_FAILURE.create(getContext()).with(QUERY, preparedQuery) .with(TIMESTAMP, lastQueryCompletedTime).with(ERROR, formattedError) .with(ROW_COUNT, queryRowCount).with(SOURCE_OFFSET, nextSourceOffset).createAndSend(); LOG.debug("Query '{}' failed at: {}; {} errors so far", preparedQuery, lastQueryCompletedTime, numQueryErrors); if (numQueryErrors > commonSourceConfigBean.numSQLErrorRetries) { throw new StageException(JdbcErrors.JDBC_77, e.getClass().getSimpleName(), preparedQuery, numQueryErrors, jdbcUtil.formatSqlException(firstQueryException)); } // else allow nextSourceOffset to be returned, to retry } } return nextSourceOffset; }
From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java
@Test public void ChainedCursorFunctionTest() { this.logger.info("ChainedFunctionTest"); try {//from www .j a v a 2s . com BQResultSetFunctionTest.Result.beforeFirst(); Assert.assertTrue(BQResultSetFunctionTest.Result.next()); Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(10)); Assert.assertEquals("word", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQResultSetFunctionTest.Result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } try { Assert.assertTrue(BQResultSetFunctionTest.Result.first()); Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQResultSetFunctionTest.Result.isFirst()); Assert.assertFalse(BQResultSetFunctionTest.Result.previous()); BQResultSetFunctionTest.Result.afterLast(); Assert.assertTrue(BQResultSetFunctionTest.Result.isAfterLast()); Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(-1)); Assert.assertEquals("word", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertTrue(BQResultSetFunctionTest.Result.relative(-5)); Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertFalse(BQResultSetFunctionTest.Result.relative(6)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } this.logger.info("chainedfunctiontest end"); }
From source file:dbProcs.Getter.java
/** * The CSRF forum is used in CSRF levels for users to deliver CSRF attacks against each other. URLs are contained in IFRAME tags * @param ApplicationRoot The current running context of the application * @param classId Identifier of the class to populate the forum with * @param moduleId The module in which to return the forum for * @param bundle Strings Package for the Language Local of the user making the request * @return A HTML table of a Class's CSRF Submissions for a specific module *//*from ww w .j a v a 2 s. c o m*/ public static String getCsrfForumWithIframe(String ApplicationRoot, String classId, String moduleId, ResourceBundle bundle) { log.debug("*** Getter.getCsrfForum ***"); log.debug("Getting stored messages from class: " + classId); Encoder encoder = ESAPI.encoder(); String htmlOutput = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { if (classId != null) { CallableStatement callstmt = conn.prepareCall("call resultMessageByClass(?, ?)"); log.debug("Gathering resultMessageByClass ResultSet"); callstmt.setString(1, classId); callstmt.setString(2, moduleId); ResultSet resultSet = callstmt.executeQuery(); log.debug("resultMessageByClass executed"); //Table Header htmlOutput = "<table><tr><th>" + bundle.getString("forum.userName") + "</th><th>" + bundle.getString("forum.message") + "</th></tr>"; log.debug("Opening Result Set from resultMessageByClass"); int counter = 0; while (resultSet.next()) { counter++; //Table content htmlOutput += "<tr><td>" + encoder.encodeForHTML(resultSet.getString(1)) + "</td><td><iframe sandbox=\"allow-scripts allow-forms\" src=\"" + encoder.encodeForHTMLAttribute(resultSet.getString(2)) + "\"></iframe></td></tr>"; } if (counter > 0) log.debug("Added a " + counter + " row table"); else log.debug("No results from query"); //Table end htmlOutput += "</table>"; } else { log.error("User with Null Class detected"); htmlOutput = "<p><font color='red'>" + bundle.getString("error.noClass") + "</font></p>"; } } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); htmlOutput = "<p>" + bundle.getString("error.occurred ") + "</p>"; } catch (Exception e) { log.fatal("Could not return CSRF Forum: " + e.toString()); } Database.closeConnection(conn); log.debug("*** END getCsrfForum ***"); return htmlOutput; }