Skip to content

Commit 9dfa996

Browse files
Merge branch 'ms-dev' into fixGetMaxConnections (Resolve conflicts)
# Conflicts: # src/test/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionTest.java
2 parents 12dd3f7 + 2c965e2 commit 9dfa996

16 files changed

+984
-746
lines changed

azure-pipelines.yml

+18-13
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,29 @@ jobs:
3030
Remove-Item –path .\JavaKeyStoreBase.txt
3131
displayName: 'PowerShell Script'
3232
- task: Maven@3
33-
displayName: 'Maven build 43'
33+
displayName: 'Maven build jre12'
3434
inputs:
3535
mavenPomFile: 'pom.xml'
36-
goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pbuild43 -DexcludeGroups=$(Ex_Groups)'
36+
goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre12 -DexcludedGroups=$(Ex_Groups)'
3737
testResultsFiles: '**/TEST-*.xml'
38-
testRunTitle: 'Maven build 43'
38+
testRunTitle: 'Maven build jre12'
3939
javaHomeOption: Path
40-
jdkDirectory: $(JDK11)
41-
mavenAuthenticateFeed: true
42-
checkStyleRunAnalysis: true
43-
pmdRunAnalysis: true
40+
jdkDirectory: $(JDK12)
4441
- task: Maven@3
45-
displayName: 'Maven build 42'
42+
displayName: 'Maven build jre11'
4643
inputs:
4744
mavenPomFile: 'pom.xml'
48-
goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pbuild42 -DexcludeGroups=$(Ex_Groups)'
49-
testRunTitle: 'Maven build 42'
45+
goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre11 -DexcludedGroups=$(Ex_Groups)'
46+
testResultsFiles: '**/TEST-*.xml'
47+
testRunTitle: 'Maven build jre11'
48+
javaHomeOption: Path
49+
jdkDirectory: $(JDK12)
50+
- task: Maven@3
51+
displayName: 'Maven build jre8'
52+
inputs:
53+
mavenPomFile: 'pom.xml'
54+
goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre8 -DexcludedGroups=$(Ex_Groups)'
55+
testResultsFiles: '**/TEST-*.xml'
56+
testRunTitle: 'Maven build jre8'
5057
javaHomeOption: Path
51-
jdkDirectory: $(JDK11)
52-
checkStyleRunAnalysis: true
53-
pmdRunAnalysis: true
58+
jdkDirectory: $(JDK12)

build.gradle

+35-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
* Gradle Scipt for Building Microsoft JDBC Driver for SQL Server
33
****************************************************************
44
* Instruction for Building JDBC Driver:
5-
* For building jre9 version of the driver,
6-
* use command 'gradle build' or 'gradle build -PbuildProfile=build43'
7-
* Whereas, for building jre8 version of the driver,
8-
* use command 'gradle build -PbuildProfile=build42'
5+
* For building particular version of the driver, use commands:
6+
* jre12 - - PS> gradle build
7+
PS> gradle build -PbuildProfile=jre12
8+
* jre11 - - PS> gradle build -PbuildProfile=jre11
9+
* jre8 - - PS> gradle build -PbuildProfile=jre8
10+
*
11+
* For Excluding Groups in command line:
12+
* PS> gradle build -PbuildProfile=jre11 "-PexcludedGroups=['xSQLv15','xGradle']"
913
****************************************************************/
1014

1115
apply plugin: 'java'
@@ -25,7 +29,26 @@ allprojects {
2529
}
2630
}
2731

28-
if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "build43")){
32+
test {
33+
useJUnitPlatform {
34+
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle')
35+
}
36+
}
37+
38+
if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "jre12")){
39+
40+
jreVersion = "jre12"
41+
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'
42+
jar {
43+
manifest {
44+
attributes 'Automatic-Module-Name': 'com.microsoft.sqlserver.jdbc'
45+
}
46+
}
47+
sourceCompatibility = 12
48+
targetCompatibility = 12
49+
}
50+
51+
if (hasProperty('buildProfile') && buildProfile == "jre11"){
2952

3053
jreVersion = "jre11"
3154
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'
@@ -38,13 +61,18 @@ if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile
3861
targetCompatibility = 11
3962
}
4063

41-
if((hasProperty('buildProfile') && buildProfile == "build42")) {
64+
if(hasProperty('buildProfile') && buildProfile == "jre8") {
4265

4366
jreVersion = "jre8"
4467
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc43.java'
4568

4669
sourceCompatibility = 1.8
4770
targetCompatibility = 1.8
71+
test {
72+
useJUnitPlatform {
73+
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','xJDBC42')
74+
}
75+
}
4876
}
4977

5078
jar.archiveName = "${archivesBaseName}-${version}.${jreVersion}-preview.jar"
@@ -55,7 +83,6 @@ jar {
5583
'Vendor': 'Microsoft Corporation'
5684
}
5785
}
58-
5986
sourceSets {
6087
main {
6188
java {
@@ -69,8 +96,7 @@ sourceSets {
6996
}
7097
test {
7198
resources {
72-
srcDirs 'src/test/resources'
73-
include '**/*.csv'
99+
srcDirs "src/test/resources", "AE_Certificates"
74100
output.resourcesDir = testOutputDir
75101
}
76102
}

pom.xml

+64-63
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@
4141

4242
<properties>
4343
<!-- Allowed values for excluded Groups here - - - - - - - - - - - - -
44+
xJDBC42 - - - - - - For tests not compatible with JDBC 42 Specifications
45+
xGradle - - - - - - For tests not compatible with Gradle Script - - - - -
4446
xSQLv12 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2014
45-
xSQLv14 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2017
46-
xSQLv15 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2019
47+
xSQLv14 - - - - - - For tests not compatible with SQL Server 2016 - 2017
48+
xSQLv15 - - - - - - For tests not compatible with SQL Server 2019 - - - -
4749
xAzureSQLDB - - - - For tests not compatible with Azure SQL Database - -
4850
xAzureSQLDW - - - - For tests not compatible with Azure Data Warehouse -
4951
xAzureSQLMI - - - - For tests not compatible with Azure SQL Managed Instance
5052
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5153
Default testing enabled with SQL Server 2019 (SQLv14) -->
52-
<excludeGroups>xSQLv15</excludeGroups>
54+
<excludedGroups>xSQLv15</excludedGroups>
5355

5456
<!-- Driver Dependencies -->
5557
<azure.keyvault.version>1.2.1</azure.keyvault.version>
@@ -181,7 +183,7 @@
181183

182184
<profiles>
183185
<profile>
184-
<id>build42</id>
186+
<id>jre8</id>
185187
<build>
186188
<finalName>${project.artifactId}-${project.version}.jre8-preview</finalName>
187189
<plugins>
@@ -214,49 +216,20 @@
214216
</archive>
215217
</configuration>
216218
</plugin>
217-
<plugin>
218-
<groupId>org.jacoco</groupId>
219-
<artifactId>jacoco-maven-plugin</artifactId>
220-
<version>0.8.3</version>
221-
<executions>
222-
<execution>
223-
<id>pre-test</id>
224-
<goals>
225-
<goal>prepare-agent</goal>
226-
</goals>
227-
</execution>
228-
<execution>
229-
<id>report</id>
230-
<phase>test</phase>
231-
<goals>
232-
<goal>report</goal>
233-
</goals>
234-
</execution>
235-
</executions>
236-
</plugin>
237219
<plugin>
238220
<groupId>org.apache.maven.plugins</groupId>
239221
<artifactId>maven-surefire-plugin</artifactId>
240222
<version>3.0.0-M1</version>
241223
<configuration>
242-
<argLine>
243-
${argLine} --illegal-access=permit
244-
</argLine>
245-
<properties>
246-
<excludeTags>${skipTestTag}</excludeTags>
247-
</properties>
248224
<!-- Exclude [xJDBC42] For tests not compatible with JDBC 4.2 Specifications -->
249-
<excludedGroups>${excludeGroups}, xJDBC42</excludedGroups>
225+
<excludedGroups>${excludedGroups}, xJDBC42</excludedGroups>
250226
</configuration>
251227
</plugin>
252228
</plugins>
253229
</build>
254230
</profile>
255231
<profile>
256-
<id>build43</id>
257-
<activation>
258-
<activeByDefault>true</activeByDefault>
259-
</activation>
232+
<id>jre11</id>
260233
<build>
261234
<finalName>${project.artifactId}-${project.version}.jre11-preview</finalName>
262235
<plugins>
@@ -285,39 +258,40 @@
285258
</archive>
286259
</configuration>
287260
</plugin>
261+
</plugins>
262+
</build>
263+
</profile>
264+
<profile>
265+
<id>jre12</id>
266+
<activation>
267+
<activeByDefault>true</activeByDefault>
268+
</activation>
269+
<build>
270+
<finalName>${project.artifactId}-${project.version}.jre12-preview</finalName>
271+
<plugins>
288272
<plugin>
289-
<groupId>org.jacoco</groupId>
290-
<artifactId>jacoco-maven-plugin</artifactId>
291-
<version>0.8.3</version>
292-
<executions>
293-
<execution>
294-
<id>pre-test</id>
295-
<goals>
296-
<goal>prepare-agent</goal>
297-
</goals>
298-
</execution>
299-
<execution>
300-
<id>report</id>
301-
<phase>test</phase>
302-
<goals>
303-
<goal>report</goal>
304-
</goals>
305-
</execution>
306-
</executions>
273+
<groupId>org.apache.maven.plugins</groupId>
274+
<artifactId>maven-compiler-plugin</artifactId>
275+
<version>3.8.0</version>
276+
<configuration>
277+
<excludes>
278+
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
279+
</excludes>
280+
<source>12</source>
281+
<target>12</target>
282+
</configuration>
307283
</plugin>
308284
<plugin>
309285
<groupId>org.apache.maven.plugins</groupId>
310-
<artifactId>maven-surefire-plugin</artifactId>
311-
<version>3.0.0-M1</version>
286+
<artifactId>maven-jar-plugin</artifactId>
287+
<version>3.1.1</version>
312288
<configuration>
313-
<argLine>
314-
${argLine} --illegal-access=permit
315-
</argLine>
316-
<properties>
317-
<excludeTags>${skipTestTag}</excludeTags>
318-
</properties>
319-
<excludedGroups>
320-
${excludeGroups}</excludedGroups>
289+
<archive>
290+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
291+
<manifestEntries>
292+
<Automatic-Module-Name>com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
293+
</manifestEntries>
294+
</archive>
321295
</configuration>
322296
</plugin>
323297
</plugins>
@@ -381,6 +355,18 @@
381355
</execution>
382356
</executions>
383357
</plugin>
358+
<plugin>
359+
<groupId>org.apache.maven.plugins</groupId>
360+
<artifactId>maven-surefire-plugin</artifactId>
361+
<version>3.0.0-M1</version>
362+
<configuration>
363+
<argLine>
364+
${argLine} --illegal-access=permit
365+
</argLine>
366+
<excludedGroups>
367+
${excludedGroups}</excludedGroups>
368+
</configuration>
369+
</plugin>
384370
<plugin>
385371
<groupId>org.apache.maven.plugins</groupId>
386372
<artifactId>maven-source-plugin</artifactId>
@@ -453,6 +439,21 @@
453439
<groupId>org.jacoco</groupId>
454440
<artifactId>jacoco-maven-plugin</artifactId>
455441
<version>0.8.3</version>
442+
<executions>
443+
<execution>
444+
<id>pre-test</id>
445+
<goals>
446+
<goal>prepare-agent</goal>
447+
</goals>
448+
</execution>
449+
<execution>
450+
<id>report</id>
451+
<phase>test</phase>
452+
<goals>
453+
<goal>report</goal>
454+
</goals>
455+
</execution>
456+
</executions>
456457
<configuration>
457458
<fileSets>
458459
<fileSet>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3025,7 +3025,7 @@ void setDataLoggable(boolean value) {
30253025
dataIsLoggable = value;
30263026
}
30273027

3028-
SharedTimer getSharedTimer() {
3028+
SharedTimer getSharedTimer() throws SQLServerException {
30293029
return con.getSharedTimer();
30303030
}
30313031

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,13 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
154154
* Return an existing cached SharedTimer associated with this Connection or create a new one.
155155
*
156156
* The SharedTimer will be released when the Connection is closed.
157+
*
158+
* @throws SQLServerException
157159
*/
158-
SharedTimer getSharedTimer() {
160+
SharedTimer getSharedTimer() throws SQLServerException {
159161
if (state == State.Closed) {
160-
throw new IllegalStateException(SQLServerException.getErrString("R_connectionIsClosed"));
162+
SQLServerException.makeFromDriverError(null, null, SQLServerException.getErrString("R_connectionIsClosed"),
163+
null, false);
161164
}
162165
if (null == sharedTimer) {
163166
this.sharedTimer = SharedTimer.getTimer();

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,9 @@ public final void setLargeMaxRows(long max) throws SQLServerException {
11331133
// SQL server only supports integer limits for setting max rows.
11341134
// If <max> is bigger than integer limits then throw an exception, otherwise call setMaxRows(int)
11351135
if (max > Integer.MAX_VALUE) {
1136-
throw new UnsupportedOperationException(SQLServerException.getErrString("R_invalidMaxRows"));
1136+
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidMaxRows"));
1137+
Object[] msgArgs = {max};
1138+
SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, true);
11371139
}
11381140
setMaxRows((int) max);
11391141
loggerExternal.exiting(getClassNameLogging(), "setLargeMaxRows");

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

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* Various driver utilities.
2626
*
2727
*/
28-
2928
final class Util {
3029
final static String SYSTEM_SPEC_VERSION = System.getProperty("java.specification.version");
3130
final static char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

src/test/java/com/microsoft/sqlserver/jdbc/JDBC43Test.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import org.junit.runner.RunWith;
1717
import org.opentest4j.TestAbortedException;
1818

19-
import com.microsoft.sqlserver.testframework.AbstractTest;;
19+
import com.microsoft.sqlserver.testframework.AbstractTest;
20+
import com.microsoft.sqlserver.testframework.Constants;
2021

2122

2223
/**
@@ -127,7 +128,7 @@ public void connectionPoolDataSourceTest() throws TestAbortedException, SQLExcep
127128
* @since 1.9
128129
*/
129130
@Test
130-
@Tag("xJDBC42")
131+
@Tag(Constants.xJDBC42)
131132
public void setShardingKeyIfValidTest() throws TestAbortedException, SQLException {
132133
try (SQLServerConnection connection43 = (SQLServerConnection43) getConnection()) {
133134
try {
@@ -151,7 +152,7 @@ public void setShardingKeyIfValidTest() throws TestAbortedException, SQLExceptio
151152
* @since 1.9
152153
*/
153154
@Test
154-
@Tag("xJDBC42")
155+
@Tag(Constants.xJDBC42)
155156
public void setShardingKeyTest() throws TestAbortedException, SQLException {
156157
try (SQLServerConnection connection43 = (SQLServerConnection43) getConnection()) {
157158
try {

0 commit comments

Comments
 (0)