sebb 2005/06/04 09:55:12
Modified: src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler JDBCSampler.java Log: Tidy error handling, and show error text in response message Revision Changes Path 1.35 +14 -38 jakarta-jmeter/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java Index: JDBCSampler.java =================================================================== RCS file: /home/cvs/jakarta-jmeter/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- JDBCSampler.java 20 May 2005 00:21:31 -0000 1.34 +++ JDBCSampler.java 4 Jun 2005 16:55:11 -0000 1.35 @@ -73,7 +73,8 @@ try { - if (pool == null) throw new Exception("No pool created"); + if (pool == null) throw new SQLException("No pool created"); + // TODO: Consider creating a sub-result with the time to get the // connection. conn = pool.getConnection(); @@ -93,14 +94,8 @@ { if (rs != null) { - try - { - rs.close(); - } - catch (SQLException exc) - { - log.warn("Error closing ResultSet", exc); - } + try { rs.close(); } + catch (SQLException exc) {log.warn("Error closing ResultSet", exc);} } } } @@ -115,40 +110,21 @@ res.setDataType(SampleResult.TEXT); res.setSuccessful(true); } - catch (Exception ex) + catch (SQLException ex) { log.error("Error in JDBC sampling", ex); - res.setResponseData(ex.toString().getBytes()); + res.setResponseMessage(ex.toString()); res.setSuccessful(false); } finally { - if (stmt != null) - { - try - { - stmt.close(); - } - catch (SQLException err) - { - log.error("Error in JDBC sampling", err); - res.setResponseData(err.toString().getBytes()); - res.setSuccessful(false); - } + if (stmt != null) { + try { stmt.close(); } + catch (SQLException ex) { log.warn("Error closing statement", ex); } } - - if (conn != null) - { - try - { - conn.close(); - } - catch (SQLException e1) - { - log.error("Error in JDBC sampling", e1); - res.setResponseData(e1.toString().getBytes()); - res.setSuccessful(false); - } + if (conn != null) { + try { conn.close(); } + catch (SQLException ex) { log.warn("Error closing connection", ex); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
Free forum by Nabble | Edit this page |