@@ -, +, @@ the current jdbc pool implementation and newer jdbc drivers should support pooling themselves. --- bin/jmeter.properties | 5 +- .../protocol/jdbc/AbstractJDBCTestElement.java | 70 ++-------------------- xdocs/usermanual/properties_reference.xml | 1 - 3 files changed, 6 insertions(+), 70 deletions(-) --- a/bin/jmeter.properties +++ a/bin/jmeter.properties @@ -821,9 +821,6 @@ wmlParser.types=text/vnd.wap.wml # JDBC Request configuration #--------------------------------------------------------------------------- -# Max number of PreparedStatements per Connection for PreparedStatement cache -#jdbcsampler.maxopenpreparedstatements=100 - # String used to indicate a null value #jdbcsampler.nullmarker=]NULL[ @@ -1245,4 +1242,4 @@ system.properties=system.properties # Force throuput controllers that work in percentage mode to be a 100% # Disabled by default -#testplan_validation.tpc_force_100_pct=false +#testplan_validation.tpc_force_100_pct=false --- a/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java +++ a/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java @@ -36,13 +36,10 @@ import java.sql.Timestamp; import java.sql.Types; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.collections.map.LRUMap; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.save.CSVSaveService; import org.apache.jmeter.testelement.AbstractTestElement; @@ -69,9 +66,6 @@ public abstract class AbstractJDBCTestElement extends AbstractTestElement implem // String used to indicate a null value private static final String NULL_MARKER = JMeterUtils.getPropDefault("jdbcsampler.nullmarker","]NULL["); // $NON-NLS-1$ - - private static final int MAX_OPEN_PREPARED_STATEMENTS = - JMeterUtils.getPropDefault("jdbcsampler.maxopenpreparedstatements", 100); private static final String INOUT = "INOUT"; // $NON-NLS-1$ @@ -131,14 +125,6 @@ public abstract class AbstractJDBCTestElement extends AbstractTestElement implem private String queryTimeout = ""; // $NON-NLS-1$ /** - * Cache of PreparedStatements stored in a per-connection basis. Each entry of this - * cache is another Map mapping the statement string to the actual PreparedStatement. - * At one time a Connection is only held by one thread - */ - private static final Map> perConnCache = - new ConcurrentHashMap<>(); - - /** * Creates a JDBCSampler. */ protected AbstractJDBCTestElement() { @@ -446,50 +432,16 @@ public abstract class AbstractJDBCTestElement extends AbstractTestElement implem } private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws SQLException { - Map preparedStatementMap = perConnCache.get(conn); - if (null == preparedStatementMap ) { - @SuppressWarnings("unchecked") // LRUMap is not generic - Map lruMap = new LRUMap(MAX_OPEN_PREPARED_STATEMENTS) { - private static final long serialVersionUID = 1L; - @Override - protected boolean removeLRU(LinkEntry entry) { - PreparedStatement preparedStatement = (PreparedStatement)entry.getValue(); - close(preparedStatement); - return true; - } - }; - preparedStatementMap = Collections.synchronizedMap(lruMap); - // As a connection is held by only one thread, we cannot already have a - // preparedStatementMap put by another thread - perConnCache.put(conn, preparedStatementMap); - } - PreparedStatement pstmt = preparedStatementMap.get(getQuery()); - if (null == pstmt) { - if (callable) { - pstmt = conn.prepareCall(getQuery()); - } else { - pstmt = conn.prepareStatement(getQuery()); - } - pstmt.setQueryTimeout(getIntegerQueryTimeout()); - // PreparedStatementMap is associated to one connection so - // 2 threads cannot use the same PreparedStatement map at the same time - preparedStatementMap.put(getQuery(), pstmt); + PreparedStatement pstmt; + if (callable) { + pstmt = conn.prepareCall(getQuery()); } else { - int timeoutInS = getIntegerQueryTimeout(); - if(pstmt.getQueryTimeout() != timeoutInS) { - pstmt.setQueryTimeout(getIntegerQueryTimeout()); - } + pstmt = conn.prepareStatement(getQuery()); } - pstmt.clearParameters(); + pstmt.setQueryTimeout(getIntegerQueryTimeout()); return pstmt; } - private static void closeAllStatements(Collection collection) { - for (PreparedStatement pstmt : collection) { - close(pstmt); - } - } - /** * Gets a Data object from a ResultSet. * @@ -759,7 +711,6 @@ public abstract class AbstractJDBCTestElement extends AbstractTestElement implem */ @Override public void testStarted(String host) { - cleanCache(); } /** @@ -777,17 +728,6 @@ public abstract class AbstractJDBCTestElement extends AbstractTestElement implem */ @Override public void testEnded(String host) { - cleanCache(); - } - - /** - * Clean cache of PreparedStatements - */ - private static void cleanCache() { - for (Map element : perConnCache.values()) { - closeAllStatements(element.values()); - } - perConnCache.clear(); } } --- a/xdocs/usermanual/properties_reference.xml +++ a/xdocs/usermanual/properties_reference.xml @@ -487,7 +487,6 @@ Other parsers:
- Max number of PreparedStatements per Connection for PreparedStatement cache
, defaults to:100
String used to indicate a null value
, defaults to:]NULL[
--