Skip to content

Commit f421d4c

Browse files
authored
Merge pull request #19 from Microsoft/dev
pull 6.4.0
2 parents c8cc20b + 9277451 commit f421d4c

12 files changed

+318
-282
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55

6+
## [6.4.0] Stable Release
7+
### Added
8+
- Support added for AAD Integrated Authentication with ADAL4J on Windows/Linux/Mac OS [#603](https://github.com/Microsoft/mssql-jdbc/pull/603)
9+
- Enable Recover after MSDTC is restarted [#581](https://github.com/Microsoft/mssql-jdbc/pull/581)
10+
- Added Version Update configuration rules to project [#541](https://github.com/Microsoft/mssql-jdbc/pull/541)
11+
- JDK 9 Compatibility + JDBC 4.3 API support added to the driver [#601 (https://github.com/Microsoft/mssql-jdbc/pull/601)
12+
13+
### Fixed Issues
14+
- Re-introduced Retry Logic for Prepared Statement Caching implementation and remove detect change context function [#618](https://github.com/Microsoft/mssql-jdbc/pull/618) and [#620](https://github.com/Microsoft/mssql-jdbc/pull/620)
15+
- Fixes for SonarQube Reported issues [#599](https://github.com/Microsoft/mssql-jdbc/pull/599)
16+
- Fixes for Random Assertion Errors [#597](https://github.com/Microsoft/mssql-jdbc/pull/597)
17+
18+
### Changed
19+
- Updated Appveyor to use JDK9 building driver and running tests [#619](https://github.com/Microsoft/mssql-jdbc/pull/619)
20+
- JDK 7 compilation support removed from the driver [#601](https://github.com/Microsoft/mssql-jdbc/pull/601)
21+
622
## [6.3.6] Preview Release
723
### Added
824
- Added support for using database name as part of the key for handle cache [#561](https://github.com/Microsoft/mssql-jdbc/pull/561)

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
8080
<dependency>
8181
<groupId>com.microsoft.sqlserver</groupId>
8282
<artifactId>mssql-jdbc</artifactId>
83-
<version>6.2.2.jre8</version>
83+
<version>6.4.0.jre9</version>
8484
</dependency>
8585
```
8686
The driver can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=852460).
@@ -120,14 +120,14 @@ Projects that require either of the two features need to explicitly declare the
120120
<dependency>
121121
<groupId>com.microsoft.sqlserver</groupId>
122122
<artifactId>mssql-jdbc</artifactId>
123-
<version>6.3.6.jre8-preview</version>
123+
<version>6.4.0.jre9</version>
124124
<scope>compile</scope>
125125
</dependency>
126126

127127
<dependency>
128128
<groupId>com.microsoft.azure</groupId>
129129
<artifactId>adal4j</artifactId>
130-
<version>1.3.0</version>
130+
<version>1.4.0</version>
131131
</dependency>
132132
```
133133

@@ -136,14 +136,14 @@ Projects that require either of the two features need to explicitly declare the
136136
<dependency>
137137
<groupId>com.microsoft.sqlserver</groupId>
138138
<artifactId>mssql-jdbc</artifactId>
139-
<version>6.3.6.jre8-preview</version>
139+
<version>6.4.0.jre9</version>
140140
<scope>compile</scope>
141141
</dependency>
142142

143143
<dependency>
144144
<groupId>com.microsoft.azure</groupId>
145145
<artifactId>adal4j</artifactId>
146-
<version>1.3.0</version>
146+
<version>1.4.0</version>
147147
</dependency>
148148

149149
<dependency>
@@ -160,7 +160,7 @@ We love contributions from the community. To help improve the quality of our co
160160
Thank you!
161161

162162
## Guidelines for Reporting Issues
163-
We appreciate you taking the time to test the driver, provide feedback and report any issues. It would be extremely helpful if you:
163+
We appreciate you taking the time to test the driver, provide feedback and report any issues. It would be extremely helpful if you:
164164

165165
- Report each issue as a new issue (but check first if it's already been reported)
166166
- Try to be detailed in your report. Useful information for good bug reports include:

appveyor.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ init:
44
- cmd: net start MSSQL$%SQL_Instance%
55

66
environment:
7-
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
7+
JAVA_HOME: C:\Program Files\Java\jdk9
88
mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=%SQL_Instance%;databaseName=master;username=sa;password=Password12!;
99

1010
matrix:
@@ -32,9 +32,9 @@ build_script:
3232
- keytool -importkeystore -srckeystore cert.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS -srcstorepass password -deststorepass password
3333
- keytool -list -v -keystore clientcert.jks -storepass "password" > JavaKeyStore.txt
3434
- cd..
35-
# - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41
36-
# - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42
35+
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild43
36+
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42
3737

38-
#test_script:
39-
# - mvn test -B -Pbuild41
40-
# - mvn test -B -Pbuild42
38+
test_script:
39+
- mvn test -B -Pbuild43
40+
- mvn test -B -Pbuild42

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.microsoft.sqlserver</groupId>
77
<artifactId>mssql-jdbc</artifactId>
8-
<version>6.4.0-SNAPSHOT.${jreVersion}</version>
8+
<version>6.4.0.${jreVersion}</version>
99
<packaging>jar</packaging>
1010

1111
<name>Microsoft JDBC Driver for SQL Server</name>

src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class SQLJdbcVersion {
1212
static final int major = 6;
13-
static final int minor = 3;
14-
static final int patch = 6;
13+
static final int minor = 4;
14+
static final int patch = 0;
1515
static final int build = 0;
1616
}

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

+60-39
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383

8484
// Note all the public functions in this class also need to be defined in SQLServerConnectionPoolProxy.
8585
public class SQLServerConnection implements ISQLServerConnection {
86-
boolean contextIsAlreadyChanged = false;
87-
boolean contextChanged = false;
8886

8987
long timerExpire;
9088
boolean attemptRefreshTokenLocked = false;
@@ -276,15 +274,20 @@ static ParsedSQLCacheItem parseAndCacheSQL(Sha1HashKey key, String sql) throws
276274
return cacheItem;
277275
}
278276

277+
/** Default size for prepared statement caches */
278+
static final int DEFAULT_STATEMENT_POOLING_CACHE_SIZE = 0;
279+
279280
/** Size of the prepared statement handle cache */
280-
private int statementPoolingCacheSize = 10;
281+
private int statementPoolingCacheSize = DEFAULT_STATEMENT_POOLING_CACHE_SIZE;
281282

282-
/** Default size for prepared statement caches */
283-
static final int DEFAULT_STATEMENT_POOLING_CACHE_SIZE = 10;
284283
/** Cache of prepared statement handles */
285284
private ConcurrentLinkedHashMap<Sha1HashKey, PreparedStatementHandle> preparedStatementHandleCache;
286285
/** Cache of prepared statement parameter metadata */
287286
private ConcurrentLinkedHashMap<Sha1HashKey, SQLServerParameterMetaData> parameterMetadataCache;
287+
/**
288+
* Checks whether statement pooling is enabled or disabled. The default is set to true;
289+
*/
290+
private boolean disableStatementPooling = true;
288291

289292
/**
290293
* Find statement parameters.
@@ -925,17 +928,10 @@ final boolean attachConnId() {
925928
connectionlogger.severe(message);
926929
throw new UnsupportedOperationException(message);
927930
}
928-
931+
929932
// Caching turned on?
930-
if (0 < this.getStatementPoolingCacheSize()) {
931-
preparedStatementHandleCache = new Builder<Sha1HashKey, PreparedStatementHandle>()
932-
.maximumWeightedCapacity(getStatementPoolingCacheSize())
933-
.listener(new PreparedStatementCacheEvictionListener())
934-
.build();
935-
936-
parameterMetadataCache = new Builder<Sha1HashKey, SQLServerParameterMetaData>()
937-
.maximumWeightedCapacity(getStatementPoolingCacheSize())
938-
.build();
933+
if (!this.getDisableStatementPooling() && 0 < this.getStatementPoolingCacheSize()) {
934+
prepareCache();
939935
}
940936
}
941937

@@ -1437,10 +1433,8 @@ Connection connectInternal(Properties propsIn,
14371433
sPropKey = SQLServerDriverBooleanProperty.DISABLE_STATEMENT_POOLING.toString();
14381434
sPropValue = activeConnectionProperties.getProperty(sPropKey);
14391435
if (null != sPropValue) {
1440-
// If disabled set cache size to 0 if disabled.
1441-
if(booleanPropertyOn(sPropKey, sPropValue))
1442-
this.setStatementPoolingCacheSize(0);
1443-
}
1436+
setDisableStatementPooling(booleanPropertyOn(sPropKey, sPropValue));
1437+
}
14441438

14451439
sPropKey = SQLServerDriverBooleanProperty.INTEGRATED_SECURITY.toString();
14461440
sPropValue = activeConnectionProperties.getProperty(sPropKey);
@@ -3080,8 +3074,6 @@ final void poolCloseEventNotify() throws SQLServerException {
30803074
checkClosed();
30813075
if (catalog != null) {
30823076
connectionCommand("use " + Util.escapeSQLId(catalog), "setCatalog");
3083-
contextIsAlreadyChanged = true;
3084-
contextChanged = true;
30853077
sCatalog = catalog;
30863078
}
30873079
loggerExternal.exiting(getClassNameLogging(), "setCatalog");
@@ -5692,14 +5684,34 @@ final void unprepareUnreferencedPreparedStatementHandles(boolean force) {
56925684
}
56935685
}
56945686

5687+
/**
5688+
* Returns true if statement pooling is disabled.
5689+
*
5690+
* @return
5691+
*/
5692+
public boolean getDisableStatementPooling() {
5693+
return this.disableStatementPooling;
5694+
}
5695+
5696+
/**
5697+
* Sets statement pooling to true or false;
5698+
*
5699+
* @param value
5700+
*/
5701+
public void setDisableStatementPooling(boolean value) {
5702+
this.disableStatementPooling = value;
5703+
if (!value && 0 < this.getStatementPoolingCacheSize()) {
5704+
prepareCache();
5705+
}
5706+
}
56955707

56965708
/**
56975709
* Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
56985710
* @return Returns the current setting per the description.
56995711
*/
57005712
public int getStatementPoolingCacheSize() {
57015713
return statementPoolingCacheSize;
5702-
}
5714+
}
57035715

57045716
/**
57055717
* Returns the current number of pooled prepared statement handles.
@@ -5717,25 +5729,40 @@ public int getStatementHandleCacheEntryCount() {
57175729
* @return Returns the current setting per the description.
57185730
*/
57195731
public boolean isStatementPoolingEnabled() {
5720-
return null != preparedStatementHandleCache && 0 < this.getStatementPoolingCacheSize();
5732+
return null != preparedStatementHandleCache && 0 < this.getStatementPoolingCacheSize() && !this.getDisableStatementPooling();
57215733
}
57225734

57235735
/**
5724-
* Specifies the size of the prepared statement cache for this conection. A value less than 1 means no cache.
5725-
* @param value The new cache size.
5736+
* Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache.
5737+
*
5738+
* @param value
5739+
* The new cache size.
57265740
*
57275741
*/
57285742
public void setStatementPoolingCacheSize(int value) {
5729-
if (value != this.statementPoolingCacheSize) {
5730-
value = Math.max(0, value);
5731-
statementPoolingCacheSize = value;
5732-
5733-
if (null != preparedStatementHandleCache)
5734-
preparedStatementHandleCache.setCapacity(value);
5743+
value = Math.max(0, value);
5744+
statementPoolingCacheSize = value;
57355745

5736-
if (null != parameterMetadataCache)
5737-
parameterMetadataCache.setCapacity(value);
5746+
if (!this.disableStatementPooling && value > 0) {
5747+
prepareCache();
57385748
}
5749+
if (null != preparedStatementHandleCache)
5750+
preparedStatementHandleCache.setCapacity(value);
5751+
5752+
if (null != parameterMetadataCache)
5753+
parameterMetadataCache.setCapacity(value);
5754+
}
5755+
5756+
/**
5757+
* Internal method to prepare the cache handle
5758+
* @param value
5759+
*/
5760+
private void prepareCache() {
5761+
preparedStatementHandleCache = new Builder<Sha1HashKey, PreparedStatementHandle>().maximumWeightedCapacity(getStatementPoolingCacheSize())
5762+
.listener(new PreparedStatementCacheEvictionListener()).build();
5763+
5764+
parameterMetadataCache = new Builder<Sha1HashKey, SQLServerParameterMetaData>().maximumWeightedCapacity(getStatementPoolingCacheSize())
5765+
.build();
57395766
}
57405767

57415768
/** Get a parameter metadata cache entry if statement pooling is enabled */
@@ -5788,12 +5815,6 @@ final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) {
57885815
preparedStatementHandleCache.remove(handle.getKey());
57895816
}
57905817

5791-
final void clearCachedPreparedStatementHandle() {
5792-
if (null != preparedStatementHandleCache) {
5793-
preparedStatementHandleCache.clear();
5794-
}
5795-
}
5796-
57975818
// Handle closing handles when removed from cache.
57985819
final class PreparedStatementCacheEvictionListener implements EvictionListener<Sha1HashKey, PreparedStatementHandle> {
57995820
public void onEviction(Sha1HashKey key, PreparedStatementHandle handle) {

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java

-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ public void run() {
169169
if (wrappedConnection.getConnectionLogger().isLoggable(Level.FINER))
170170
wrappedConnection.getConnectionLogger().finer(toString() + " Connection proxy closed ");
171171

172-
// clear cached prepared statement handle on this connection
173-
wrappedConnection.clearCachedPreparedStatementHandle();
174172
wrappedConnection.poolCloseEventNotify();
175173
wrappedConnection = null;
176174
}

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ public int getServerPreparedStatementDiscardThreshold() {
744744
}
745745

746746
/**
747-
* Specifies the size of the prepared statement cache for this conection. A value less than 1 means no cache.
747+
* Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache.
748748
*
749749
* @param statementPoolingCacheSize
750750
* Changes the setting per the description.
@@ -754,14 +754,32 @@ public void setStatementPoolingCacheSize(int statementPoolingCacheSize) {
754754
}
755755

756756
/**
757-
* Returns the size of the prepared statement cache for this conection. A value less than 1 means no cache.
757+
* Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
758758
*
759759
* @return Returns the current setting per the description.
760760
*/
761761
public int getStatementPoolingCacheSize() {
762762
int defaultSize = SQLServerDriverIntProperty.STATEMENT_POOLING_CACHE_SIZE.getDefaultValue();
763763
return getIntProperty(connectionProps, SQLServerDriverIntProperty.STATEMENT_POOLING_CACHE_SIZE.toString(), defaultSize);
764764
}
765+
766+
/**
767+
* Sets the statement pooling to true or false
768+
* @param disableStatementPooling
769+
*/
770+
public void setDisableStatementPooling(boolean disableStatementPooling) {
771+
setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.DISABLE_STATEMENT_POOLING.toString(), disableStatementPooling);
772+
}
773+
774+
/**
775+
* Returns true if statement pooling is disabled.
776+
* @return
777+
*/
778+
public boolean getDisableStatementPooling() {
779+
boolean defaultValue = SQLServerDriverBooleanProperty.DISABLE_STATEMENT_POOLING.getDefaultValue();
780+
return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.DISABLE_STATEMENT_POOLING.toString(),
781+
defaultValue);
782+
}
765783

766784
/**
767785
* Setting the socket timeout

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ public String toString() {
340340

341341
enum SQLServerDriverBooleanProperty
342342
{
343-
DISABLE_STATEMENT_POOLING ("disableStatementPooling", false),
343+
DISABLE_STATEMENT_POOLING ("disableStatementPooling", true),
344344
ENCRYPT ("encrypt", false),
345345
INTEGRATED_SECURITY ("integratedSecurity", false),
346346
LAST_UPDATE_COUNT ("lastUpdateCount", true),
347347
MULTI_SUBNET_FAILOVER ("multiSubnetFailover", false),
348348
SERVER_NAME_AS_ACE ("serverNameAsACE", false),
349349
SEND_STRING_PARAMETERS_AS_UNICODE ("sendStringParametersAsUnicode", true),
350-
SEND_TIME_AS_DATETIME ("sendTimeAsDatetime", false),
350+
SEND_TIME_AS_DATETIME ("sendTimeAsDatetime", true),
351351
TRANSPARENT_NETWORK_IP_RESOLUTION ("TransparentNetworkIPResolution", true),
352352
TRUST_SERVER_CERTIFICATE ("trustServerCertificate", false),
353353
XOPEN_STATES ("xopenStates", false),

0 commit comments

Comments
 (0)