ASF Bugzilla – Attachment 17982 Details for
Bug 38682
JDBC Sampler does not support prepareCall
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
JDBCSampler Patch for handling Calling Procedures
JDBCSampler.java.patch (text/plain), 2.77 KB, created by
Ronald Bradford
on 2006-03-26 12:36:12 UTC
(
hide
)
Description:
JDBCSampler Patch for handling Calling Procedures
Filename:
MIME Type:
Creator:
Ronald Bradford
Created:
2006-03-26 12:36:12 UTC
Size:
2.77 KB
patch
obsolete
>Index: JDBCSampler.java >=================================================================== >--- JDBCSampler.java (revision 388876) >+++ JDBCSampler.java (working copy) >@@ -23,6 +23,7 @@ > import java.sql.ResultSetMetaData; > import java.sql.SQLException; > import java.sql.Statement; >+import java.sql.CallableStatement; > > import org.apache.avalon.excalibur.datasource.DataSourceComponent; > import org.apache.jmeter.samplers.Entry; >@@ -45,6 +46,8 @@ > > public static final String QUERY = "query"; > public static final String SELECT = "Select Statement"; >+ public static final String UPDATE = "Update Statement"; >+ public static final String STATEMENT = "Call Statement"; > > public String query = ""; > >@@ -69,6 +72,7 @@ > log.debug("DataSourceComponent: " + pool); > Connection conn = null; > Statement stmt = null; >+ CallableStatement cs = null; > > try { > >@@ -88,14 +92,19 @@ > Data data = getDataFromResultSet(rs); > res.setResponseData(data.toString().getBytes()); > } finally { >- if (rs != null) { >- try { >- rs.close(); >- } catch (SQLException exc) { >- log.warn("Error closing ResultSet", exc); >- } >- } >+ close(rs); > } >+ // execute stored procedure >+ } else if (STATEMENT.equals(getQueryType())) { >+ try { >+ cs = conn.prepareCall(getQuery()); >+ cs.execute(); >+ String results = "Executed"; >+ res.setResponseData(results.getBytes()); >+ } finally { >+ close(cs); >+ } >+ // Insert/Update/Delete statement > } else { > stmt.execute(getQuery()); > int updateCount = stmt.getUpdateCount(); >@@ -112,20 +121,8 @@ > res.setResponseMessage(ex.toString()); > res.setSuccessful(false); > } finally { >- if (stmt != null) { >- try { >- stmt.close(); >- } catch (SQLException ex) { >- log.warn("Error closing statement", ex); >- } >- } >- if (conn != null) { >- try { >- conn.close(); >- } catch (SQLException ex) { >- log.warn("Error closing connection", ex); >- } >- } >+ close(stmt); >+ close(conn); > } > > res.sampleEnd(); >@@ -164,6 +161,38 @@ > return data; > } > >+ public static void close(Connection c) { >+ try { >+ if (c != null) c.close(); >+ } catch (SQLException e) { >+ log.warn("Error closing Connection", e); >+ } >+ } >+ >+ public static void close(Statement s) { >+ try { >+ if (s != null) s.close(); >+ } catch (SQLException e) { >+ log.warn("Error closing Statement", e); >+ } >+ } >+ >+ public static void close(CallableStatement cs) { >+ try { >+ if (cs != null) cs.close(); >+ } catch (SQLException e) { >+ log.warn("Error closing CallableStatement", e); >+ } >+ } >+ >+ public static void close(ResultSet rs) { >+ try { >+ if (rs != null) rs.close(); >+ } catch (SQLException e) { >+ log.warn("Error closing ResultSet", e); >+ } >+ } >+ > public String getQuery() { > return query; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 38682
: 17982 |
17983