Skip to content

Commit

Permalink
Merge pull request #39 from StephG38/master
Browse files Browse the repository at this point in the history
Providing way to disable prepared statement cache
  • Loading branch information
krummas committed Oct 17, 2015
2 parents 055a5cb + ba5b2fc commit d3d7040
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -35,6 +35,7 @@ Current supported options are;
* `connectTimeout=X` - have an X second connection timeout.
* `createDB=true` - create the given database if it does not exist when connecting.
* `enableBlobStreaming=true` - experimental support for PBMS blob streaming.
* `noPrepStmtCache=true` - Disable prepared statement cache.


Building and testing
Expand Down
Expand Up @@ -92,7 +92,7 @@ public DrizzlePreparedStatement(final Protocol protocol,
if(log.isLoggable(Level.FINEST)) {
log.finest("Creating prepared statement for " + query);
}
dQuery = queryFactory.createParameterizedQuery(query);
dQuery = queryFactory.createParameterizedQuery(query, protocol.noPrepStmtCache());
this.parameterizedBatchHandler = parameterizedBatchHandler;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/drizzle/jdbc/internal/common/Protocol.java
Expand Up @@ -230,4 +230,6 @@ public interface Protocol {
* @see #setCatalog
*/
public String getCatalog() throws QueryException;

public boolean noPrepStmtCache();
}
Expand Up @@ -39,9 +39,13 @@ public DrizzleQuery createQuery(byte[] query)
{
return new DrizzleQuery(query);
}
public ParameterizedQuery createParameterizedQuery(final String query) {
public ParameterizedQuery createParameterizedQuery(final String query, boolean noCache) {

if(noCache)
return new DrizzleParameterizedQuery(new DrizzleParameterizedQuery(query));

// Cache prepared statements
ParameterizedQuery pq = DrizzleQueryFactory.PREPARED_CACHE.get(query);


if(pq == null) {
pq = new DrizzleParameterizedQuery(query);
Expand Down
Expand Up @@ -31,7 +31,7 @@ public interface QueryFactory {
Query createQuery(String query);
Query createQuery(byte[] query);

ParameterizedQuery createParameterizedQuery(String query);
ParameterizedQuery createParameterizedQuery(String query, boolean noCache);

ParameterizedQuery createParameterizedQuery(ParameterizedQuery dQuery);
}
Expand Up @@ -641,6 +641,10 @@ public boolean createDB() {
&& info.getProperty("createDB", "").equalsIgnoreCase("true");
}

public boolean noPrepStmtCache() {
return info != null
&& info.getProperty("noPrepStmtCache", "").equalsIgnoreCase("true");
}

/**
* Send the given file to the server starting with packet number packIndex
Expand Down

0 comments on commit d3d7040

Please sign in to comment.