diff --git a/.gitignore b/.gitignore
index b8095970d9..17f1c1b0a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,238 +1,239 @@
-#################
-## Eclipse
-#################
-
-.project
-.metadata
-bin/
-tmp/
-target/
-build/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.classpath
-.vscode/
-.settings/
-.gradle/
-.loadpath
-outdated-dependencies.txt
-pom.xml.versionBackup
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-
-#################
-## Visual Studio
-#################
-
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
-*.user
-*.sln.docstates
-
-# Build results
-
-[Dd]ebug/
-[Rr]elease/
-x64/
-build/
-[Bb]in/
-[Oo]bj/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-*_i.c
-*_p.c
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.log
-*.scc
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-*.ncrunch*
-.*crunch*.local.xml
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.Publish.xml
-*.pubxml
-*.publishproj
-
-# NuGet Packages Directory
-## TODO: If you have NuGet Package Restore enabled, uncomment the next line
-#packages/
-
-# Windows Azure Build Output
-csx
-*.build.csdef
-
-# Windows Store app package directory
-AppPackages/
-
-# Others
-sql/
-*.Cache
-ClientBin/
-[Ss]tyle[Cc]op.*
-~$*
-*~
-*.dbmdl
-*.[Pp]ublish.xml
-*.pfx
-*.publishsettings
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file to a newer
-# Visual Studio version. Backup files are not needed, because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-App_Data/*.mdf
-App_Data/*.ldf
-
-#############
-## Windows detritus
-#############
-
-# Windows image file caches
-Thumbs.db
-ehthumbs.db
-
-# Folder config file
-Desktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Mac crap
-.DS_Store
-
-
-#############
-## Python
-#############
-
-*.py[cod]
-
-# Packages
-*.egg
-*.egg-info
-dist/
-build/
-eggs/
-parts/
-var/
-sdist/
-develop-eggs/
-.installed.cfg
-
-# Installer logs
-pip-log.txt
-
-# Unit test / coverage reports
-.coverage
-.tox
-
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
-
-
-#############
-## Intellij
-#############
-
-## Directory-based project format
-.idea/
-
-## File-based project format
-*.ipr
-*.iws
-*.iml
-
-## Additional for IntelliJ
-out/
-gen/
\ No newline at end of file
+#################
+## Eclipse
+#################
+
+.project
+.metadata
+bin/
+tmp/
+target/
+build/
+AE_Certificates/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.vscode/
+.settings/
+.gradle/
+.loadpath
+outdated-dependencies.txt
+pom.xml.versionBackup
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+
+[Dd]ebug/
+[Rr]elease/
+x64/
+build/
+[Bb]in/
+[Oo]bj/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.log
+*.scc
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+.*crunch*.local.xml
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.Publish.xml
+*.pubxml
+*.publishproj
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+#packages/
+
+# Windows Azure Build Output
+csx
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.[Pp]ublish.xml
+*.pfx
+*.publishsettings
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+#############
+## Windows detritus
+#############
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Mac crap
+.DS_Store
+
+
+#############
+## Python
+#############
+
+*.py[cod]
+
+# Packages
+*.egg
+*.egg-info
+dist/
+build/
+eggs/
+parts/
+var/
+sdist/
+develop-eggs/
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+
+#############
+## Intellij
+#############
+
+## Directory-based project format
+.idea/
+
+## File-based project format
+*.ipr
+*.iws
+*.iml
+
+## Additional for IntelliJ
+out/
+gen/
diff --git a/.travis.yml b/.travis.yml
index 1a4299131d..af46163422 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
language: java
jdk:
- - oraclejdk10
+ - oraclejdk11
services:
- docker
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b01ab74e4d..4e736de77b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,11 +3,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
+## [7.1.2] Preview Release
+### Added
+- Added support for JDK 11 [#824](https://github.com/Microsoft/mssql-jdbc/pull/824) [#837](https://github.com/Microsoft/mssql-jdbc/pull/837) [#807](https://github.com/Microsoft/mssql-jdbc/pull/807)
+- Updated SQL keywords in DatabaseMetaData [#829](https://github.com/Microsoft/mssql-jdbc/pull/829)
+- Improvements in DatabaseMetadata to prevent Statement leaks and enhance Statement caching [#806](https://github.com/Microsoft/mssql-jdbc/pull/806)
+
+### Fixed Issues
+- Fixed slf4j warning message in tests [#841](https://github.com/Microsoft/mssql-jdbc/pull/841)
+- Fixed potential NullPointerException in logException() [#844](https://github.com/Microsoft/mssql-jdbc/pull/844)
+- Fixed intermittent failures in JUnit - LobsTest [#827](https://github.com/Microsoft/mssql-jdbc/pull/827)
+- Fixed useBulkCopyForBatchInserts API to respect Statement timeout value [#817](https://github.com/Microsoft/mssql-jdbc/pull/817)
+
+### Changed
+- Updated JUnit tests to remove hard-coded names [#809](https://github.com/Microsoft/mssql-jdbc/pull/809)
+- Removed illegal reflection access in Kerberos Authentication [#839](https://github.com/Microsoft/mssql-jdbc/pull/839)
+- Enabled non-running JUnit tests [#847](https://github.com/Microsoft/mssql-jdbc/pull/847)
+- Updated Clobs to use StandardCharsets.US_ASCII instead of hard-coded string [#855](https://github.com/Microsoft/mssql-jdbc/pull/855)
+- Code cleanup [#821](https://github.com/Microsoft/mssql-jdbc/pull/821) [#825](https://github.com/Microsoft/mssql-jdbc/pull/825)
+
## [7.1.1] Preview Release
+### Added
+- Added streaming capabilities for Clob.getAsciiStream() [#799](https://github.com/Microsoft/mssql-jdbc/pull/799)
+
### Fixed Issues
- Fixed a bug where calling length() after obtaining a stream would close the stream for Clobs/NClobs [#799](https://github.com/Microsoft/mssql-jdbc/pull/799)
+- Fixed Clob/NClob encoding issues [#799](https://github.com/Microsoft/mssql-jdbc/pull/799)
- Fixed issues in Bulk Copy exception handling [#801](https://github.com/Microsoft/mssql-jdbc/pull/801)
-- Fixed closeable resource leaks in Junit tests [#797](https://github.com/Microsoft/mssql-jdbc/pull/797)
+- Fixed closeable resource leaks in JUnit tests [#797](https://github.com/Microsoft/mssql-jdbc/pull/797)
- Fixed issues with apostrophe being passed in table name [#780](https://github.com/Microsoft/mssql-jdbc/pull/780)
- Fixed statement leaks and improved exception handling in SQLServerParameterMetadata [#780](https://github.com/Microsoft/mssql-jdbc/pull/780)
@@ -67,7 +90,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
### Added
- Added removed constructor back to AKV Provider which supports authentication with a customized method to fetch accessToken [#675](https://github.com/Microsoft/mssql-jdbc/pull/675)
- Added support for JDK 10 for both Maven and Gradle [#691](https://github.com/Microsoft/mssql-jdbc/pull/691)
-- Added a resource bundle to handle junit error strings [#698](https://github.com/Microsoft/mssql-jdbc/pull/698)
+- Added a resource bundle to handle JUnit error strings [#698](https://github.com/Microsoft/mssql-jdbc/pull/698)
### Fixed Issues
- Fixed the driver disposing user created credentials when using Kerberos Constrained Delegation [#636](https://github.com/Microsoft/mssql-jdbc/pull/636)
@@ -202,7 +225,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
## [6.3.1] Preview Release
### Added
- Added support for datetime/smallDatetime in TVP [#435](https://github.com/Microsoft/mssql-jdbc/pull/435)
-- Added more Junit tests for Always Encrypted [#432](https://github.com/Microsoft/mssql-jdbc/pull/432)
+- Added more JUnit tests for Always Encrypted [#432](https://github.com/Microsoft/mssql-jdbc/pull/432)
### Fixed Issues
- Fixed getString issue for uniqueIdentifier [#423](https://github.com/Microsoft/mssql-jdbc/pull/423)
@@ -214,7 +237,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
## [6.3.0] Preview Release
### Added
- Added support for sql_variant datatype [#387](https://github.com/Microsoft/mssql-jdbc/pull/387)
-- Added more Junit tests for Always Encrypted [#404](https://github.com/Microsoft/mssql-jdbc/pull/404)
+- Added more JUnit tests for Always Encrypted [#404](https://github.com/Microsoft/mssql-jdbc/pull/404)
### Fixed Issues
- Fixed Turkey locale issue when lowercasing an "i" [#384](https://github.com/Microsoft/mssql-jdbc/pull/384)
@@ -318,7 +341,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
### Added
- Added socket timeout exception as cause[#180](https://github.com/Microsoft/mssql-jdbc/pull/180)
- Added Constrained delegation support[#178](https://github.com/Microsoft/mssql-jdbc/pull/178)
-- Added junit test for Statement test[#174](https://github.com/Microsoft/mssql-jdbc/pull/174)
+- Added JUnit test for Statement test[#174](https://github.com/Microsoft/mssql-jdbc/pull/174)
- Added test for statement.cancel() when MultiSubnetFailover is set to true[#173](https://github.com/Microsoft/mssql-jdbc/pull/173)
- Added tests for lobs [#168](https://github.com/Microsoft/mssql-jdbc/pull/168)
- Added badges for License, Maven Central, JavaDocs & gitter chat room [#184](https://github.com/Microsoft/mssql-jdbc/pull/184)
@@ -360,7 +383,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
### Changed
- Switched to clean rounding for bigDecimal [#118](https://github.com/Microsoft/mssql-jdbc/pull/118)
- Updated BVT tests to use jUnit test framework [#120](https://github.com/Microsoft/mssql-jdbc/pull/120)
- - In case of socket timeout occurance, avoid connection retry [#122](https://github.com/Microsoft/mssql-jdbc/pull/122)
+ - In case of socket timeout occurrence, avoid connection retry [#122](https://github.com/Microsoft/mssql-jdbc/pull/122)
- Changed ant build file to skip tests [#126](https://github.com/Microsoft/mssql-jdbc/pull/126)
### Fixed Issues
diff --git a/README.md b/README.md
index 375137e46d..51c931dd59 100644
--- a/README.md
+++ b/README.md
@@ -36,26 +36,26 @@ What's coming next? We will look into adding a more comprehensive set of tests,
## Build
### Prerequisites
-* Java 10
+* Java 11
* [Maven](http://maven.apache.org/download.cgi)
* An instance of SQL Server or Azure SQL Database that you can connect to.
### Build the JAR files
Maven builds automatically trigger a set of verification tests to run. For these tests to pass, you will first need to add an environment variable in your system called `mssql_jdbc_test_connection_properties` to provide the [correct connection properties](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url) for your SQL Server or Azure SQL Database instance.
-To build the jar files, you must use Java 10 with Maven. You can choose to build a JDBC 4.3 compliant jar file (for use with JRE 10) and/or a JDBC 4.2 compliant jar file (for use with JRE 8).
+To build the jar files, you must use Java 11 with Maven. You can choose to build a JDBC 4.3 compliant jar file (for use with JRE 11) and/or a JDBC 4.2 compliant jar file (for use with JRE 8).
* Maven:
1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance.
- 2. Run one of the commands below to build a JDBC 4.3 compliant jar or JDBC 4.2 compliant jar in the \target directory.
- * Run `mvn install -Pbuild43`. This creates JDBC 4.3 compliant jar in \target directory
- * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory
+ 2. Run one of the commands below to build a JDBC 4.3 compliant jar or JDBC 4.2 compliant jar in the `\target` directory.
+ * Run `mvn install -Pbuild43`. This creates JDBC 4.3 compliant jar in `\target` directory
+ * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in `\target` directory
* Gradle:
1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance.
- 2. Run one of the commands below to build a JDBC 4.3 compliant jar or JDBC 4.2 compliant jar in the \build\libs directory.
- * Run `gradle build -PbuildProfile=build43`. This creates JDBC 4.3 compliant jar in \build\libs directory
- * Run `gradle build -PbuildProfile=build42`. This creates JDBC 4.2 compliant jar in \build\libs directory
+ 2. Run one of the commands below to build a JDBC 4.3 compliant jar or JDBC 4.2 compliant jar in the `\build\libs` directory.
+ * Run `gradle build -PbuildProfile=build43`. This creates JDBC 4.3 compliant jar in `\build\libs` directory
+ * Run `gradle build -PbuildProfile=build42`. This creates JDBC 4.2 compliant jar in `\build\libs` directory
## Resources
@@ -65,7 +65,7 @@ API reference documentation is available in [Javadocs](https://aka.ms/jdbcjavado
This driver is documented on [Microsoft's Documentation web site](https://docs.microsoft.com/en-us/sql/connect/jdbc/getting-started-with-the-jdbc-driver).
### Sample Code
-For samples, please see the src\sample directory.
+For samples, please see the `src\sample` directory.
### Download the DLLs
For some features (e.g. Integrated Authentication and Distributed Transactions), you may need to use the `sqljdbc_xa` and `sqljdbc_auth` DLLs. They can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=868287)
@@ -90,7 +90,7 @@ To get the latest preview version of the driver, add the following to your POM f
com.microsoft.sqlserver
mssql-jdbc
- 7.1.1.jre10-preview
+ 7.1.2.jre11-preview
```
@@ -123,7 +123,7 @@ Projects that require either of the two features need to explicitly declare the
com.microsoft.sqlserver
mssql-jdbc
- 7.1.1.jre10-preview
+ 7.1.2.jre11-preview
compile
@@ -140,7 +140,7 @@ Projects that require either of the two features need to explicitly declare the
com.microsoft.sqlserver
mssql-jdbc
- 7.1.1.jre10-preview
+ 7.1.2.jre11-preview
compile
diff --git a/appveyor.yml b/appveyor.yml
index 6ab08769cd..3e70b718ba 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -27,13 +27,13 @@ install:
cache:
- C:\Users\appveyor\.m2 -> pom.xml
+# Disable build and test scripts till Java 11 is supported
build_script:
- - keytool -importkeystore -srckeystore cert.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS -srcstorepass password -deststorepass password
- - keytool -list -v -keystore clientcert.jks -storepass "password" > JavaKeyStore.txt
- - cd..
- - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild43
- - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42
-
-test_script:
- - mvn test -B -Pbuild43
- - mvn test -B -Pbuild42
+ - keytool -importkeystore -srckeystore cert.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS -srcstorepass password -deststorepass password
+ - keytool -list -v -keystore clientcert.jks -storepass "password" > JavaKeyStore.txt
+# - cd..
+# - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild43
+# - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42
+# test_script:
+# - mvn test -B -Pbuild43
+# - mvn test -B -Pbuild42
diff --git a/build.gradle b/build.gradle
index 34c86772c9..0688b4aedf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,7 +10,7 @@
apply plugin: 'java'
-version = '7.1.1'
+version = '7.1.2'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
@@ -27,15 +27,15 @@ allprojects {
if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "build43")){
- jreVersion = "jre10-preview"
+ jreVersion = "jre11-preview"
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'
jar {
manifest {
attributes 'Automatic-Module-Name': 'com.microsoft.sqlserver.jdbc'
}
}
- sourceCompatibility = 10
- targetCompatibility = 10
+ sourceCompatibility = 11
+ targetCompatibility = 11
}
if((hasProperty('buildProfile') && buildProfile == "build42")) {
@@ -82,16 +82,19 @@ repositories {
}
dependencies {
- compileOnly 'com.microsoft.azure:azure-keyvault:1.0.0',
- 'com.microsoft.azure:adal4j:1.6.0'
- testCompile 'org.junit.platform:junit-platform-console:1.2.0',
- 'org.junit.platform:junit-platform-commons:1.2.0',
- 'org.junit.platform:junit-platform-engine:1.2.0',
- 'org.junit.platform:junit-platform-launcher:1.2.0',
- 'org.junit.platform:junit-platform-runner:1.2.0',
- 'org.junit.platform:junit-platform-surefire-provider:1.2.0',
- 'org.junit.jupiter:junit-jupiter-api:5.2.0',
- 'org.junit.jupiter:junit-jupiter-engine:5.2.0',
+ compileOnly 'com.microsoft.azure:azure-keyvault:1.1.1',
+ 'com.microsoft.azure:azure-keyvault-webkey:1.1.1',
+ 'com.microsoft.rest:client-runtime:1.6.2',
+ 'com.microsoft.azure:adal4j:1.6.2'
+ testCompile 'org.junit.platform:junit-platform-console:1.3.1',
+ 'org.junit.platform:junit-platform-commons:1.3.1',
+ 'org.junit.platform:junit-platform-engine:1.3.1',
+ 'org.junit.platform:junit-platform-launcher:1.3.1',
+ 'org.junit.platform:junit-platform-runner:1.3.1',
+ 'org.junit.platform:junit-platform-surefire-provider:1.3.1',
+ 'org.junit.jupiter:junit-jupiter-api:5.3.1',
+ 'org.junit.jupiter:junit-jupiter-engine:5.3.1',
'com.zaxxer:HikariCP:3.2.0',
- 'org.apache.commons:commons-dbcp2:5.0'
+ 'org.apache.commons:commons-dbcp2:2.5.0',
+ 'org.slf4j:slf4j-nop:1.7.25'
}
diff --git a/pom.xml b/pom.xml
index f6de796709..9505b50557 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.microsoft.sqlserver
mssql-jdbc
- 7.1.1
+ 7.1.2
jar
Microsoft JDBC Driver for SQL Server
@@ -39,22 +39,33 @@
UTF-8
- 1.2.0
- 5.2.0
+ 1.3.1
+ 5.3.1
com.microsoft.azure
azure-keyvault
- 1.0.0
+ 1.1.1
+ true
+
+
+ com.microsoft.azure
+ azure-keyvault-webkey
+ 1.1.1
true
-
com.microsoft.azure
adal4j
- 1.6.0
+ 1.6.2
+ true
+
+
+ com.microsoft.rest
+ client-runtime
+ 1.6.2
true
@@ -119,6 +130,12 @@
2.5.0
test
+
+ org.slf4j
+ slf4j-nop
+ 1.7.25
+ test
+
@@ -128,8 +145,9 @@
${project.artifactId}-${project.version}.jre8-preview
+ org.apache.maven.plugins
maven-compiler-plugin
- 3.7.0
+ 3.8.0
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc43.java
@@ -148,27 +166,60 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.2
+
+
+ pre-test
+
+ prepare-agent
+
+
+
+ report
+ test
+
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.0
+
+
+ ${argLine} --illegal-access=permit
+
+
+ ${skipTestTag}
+
+
+
-
build43
true
- ${project.artifactId}-${project.version}.jre10-preview
+ ${project.artifactId}-${project.version}.jre11-preview
+ org.apache.maven.plugins
maven-compiler-plugin
- 3.7.0
+ 3.8.0
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java
- 10
- 10
+ 11
+ 11
@@ -184,14 +235,44 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.2
+
+
+ pre-test
+
+ prepare-agent
+
+
+
+ report
+ test
+
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.0
+
+
+ ${argLine} --illegal-access=permit
+
+
+ ${skipTestTag}
+
+
+
-
-
-
${basedir}
@@ -200,7 +281,6 @@
-
src/test/resources
@@ -216,39 +296,48 @@
-
-
org.apache.maven.plugins
- maven-source-plugin
- 3.0.1
+ maven-enforcer-plugin
+ 3.0.0-M2
- attach-sources
+ enforce-versions
- jar
+ enforce
+
+
+
+
+ WARN
+
+ org.apache.maven.plugins:maven-verifier-plugin
+
+ Please consider using the maven-invoker-plugin
+ (http://maven.apache.org/plugins/maven-invoker-plugin/)!
+
+
+ 3.0.5
+
+
+ 11
+
+
+
-
- org.jacoco
- jacoco-maven-plugin
- 0.8.1
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
- pre-test
-
- prepare-agent
-
-
-
- report
- test
+ attach-sources
- report
+ jar
@@ -261,7 +350,10 @@
true
- com.microsoft.sqlserver.jdbc,microsoft.sql
+ <_exportcontents>export com.microsoft.sqlserver.jdbc
+ <_exportcontents>export microsoft.sql
+ <_exportcontents>export
+ com.microsoft.sqlserver.jdbc.dataclassification
!microsoft.sql,*
@@ -275,16 +367,13 @@
-
org.apache.maven.plugins
maven-javadoc-plugin
3.0.0
-
true
-
attach-javadocs
@@ -294,27 +383,6 @@
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.0
-
-
-
- ${skipTestTag}
-
-
-
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
-
-
-
-
org.codehaus.mojo
versions-maven-plugin
@@ -325,8 +393,6 @@
file:///${session.executionRootDirectory}/maven-version-rules.xml
-
-
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
index 1fa3e55dad..845fe5b900 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
@@ -1129,7 +1129,7 @@ static String convertReaderToString(Reader reader, int readerLength) throws SQLS
try {
// Set up a StringBuilder big enough to hold the Reader value. If we weren't told the size of
// the value then start with a "reasonable" guess StringBuilder size. If necessary, the StringBuilder
- // will grow automatically to accomodate arbitrary amounts of data.
+ // will grow automatically to accommodate arbitrary amounts of data.
StringBuilder sb = new StringBuilder(
(DataTypes.UNKNOWN_STREAM_LENGTH != readerLength) ? readerLength : 4000);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
index 1f78a96978..a46ad5b231 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
@@ -10,7 +10,7 @@
/**
*
- * This class is used to handle exceptions that may be recieved from sqljdbc_auth.dll and sqljdbc_xa.dll
+ * This class is used to handle exceptions that may be received from sqljdbc_auth.dll and sqljdbc_xa.dll
*
*/
class DLLException extends Exception {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
index cce14b03e7..0cabb29360 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
@@ -2484,7 +2484,7 @@ private void findSocketUsingJavaNIO(InetAddress[] inetAddrs, int portNumber,
} catch (IOException ex) {
if (logger.isLoggable(Level.FINER))
logger.finer(this.toString() + " the exception: " + ex.getClass() + " with message: "
- + ex.getMessage() + " occured while processing the channel: " + ch);
+ + ex.getMessage() + " occurred while processing the channel: " + ch);
updateSelectedException(ex, this.toString());
// close the channel pro-actively so that we do not
// rely to network resources
@@ -2913,7 +2913,7 @@ public void run() {
} catch (IOException ex) {
if (logger.isLoggable(Level.FINER)) {
logger.finer(this.toString() + " exception:" + ex.getClass() + " with message:" + ex.getMessage()
- + " occured while connecting to InetSocketAddress:" + inetSocketAddress);
+ + " occurred while connecting to InetSocketAddress:" + inetSocketAddress);
}
exception = ex;
}
@@ -3281,7 +3281,7 @@ void writeBigDecimal(BigDecimal bigDecimalVal, int srcJdbcType, int precision,
*/
/*
- * setScale of all BigDecimal value based on metadata as scale is not sent seperately for individual value. Use
+ * setScale of all BigDecimal value based on metadata as scale is not sent separately for individual value. Use
* the rounding used in Server. Say, for BigDecimal("0.1"), if scale in metdadata is 0, then ArithmeticException
* would be thrown if RoundingMode is not set
*/
@@ -4099,7 +4099,7 @@ void flush(boolean atEOM) throws SQLServerException {
* @param sName
* the optional parameter name
* @param bOut
- * boolean true if the value that follows is being registered as an ouput parameter
+ * boolean true if the value that follows is being registered as an output parameter
* @param tdsType
* TDS type of the value that follows
*/
@@ -4130,7 +4130,7 @@ void writeRPCNameValType(String sName, boolean bOut, TDSType tdsType) throws SQL
* @param booleanValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCBit(String sName, Boolean booleanValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.BITN);
@@ -4151,7 +4151,7 @@ void writeRPCBit(String sName, Boolean booleanValue, boolean bOut) throws SQLSer
* @param shortValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCByte(String sName, Byte byteValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.INTN);
@@ -4172,7 +4172,7 @@ void writeRPCByte(String sName, Byte byteValue, boolean bOut) throws SQLServerEx
* @param shortValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCShort(String sName, Short shortValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.INTN);
@@ -4193,7 +4193,7 @@ void writeRPCShort(String sName, Short shortValue, boolean bOut) throws SQLServe
* @param intValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCInt(String sName, Integer intValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.INTN);
@@ -4214,7 +4214,7 @@ void writeRPCInt(String sName, Integer intValue, boolean bOut) throws SQLServerE
* @param longValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCLong(String sName, Long longValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.INTN);
@@ -4235,7 +4235,7 @@ void writeRPCLong(String sName, Long longValue, boolean bOut) throws SQLServerEx
* @param floatValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCReal(String sName, Float floatValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.FLOATN);
@@ -4269,7 +4269,7 @@ void writeRPCSqlVariant(String sName, SqlVariant sqlVariantValue, boolean bOut)
* @param doubleValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCDouble(String sName, Double doubleValue, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.FLOATN);
@@ -4303,7 +4303,7 @@ void writeRPCDouble(String sName, Double doubleValue, boolean bOut) throws SQLSe
* @param nScale
* the desired scale
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*/
void writeRPCBigDecimal(String sName, BigDecimal bdValue, int nScale, boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.DECIMALN);
@@ -4364,7 +4364,7 @@ void writeRPCStringUnicode(String sValue) throws SQLServerException {
* @param sValue
* the data value
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
* @param collation
* the collation of the data value
*/
@@ -4679,7 +4679,7 @@ private void writeInternalTVPRowValues(JDBCType jdbcType, String currentColumnSt
BigDecimal bdValue = new BigDecimal(currentColumnStringValue);
/*
- * setScale of all BigDecimal value based on metadata as scale is not sent seperately for individual
+ * setScale of all BigDecimal value based on metadata as scale is not sent separately for individual
* value. Use the rounding used in Server. Say, for BigDecimal("0.1"), if scale in metdadata is 0,
* then ArithmeticException would be thrown if RoundingMode is not set
*/
@@ -5239,7 +5239,7 @@ void writeRPCByteArray(String sName, byte bValue[], boolean bOut, JDBCType jdbcT
* @param subSecondNanos
* the sub-second nanoseconds (0 - 999,999,999)
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
*
*/
void writeRPCDateTime(String sName, GregorianCalendar cal, int subSecondNanos,
@@ -5934,7 +5934,7 @@ private byte[] scaledNanosToEncodedBytes(long scaledNanos, int encodedLength) {
* @param streamLength
* length of the stream (may be unknown)
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
* @param jdbcType
* The JDBC type used to determine whether the value is textual or non-textual.
* @param collation
@@ -6033,7 +6033,7 @@ void writeRPCInputStream(String sName, InputStream stream, long streamLength, bo
* @param streamLength
* length of the stream (may be unknown)
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
* @throws SQLServerException
*/
void writeRPCXML(String sName, InputStream stream, long streamLength, boolean bOut) throws SQLServerException {
@@ -6072,7 +6072,7 @@ void writeRPCXML(String sName, InputStream stream, long streamLength, boolean bO
* @param reLength
* the reader data length (in characters)
* @param bOut
- * boolean true if the data value is being registered as an ouput parameter
+ * boolean true if the data value is being registered as an output parameter
* @param collation
* The SQL collation associated with the value. Null for non-textual SQL Server types.
* @throws SQLServerException
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
index 47c95e9de7..d0a99ba1c6 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
@@ -251,7 +251,7 @@ private String enrichSpnWithRealm(String spn, boolean allowHostnameCanonicalizat
}
String dnsName = m.group(1);
String portOrInstance = m.group(2);
- RealmValidator realmValidator = getRealmValidator(dnsName);
+ RealmValidator realmValidator = getRealmValidator();
String realm = findRealmFromHostname(realmValidator, dnsName);
if (realm == null && allowHostnameCanonicalization) {
// We failed, try with canonical host name to find a better match
@@ -277,50 +277,15 @@ private String enrichSpnWithRealm(String spn, boolean allowHostnameCanonicalizat
private static RealmValidator validator;
/**
- * Find a suitable way of validating a REALM for given JVM.
+ * Get validator to validate REALM for given JVM.
*
- * @param hostnameToTest
- * an example hostname we are gonna use to test our realm validator.
- * @return a not null realm Validator.
+ * @return a not null realm validator.
*/
- static RealmValidator getRealmValidator(String hostnameToTest) {
+ static RealmValidator getRealmValidator() {
if (validator != null) {
return validator;
}
- // JVM Specific, here Sun/Oracle JVM
- try {
- Class> clz = Class.forName("sun.security.krb5.Config");
- Method getInstance = clz.getMethod("getInstance", new Class[0]);
- final Method getKDCList = clz.getMethod("getKDCList", new Class[] {String.class});
- final Object instance = getInstance.invoke(null);
- RealmValidator oracleRealmValidator = new RealmValidator() {
-
- @Override
- public boolean isRealmValid(String realm) {
- try {
- Object ret = getKDCList.invoke(instance, realm);
- return ret != null;
- } catch (Exception err) {
- return false;
- }
- }
- };
- validator = oracleRealmValidator;
- // As explained here: https://github.com/Microsoft/mssql-jdbc/pull/40#issuecomment-281509304
- // The default Oracle Resolution mechanism is not bulletproof
- // If it resolves a non-existing name, drop it.
- if (!validator.isRealmValid("this.might.not.exist." + hostnameToTest)) {
- // Our realm validator is well working, return it
- authLogger.fine("Kerberos Realm Validator: Using Built-in Oracle Realm Validation method.");
- return oracleRealmValidator;
- }
- authLogger
- .fine("Kerberos Realm Validator: Detected buggy Oracle Realm Validator, using DNSKerberosLocator.");
- } catch (ReflectiveOperationException notTheRightJVMException) {
- // Ignored, we simply are not using the right JVM
- authLogger.fine("Kerberos Realm Validator: No Oracle Realm Validator Available, using DNSKerberosLocator.");
- }
- // No implementation found, default one, not any realm is valid
+
validator = new RealmValidator() {
@Override
public boolean isRealmValid(String realm) {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java
index 1da236fcb1..32e02dc578 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java
@@ -142,19 +142,19 @@ private static byte[] decryptRSAOAEP(byte[] cipherText,
private static boolean verifyRSASignature(byte[] hash, byte[] signature, X509Certificate certificate,
String masterKeyPath) throws SQLServerException {
Signature signVerify;
- boolean verificationSucess = false;
+ boolean verificationSuccess = false;
try {
signVerify = Signature.getInstance("SHA256withRSA");
signVerify.initVerify(certificate.getPublicKey());
signVerify.update(hash);
- verificationSucess = signVerify.verify(signature);
+ verificationSuccess = signVerify.verify(signature);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException e) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidCertificateSignature"));
Object[] msgArgs = {masterKeyPath};
throw new SQLServerException(form.format(msgArgs), e);
}
- return verificationSucess;
+ return verificationSuccess;
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
index 93758a09cb..6e8e0a2daa 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
@@ -34,7 +34,7 @@ final class Parameter {
// Value type info for OUT parameters (excluding return status)
private TypeInfo typeInfo;
- // For unencrypted paramters cryptometa will be null. For encrypted parameters it will hold encryption metadata.
+ // For unencrypted parameters cryptometa will be null. For encrypted parameters it will hold encryption metadata.
CryptoMetadata cryptoMeta = null;
TypeInfo getTypeInfo() {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
index 3aa3f97915..de354b40e4 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
@@ -8,6 +8,6 @@
final class SQLJdbcVersion {
static final int major = 7;
static final int minor = 1;
- static final int patch = 1;
+ static final int patch = 2;
static final int build = 0;
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
index 5968eba254..068e400117 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
@@ -1700,9 +1700,11 @@ private void getDestinationMetadata() throws SQLServerException {
SQLServerException.getErrString("R_invalidDestinationTable"), null, false);
}
+ String escapedDestinationTableName = Util.escapeSingleQuotes(destinationTableName);
+
SQLServerResultSet rs = null;
- SQLServerResultSet rsMoreMetaData = null;
SQLServerStatement stmt = null;
+ String metaDataQuery = null;
try {
if (null != destinationTableMetadata) {
@@ -1713,7 +1715,7 @@ private void getDestinationMetadata() throws SQLServerException {
// Get destination metadata
rs = stmt.executeQueryInternal("sp_executesql N'SET FMTONLY ON SELECT * FROM "
- + Util.escapeSingleQuotes(destinationTableName) + " '");
+ + escapedDestinationTableName + " '");
}
destColumnCount = rs.getMetaData().getColumnCount();
@@ -1721,27 +1723,26 @@ private void getDestinationMetadata() throws SQLServerException {
destCekTable = rs.getCekTable();
if (!connection.getServerSupportsColumnEncryption()) {
- // SQL server prior to 2016 does not support encryption_type
- rsMoreMetaData = ((SQLServerStatement) connection.createStatement())
- .executeQueryInternal("select collation_name from sys.columns where " + "object_id=OBJECT_ID('"
- + Util.escapeSingleQuotes(destinationTableName) + "') " + "order by column_id ASC");
+ metaDataQuery = "select collation_name from sys.columns where " + "object_id=OBJECT_ID('"
+ + escapedDestinationTableName + "') " + "order by column_id ASC";
} else {
- rsMoreMetaData = ((SQLServerStatement) connection.createStatement()).executeQueryInternal(
- "select collation_name, encryption_type from sys.columns where " + "object_id=OBJECT_ID('"
- + Util.escapeSingleQuotes(destinationTableName) + "') " + "order by column_id ASC");
+ metaDataQuery = "select collation_name, encryption_type from sys.columns where "
+ + "object_id=OBJECT_ID('" + escapedDestinationTableName + "') " + "order by column_id ASC";
}
- for (int i = 1; i <= destColumnCount; ++i) {
- if (rsMoreMetaData.next()) {
- if (!connection.getServerSupportsColumnEncryption()) {
+
+ try (SQLServerStatement statementMoreMetadata = (SQLServerStatement) connection.createStatement();
+ SQLServerResultSet rsMoreMetaData = statementMoreMetadata.executeQueryInternal(metaDataQuery)) {
+ for (int i = 1; i <= destColumnCount; ++i) {
+ if (rsMoreMetaData.next()) {
+ String bulkCopyEncryptionType = null;
+ if (connection.getServerSupportsColumnEncryption()) {
+ bulkCopyEncryptionType = rsMoreMetaData.getString("encryption_type");
+ }
destColumnMetadata.put(i, new BulkColumnMetaData(rs.getColumn(i),
- rsMoreMetaData.getString("collation_name"), null));
+ rsMoreMetaData.getString("collation_name"), bulkCopyEncryptionType));
} else {
- destColumnMetadata.put(i,
- new BulkColumnMetaData(rs.getColumn(i), rsMoreMetaData.getString("collation_name"),
- rsMoreMetaData.getString("encryption_type")));
+ destColumnMetadata.put(i, new BulkColumnMetaData(rs.getColumn(i)));
}
- } else {
- destColumnMetadata.put(i, new BulkColumnMetaData(rs.getColumn(i)));
}
}
} catch (SQLException e) {
@@ -1752,8 +1753,6 @@ private void getDestinationMetadata() throws SQLServerException {
rs.close();
if (null != stmt)
stmt.close();
- if (null != rsMoreMetaData)
- rsMoreMetaData.close();
}
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
index 87054ef958..6331df080a 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
@@ -2265,51 +2265,51 @@ public void registerOutParameter(String parameterName, int sqlType) throws SQLSe
}
@Override
- public void registerOutParameter(int paramterIndex, SQLType sqlType) throws SQLServerException {
+ public void registerOutParameter(int parameterIndex, SQLType sqlType) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {paramterIndex, sqlType});
+ new Object[] {parameterIndex, sqlType});
// getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber());
+ registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber());
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
@Override
- public void registerOutParameter(int paramterIndex, SQLType sqlType, String typeName) throws SQLServerException {
+ public void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {paramterIndex, sqlType, typeName});
+ new Object[] {parameterIndex, sqlType, typeName});
// getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), typeName);
+ registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber(), typeName);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
@Override
- public void registerOutParameter(int paramterIndex, SQLType sqlType, int scale) throws SQLServerException {
+ public void registerOutParameter(int parameterIndex, SQLType sqlType, int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {paramterIndex, sqlType, scale});
+ new Object[] {parameterIndex, sqlType, scale});
// getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), scale);
+ registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber(), scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
@Override
- public void registerOutParameter(int paramterIndex, SQLType sqlType, int precision,
+ public void registerOutParameter(int parameterIndex, SQLType sqlType, int precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {paramterIndex, sqlType, scale});
+ new Object[] {parameterIndex, sqlType, scale});
// getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), precision, scale);
+ registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber(), precision, scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
index 79df3191cb..5cc302ec73 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
@@ -19,6 +19,7 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.sql.Clob;
import java.sql.SQLException;
import java.text.MessageFormat;
@@ -588,7 +589,7 @@ public int setString(long pos, String s) throws SQLException {
* Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents. The
* string will overwrite the existing characters in the Clob object starting at the position pos. If the end of the
* Clob value is reached while writing the given string, then the length of the Clob value will be increased to
- * accomodate the extra characters.
+ * accommodate the extra characters.
*
* SQL Server behavior: If the value specified for pos is greater than then length+1 of the CLOB value then a
* SQLException is thrown.
@@ -776,7 +777,7 @@ public void write(byte[] b, int off, int len) throws IOException {
return;
try {
// Convert bytes to string using US-ASCII translation.
- String s = new String(b, off, len, "US-ASCII");
+ String s = new String(b, off, len, StandardCharsets.US_ASCII);
// Call parent's setString and update position.
// setString can throw a SQLServerException, we translate
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
index 18142be1d8..0ba3f48d30 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
@@ -309,7 +309,7 @@ static ParsedSQLCacheItem parseAndCacheSQL(CityHash128Key key, String sql) throw
* Locates statement parameters.
*
* @param sql
- * SQL text to parse for positions of parameters to intialize.
+ * SQL text to parse for positions of parameters to initialize.
*/
private static int[] locateParams(String sql) {
LinkedList parameterPositions = new LinkedList<>();
@@ -2326,8 +2326,8 @@ static int TimerRemaining(long timerExpire) {
// maximum timeout the socket takes is int max.
if (result > Integer.MAX_VALUE)
result = Integer.MAX_VALUE;
- // we have to make sure that we return atleast one ms
- // we want atleast one attempt to happen with a positive timeout passed by the user.
+ // we have to make sure that we return at least one ms
+ // we want at least one attempt to happen with a positive timeout passed by the user.
if (result <= 0)
result = 1;
return (int) result;
@@ -5453,7 +5453,7 @@ protected void endRequestInternal() throws SQLException {
}
/**
- * Replaces JDBC syntax parameter markets '?' with SQL Server paramter markers @p1, @p2 etc...
+ * Replaces JDBC syntax parameter markets '?' with SQL Server parameter markers @p1, @p2 etc...
*
* @param sql
* the user's SQL
@@ -5502,7 +5502,7 @@ String replaceParameterMarkers(String sqlSrc, int[] paramPositions, Parameter[]
* @param nParam
* the parameter number
* @param name
- * the paramter name
+ * the parameter name
* @param offset
* @return int
*/
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
index aca757bc9f..91592c78b5 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
@@ -14,6 +14,8 @@
import java.sql.SQLTimeoutException;
import java.text.MessageFormat;
import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
@@ -80,16 +82,35 @@ CallableStatement prepare(SQLServerConnection conn) throws SQLServerException {
}
final class HandleAssociation {
- final String databaseName;
- final CallableStatement stmt;
+ Map statementMap;
+ boolean nullCatalog = false;
+ CallableStatement stmt;
- HandleAssociation(String databaseName, CallableStatement stmt) {
- this.databaseName = databaseName;
- this.stmt = stmt;
+ HandleAssociation() {
+ if (null == statementMap) {
+ statementMap = new HashMap<>();
+ }
+ }
+
+ final void addToMap(String databaseName, CallableStatement stmt) {
+ if (null != databaseName) {
+ nullCatalog = false;
+ statementMap.put(databaseName, stmt);
+ } else {
+ nullCatalog = true;
+ this.stmt = stmt;
+ }
}
- final void close() throws SQLServerException {
- ((SQLServerCallableStatement) stmt).close();
+ final CallableStatement getMappedStatement(String databaseName) {
+ if (null != databaseName) {
+ if (null != statementMap && statementMap.containsKey(databaseName)) {
+ return statementMap.get(databaseName);
+ }
+ return null;
+ } else {
+ return stmt;
+ }
}
}
@@ -231,6 +252,7 @@ private void checkClosed() throws SQLServerException {
private static final String SS_IS_COLUMN_SET = "SS_IS_COLUMN_SET";
private static final String IS_GENERATEDCOLUMN = "IS_GENERATEDCOLUMN";
private static final String IS_AUTOINCREMENT = "IS_AUTOINCREMENT";
+ private static final String SQL_KEYWORDS = createSqlKeyWords();
/**
* Returns the result from a simple query. This is to be used only for internal queries without any user input.
@@ -243,13 +265,15 @@ private void checkClosed() throws SQLServerException {
* @throws SQLTimeoutException
*/
private SQLServerResultSet getResultSetFromInternalQueries(String catalog,
- String query) throws SQLServerException, SQLTimeoutException {
+ String query) throws SQLException, SQLTimeoutException {
checkClosed();
String orgCat = null;
orgCat = switchCatalogs(catalog);
SQLServerResultSet rs = null;
try {
- rs = ((SQLServerStatement) connection.createStatement()).executeQueryInternal(query);
+ SQLServerStatement statement = (SQLServerStatement) connection.createStatement();
+ statement.closeOnCompletion();
+ rs = statement.executeQueryInternal(query);
} finally {
if (null != orgCat) {
connection.setCatalog(orgCat);
@@ -265,15 +289,24 @@ private CallableStatement getCallableStatementHandle(CallableHandles request,
String catalog) throws SQLServerException {
CallableStatement CS = null;
HandleAssociation hassoc = handleMap.get(request);
- if (null == hassoc || null == hassoc.databaseName || !hassoc.databaseName.equals(catalog)) {
- CS = request.prepare(connection);
- hassoc = new HandleAssociation(catalog, CS);
- HandleAssociation previous = handleMap.put(request, hassoc);
- if (null != previous) {
- previous.close();
+ try {
+ if (null == hassoc) {
+ CS = request.prepare(connection);
+ hassoc = new HandleAssociation();
+ hassoc.addToMap(catalog, CS);
+ } else { // hassoc != null
+ CS = hassoc.getMappedStatement(catalog);
+ // No Cached Statement yet
+ if (null == CS || CS.isClosed()) {
+ CS = request.prepare(connection);
+ hassoc.addToMap(catalog, CS);
+ }
}
+ handleMap.put(request, hassoc);
+ } catch (SQLException e) {
+ SQLServerException.makeFromDriverError(connection, CS, e.toString(), null, false);
}
- return hassoc.stmt;
+ return CS;
}
/**
@@ -410,12 +443,12 @@ public boolean supportsSharding() throws SQLException {
}
@Override
- public java.sql.ResultSet getCatalogs() throws SQLServerException, SQLTimeoutException {
+ public java.sql.ResultSet getCatalogs() throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
checkClosed();
- // Return the orginal case instead of CAPS.removed Upper().
+ // Return the original case instead of CAPS.removed Upper().
String s = "SELECT name AS TABLE_CAT FROM sys.databases order by name"; // Need
// to
// match
@@ -531,7 +564,7 @@ private static String EscapeIDName(String inID) throws SQLServerException {
// \x -> \x where x is any char other than the ones above.
char ch;
- // Add 2 extra chars wild guess thinking atleast one escape.
+ // Add 2 extra chars wild guess thinking at least one escape.
StringBuilder outID = new StringBuilder(inID.length() + 2);
for (int i = 0; i < inID.length(); i++) {
@@ -761,7 +794,7 @@ public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, St
@Override
public java.sql.ResultSet getCrossReference(String cat1, String schem1, String tab1, String cat2, String schem2,
- String tab2) throws SQLServerException, SQLTimeoutException {
+ String tab2) throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -826,7 +859,7 @@ public String getDriverVersion() throws SQLServerException {
@Override
public java.sql.ResultSet getExportedKeys(String cat, String schema,
- String table) throws SQLServerException, SQLTimeoutException {
+ String table) throws SQLException, SQLTimeoutException {
return getCrossReference(cat, schema, table, null, null, null);
}
@@ -844,11 +877,11 @@ public String getIdentifierQuoteString() throws SQLServerException {
@Override
public java.sql.ResultSet getImportedKeys(String cat, String schema,
- String table) throws SQLServerException, SQLTimeoutException {
+ String table) throws SQLException, SQLTimeoutException {
return getCrossReference(null, null, null, cat, schema, table);
}
- private ResultSet executeSPFkeys(String[] procParams) throws SQLServerException, SQLTimeoutException {
+ private ResultSet executeSPFkeys(String[] procParams) throws SQLException, SQLTimeoutException {
String tempTableName = "@jdbc_temp_fkeys_result";
String sql = "DECLARE " + tempTableName + " table (PKTABLE_QUALIFIER sysname, " + "PKTABLE_OWNER sysname, "
+ "PKTABLE_NAME sysname, " + "PKCOLUMN_NAME sysname, " + "FKTABLE_QUALIFIER sysname, "
@@ -858,21 +891,8 @@ private ResultSet executeSPFkeys(String[] procParams) throws SQLServerException,
+ " EXEC sp_fkeys ?,?,?,?,?,?;" + "SELECT t.PKTABLE_QUALIFIER AS PKTABLE_CAT, "
+ "t.PKTABLE_OWNER AS PKTABLE_SCHEM, " + "t.PKTABLE_NAME, " + "t.PKCOLUMN_NAME, "
+ "t.FKTABLE_QUALIFIER AS FKTABLE_CAT, " + "t.FKTABLE_OWNER AS FKTABLE_SCHEM, " + "t.FKTABLE_NAME, "
- + "t.FKCOLUMN_NAME, " + "t.KEY_SEQ, " + "CASE s.update_referential_action " + "WHEN 1 THEN 0 " + // cascade
- // -
- // note
- // that
- // sp_fkey
- // and
- // sys.foreign_keys
- // have
- // flipped
- // values
- // for
- // cascade
- // and
- // no
- // action
+ + "t.FKCOLUMN_NAME, " + "t.KEY_SEQ, " + "CASE s.update_referential_action " + "WHEN 1 THEN 0 " +
+ // cascade - note that sp_fkey and sys.foreign_keys have flipped values for cascade and no action
"WHEN 0 THEN 3 " + // no action
"WHEN 2 THEN 2 " + // set null
"WHEN 3 THEN 4 " + // set default
@@ -881,6 +901,7 @@ private ResultSet executeSPFkeys(String[] procParams) throws SQLServerException,
+ "t.DEFERRABILITY " + "FROM " + tempTableName + " t "
+ "LEFT JOIN sys.foreign_keys s ON t.FK_NAME = s.name collate database_default;";
SQLServerCallableStatement cstmt = (SQLServerCallableStatement) connection.prepareCall(sql);
+ cstmt.closeOnCompletion();
for (int i = 0; i < 6; i++) {
cstmt.setString(i + 1, procParams[i]);
}
@@ -986,7 +1007,7 @@ public int getMaxColumnsInTable() throws SQLServerException {
}
@Override
- public int getMaxConnections() throws SQLServerException, SQLTimeoutException {
+ public int getMaxConnections() throws SQLException, SQLTimeoutException {
checkClosed();
try {
String s = "sp_configure 'user connections'";
@@ -1198,7 +1219,7 @@ public ResultSet getPseudoColumns(String catalog, String schemaPattern, String t
}
@Override
- public java.sql.ResultSet getSchemas() throws SQLServerException, SQLTimeoutException {
+ public java.sql.ResultSet getSchemas() throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -1208,7 +1229,7 @@ public java.sql.ResultSet getSchemas() throws SQLServerException, SQLTimeoutExce
}
private java.sql.ResultSet getSchemasInternal(String catalog,
- String schemaPattern) throws SQLServerException, SQLTimeoutException {
+ String schemaPattern) throws SQLException, SQLTimeoutException {
String s;
// The schemas that return null for catalog name, these are prebuilt
@@ -1267,10 +1288,10 @@ private java.sql.ResultSet getSchemasInternal(String catalog,
} else {
// The prepared statement is not closed after execution.
- // Yes we will "leak a server handle" per execution but the
- // connection closure will release them
- //
+ // No we will not "leak a server handle" per execution
+ // as the prepared statement will close as the resultset 'rs' is closed
SQLServerPreparedStatement ps = (SQLServerPreparedStatement) connection.prepareStatement(s);
+ ps.closeOnCompletion();
ps.setString(1, schemaPattern);
rs = (SQLServerResultSet) ps.executeQueryInternal();
}
@@ -1300,7 +1321,38 @@ public String getSearchStringEscape() throws SQLServerException {
@Override
public String getSQLKeywords() throws SQLServerException {
checkClosed();
- return "BACKUP,BREAK,BROWSE,BULK,CHECKPOINT,CLUSTERED,COMPUTE,CONTAINS,CONTAINSTABLE,DATABASE,DBCC,DENY,DISK,DISTRIBUTED,DUMMY,DUMP,ERRLVL,EXIT,FILE,FILLFACTOR,FREETEXT,FREETEXTTABLE,FUNCTION,HOLDLOCK,IDENTITY_INSERT,IDENTITYCOL,IF,KILL,LINENO,LOAD,NOCHECK,NONCLUSTERED,OFF,OFFSETS,OPENDATASOURCE,OPENQUERY,OPENROWSET,OPENXML,OVER,PERCENT,PLAN,PRINT,PROC,RAISERROR,READTEXT,RECONFIGURE,REPLICATION,RESTORE,RETURN,ROWCOUNT,ROWGUIDCOL,RULE,SAVE,SETUSER,SHUTDOWN,STATISTICS,TEXTSIZE,TOP,TRAN,TRIGGER,TRUNCATE,TSEQUAL,UPDATETEXT,USE,WAITFOR,WHILE,WRITETEXT";
+ return SQL_KEYWORDS;
+ }
+
+ private static String createSqlKeyWords() {
+ return "ADD,ALL,ALTER,AND,ANY,AS,ASC,AUTHORIZATION," +
+ "BACKUP,BEGIN,BETWEEN,BREAK,BROWSE,BULK,BY," +
+ "CASCADE,CASE,CHECK,CHECKPOINT,CLOSE,CLUSTERED,COALESCE,COLLATE,COLUMN,COMMIT," +
+ "COMPUTE,CONSTRAINT,CONTAINS,CONTAINSTABLE,CONTINUE,CONVERT,CREATE,CROSS,CURRENT," +
+ "CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR," +
+ "DATABASE,DBCC,DEALLOCATE,DECLARE,DEFAULT,DELETE,DENY,DESC,DISK," +
+ "DISTINCT,DISTRIBUTED,DOUBLE,DROP,DUMP," +
+ "ELSE,END,ERRLVL,ESCAPE,EXCEPT,EXEC,EXECUTE,EXISTS,EXIT,EXTERNAL," +
+ "FETCH,FILE,FILLFACTOR,FOR,FOREIGN,FREETEXT,FREETEXTTABLE,FROM,FULL,FUNCTION," +
+ "GOTO,GRANT,GROUP," +
+ "HAVING,HOLDLOCK," +
+ "IDENTITY,IDENTITY_INSERT,IDENTITYCOL,IF,IN,INDEX,INNER,INSERT,INTERSECT,INTO,IS," +
+ "JOIN," +
+ "KEY,KILL," +
+ "LEFT,LIKE,LINENO,LOAD," +
+ "MERGE," +
+ "NATIONAL,NOCHECK,NONCLUSTERED,NOT,NULL,NULLIF," +
+ "OF,OFF,OFFSETS,ON,OPEN,OPENDATASOURCE,OPENQUERY," +
+ "OPENROWSET,OPENXML,OPTION,OR,ORDER,OUTER,OVER," +
+ "PERCENT,PIVOT,PLAN,PRECISION,PRIMARY,PRINT,PROC,PROCEDURE,PUBLIC," +
+ "RAISERROR,READ,READTEXT,RECONFIGURE,REFERENCES,REPLICATION,RESTORE,RESTRICT," +
+ "RETURN,REVERT,REVOKE,RIGHT,ROLLBACK,ROWCOUNT,ROWGUIDCOL,RULE," +
+ "SAVE,SCHEMA,SECURITYAUDIT,SELECT,SEMANTICKEYPHRASETABLE,SEMANTICSIMILARITYDETAILSTABLE," +
+ "SEMANTICSIMILARITYTABLE,SESSION_USER,SET,SETUSER,SHUTDOWN,SOME,STATISTICS,SYSTEM_USER," +
+ "TABLE,TABLESAMPLE,TEXTSIZE,THEN,TO,TOP,TRAN,TRANSACTION,TRIGGER,TRUNCATE,TRY_CONVERT,TSEQUAL," +
+ "UNION,UNIQUE,UNPIVOT,UPDATE,UPDATETEXT,USE,USER," +
+ "VALUES,VARYING,VIEW," +
+ "WAITFOR,WHEN,WHERE,WHILE,WITH,WITHIN GROUP,WRITETEXT";
}
@Override
@@ -1342,7 +1394,7 @@ public java.sql.ResultSet getTablePrivileges(String catalog, String schema,
}
@Override
- public java.sql.ResultSet getTableTypes() throws SQLServerException, SQLTimeoutException {
+ public java.sql.ResultSet getTableTypes() throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -1359,7 +1411,7 @@ public String getTimeDateFunctions() throws SQLServerException {
}
@Override
- public java.sql.ResultSet getTypeInfo() throws SQLServerException, SQLTimeoutException {
+ public java.sql.ResultSet getTypeInfo() throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -1449,25 +1501,13 @@ public String getUserName() throws SQLServerException, SQLTimeoutException {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
checkClosed();
- SQLServerStatement s = null;
- SQLServerResultSet rs = null;
String result = "";
-
- try {
- s = (SQLServerStatement) connection.createStatement();
- rs = s.executeQueryInternal("select system_user");
+ try (SQLServerStatement s = (SQLServerStatement) connection.createStatement();
+ SQLServerResultSet rs = s.executeQueryInternal("select system_user")) {
// Select system_user will always return a row.
boolean next = rs.next();
assert next;
-
result = rs.getString(1);
- } finally {
- if (rs != null) {
- rs.close();
- }
- if (s != null) {
- s.close();
- }
}
return result;
}
@@ -2110,7 +2150,7 @@ public boolean supportsBatchUpdates() throws SQLServerException {
@Override
public java.sql.ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern,
- int[] types) throws SQLServerException, SQLTimeoutException {
+ int[] types) throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -2212,7 +2252,7 @@ public boolean supportsResultSetHoldability(int holdability) throws SQLServerExc
@Override
public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern,
- String attributeNamePattern) throws SQLServerException, SQLTimeoutException {
+ String attributeNamePattern) throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -2243,7 +2283,7 @@ public ResultSet getAttributes(String catalog, String schemaPattern, String type
@Override
public ResultSet getSuperTables(String catalog, String schemaPattern,
- String tableNamePattern) throws SQLServerException, SQLTimeoutException {
+ String tableNamePattern) throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
@@ -2257,7 +2297,7 @@ public ResultSet getSuperTables(String catalog, String schemaPattern,
@Override
public ResultSet getSuperTypes(String catalog, String schemaPattern,
- String typeNamePattern) throws SQLServerException, SQLTimeoutException {
+ String typeNamePattern) throws SQLException, SQLTimeoutException {
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
index fc3e6a424b..be19694f5e 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
@@ -126,7 +126,7 @@ private void logException(Object o, String errText, boolean bStack) {
exLogger.fine(sb.toString());
}
}
- if (errText.equals(SQLServerException.getErrString("R_queryTimedOut"))) {
+ if (SQLServerException.getErrString("R_queryTimedOut").equals(errText)) {
this.setDriverErrorCode(SQLServerException.ERROR_QUERY_TIMEOUT);
}
}
@@ -366,7 +366,7 @@ static String generateStateCode(SQLServerConnection con, int errNum, int databas
* Appends ClientConnectionId to an error message if applicable.
*
* @param errMsg
- * - the orginal error message.
+ * - the original error message.
* @param conn
* - the SQLServerConnection object
* @return error string concated by ClientConnectionId(in string format) if applicable, otherwise, return original
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
index 31b4947817..41844f8134 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
@@ -389,7 +389,7 @@ private boolean buildPreparedStrings(Parameter[] params, boolean renewDefinition
* True if renewing parameter definition, False otherwise
* @throws SQLServerException
* when an error occurs.
- * @return the required data type defintions.
+ * @return the required data type definitions.
*/
private String buildParamTypeDefinitions(Parameter[] params, boolean renewDefinition) throws SQLServerException {
StringBuilder sb = new StringBuilder();
@@ -543,7 +543,7 @@ final void doExecutePreparedStatement(PrepStmtExecCmd command) throws SQLServerE
if ((Util.shouldHonorAEForParameters(stmtColumnEncriptionSetting, connection)) && (0 < inOutParam.length)
&& !isInternalEncryptionQuery) {
- // retrieve paramater encryption metadata if they are not retrieved yet
+ // retrieve parameter encryption metadata if they are not retrieved yet
if (!encryptionMetadataIsRetrieved) {
getParameterEncryptionMetadata(inOutParam);
encryptionMetadataIsRetrieved = true;
@@ -1101,7 +1101,7 @@ private ResultSet buildExecuteMetaData() throws SQLServerException {
* The index of the parameter to set starting at 1.
* @return A reference the to Parameter object created or referenced.
* @exception SQLServerException
- * The index specified was outside the number of paramters for the statement.
+ * The index specified was outside the number of parameters for the statement.
*/
final Parameter setterGetParam(int index) throws SQLServerException {
if (index < 1 || index > inOutParam.length) {
@@ -1178,33 +1178,33 @@ public final void setAsciiStream(int parameterIndex, InputStream x, long length)
}
@Override
- public final void setBigDecimal(int paramterIndex, BigDecimal x) throws SQLServerException {
+ public final void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {paramterIndex, x});
+ loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {parameterIndex, x});
checkClosed();
- setValue(paramterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, false);
+ setValue(parameterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, false);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
@Override
- public final void setBigDecimal(int paramterIndex, BigDecimal x, int precision,
+ public final void setBigDecimal(int parameterIndex, BigDecimal x, int precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "setBigDecimal",
- new Object[] {paramterIndex, x, precision, scale});
+ new Object[] {parameterIndex, x, precision, scale});
checkClosed();
- setValue(paramterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, precision, scale, false);
+ setValue(parameterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, precision, scale, false);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
@Override
- public final void setBigDecimal(int paramterIndex, BigDecimal x, int precision, int scale,
+ public final void setBigDecimal(int parameterIndex, BigDecimal x, int precision, int scale,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "setBigDecimal",
- new Object[] {paramterIndex, x, precision, scale, forceEncrypt});
+ new Object[] {parameterIndex, x, precision, scale, forceEncrypt});
checkClosed();
- setValue(paramterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, precision, scale, forceEncrypt);
+ setValue(parameterIndex, JDBCType.DECIMAL, x, JavaType.BIGDECIMAL, precision, scale, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
@@ -2003,6 +2003,9 @@ public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQL
}
SQLServerBulkCopy bcOperation = new SQLServerBulkCopy(connection);
+ SQLServerBulkCopyOptions option = new SQLServerBulkCopyOptions();
+ option.setBulkCopyTimeout(queryTimeout);
+ bcOperation.setBulkCopyOptions(option);
bcOperation.setDestinationTableName(tableName);
bcOperation.setStmtColumnEncriptionSetting(this.getStmtColumnEncriptionSetting());
bcOperation.setDestinationTableMetadata(rs);
@@ -2157,6 +2160,9 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio
}
SQLServerBulkCopy bcOperation = new SQLServerBulkCopy(connection);
+ SQLServerBulkCopyOptions option = new SQLServerBulkCopyOptions();
+ option.setBulkCopyTimeout(queryTimeout);
+ bcOperation.setBulkCopyOptions(option);
bcOperation.setDestinationTableName(tableName);
bcOperation.setStmtColumnEncriptionSetting(this.getStmtColumnEncriptionSetting());
bcOperation.setDestinationTableMetadata(rs);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
index 612c44ab33..e163219e80 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
@@ -793,7 +793,7 @@ public boolean relative(int rows) throws SQLException {
checkClosed();
// From JDBC spec:
- // Throws SQLException if (1) there is no curent row or (2)
+ // Throws SQLException if (1) there is no current row or (2)
// the type of this ResultSet object is TYPE_FORWARD_ONLY.
verifyResultSetIsScrollable();
verifyResultSetHasCurrentRow();
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
index c2c269053d..d0ae5e25b5 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
@@ -439,7 +439,7 @@ boolean onDone(TDSReader tdsReader) throws SQLServerException {
int nFetchDirection;
/**
- * True is the statment is closed
+ * True is the statement is closed
*/
boolean bIsClosed;
@@ -948,7 +948,7 @@ final void resetForReexecute() throws SQLServerException {
* Determines if the SQL is a SELECT.
*
* @param sql
- * The statment SQL.
+ * The statement SQL.
* @return True if the statement is a select.
*/
final boolean isSelect(String sql) throws SQLServerException {
@@ -966,7 +966,7 @@ final boolean isSelect(String sql) throws SQLServerException {
* Determine if the SQL is a INSERT.
*
* @param sql
- * The statment SQL.
+ * The statement SQL.
* @return True if the statement is an insert.
*/
final boolean isInsert(String sql) throws SQLServerException {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java
index 8d314b08e9..1b60a9feef 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java
@@ -34,7 +34,7 @@ void applyTo(Column[] columns, int numTables) throws SQLServerException {
// Read in all of the multi-part table names. The number of table
// names to expect is determined in advance. It is computed as a side
- // effect of processing the COLINFO token that preceeds this TABNAME token.
+ // effect of processing the COLINFO token that preceds this TABNAME token.
SQLIdentifier[] tableNames = new SQLIdentifier[numTables];
for (int i = 0; i < numTables; i++)
tableNames[i] = tdsReader.readSQLIdentifier();
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java
index a9557c2c78..92bf03d6c1 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java
@@ -431,7 +431,7 @@ else if ((-1 != rightQuote.indexOf(testchar)) || (-1 != leftQuote.indexOf(testch
}
/*
- * parsing the multipart identifer string. paramaters: name - string to parse leftquote: set of characters which are
+ * parsing the multipart identifer string. parameters: name - string to parse leftquote: set of characters which are
* valid quoteing characters to initiate a quote rightquote: set of characters which are valid to stop a quote,
* array index's correspond to the the leftquote array. separator: separator to use limit: number of names to parse
* out removequote:to remove the quotes on the returned string
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityProperty.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityProperty.java
index 1c8846deb5..d4024a9fcb 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityProperty.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityProperty.java
@@ -18,7 +18,7 @@ public class SensitivityProperty {
* @param label
* Label as received from SQL Server for this SensitivityProperty
* @param informationType
- * InformationType as recieved from SQL Server for this SensitivityProperty
+ * InformationType as received from SQL Server for this SensitivityProperty
*/
public SensitivityProperty(Label label, InformationType informationType) {
this.label = label;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dns/DNSKerberosLocator.java b/src/main/java/com/microsoft/sqlserver/jdbc/dns/DNSKerberosLocator.java
index 11e85ebd80..cdcdbb5359 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/dns/DNSKerberosLocator.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/dns/DNSKerberosLocator.java
@@ -9,7 +9,6 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-
/**
* Represents a DNS Kerberos Locator
*/
@@ -18,7 +17,9 @@ public final class DNSKerberosLocator {
private DNSKerberosLocator() {}
/**
- * Returns whether a realm is valid.
+ * Returns whether a realm is valid by retrieving the KDC list in DNS SRV records.
+ * This will only work if DNS lookup is setup properly or the realms are properly defined in krb5 config file.
+ * Otherwise this will fail since the realm cannot be found.
*
* @param realmName
* the realm to test
@@ -37,6 +38,7 @@ public static boolean isRealmValid(String realmName) throws NamingException {
Set records = DNSUtilities.findSrvRecords("_kerberos._udp." + realmName);
return !records.isEmpty();
} catch (NameNotFoundException wrongDomainException) {
+ // config error - domain controller cannot be located via DNS
return false;
}
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
index ae3693af54..657cb7e798 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
@@ -19,6 +19,7 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.SQLException;
@@ -2193,11 +2194,7 @@ void execute(DTV dtv, InputStream inputStreamValue) throws SQLServerException {
// If the stream is to be sent as Unicode, then assume it's an ASCII stream
if (JDBCType.NCHAR == jdbcType || JDBCType.NVARCHAR == jdbcType || JDBCType.LONGNVARCHAR == jdbcType) {
Reader readerValue = null;
- try {
- readerValue = new InputStreamReader(inputStreamValue, "US-ASCII");
- } catch (UnsupportedEncodingException ex) {
- throw new SQLServerException(ex.getMessage(), null, 0, ex);
- }
+ readerValue = new InputStreamReader(inputStreamValue, StandardCharsets.US_ASCII);
dtv.setValue(readerValue, JavaType.READER);
diff --git a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
index ba48e21cdb..87ccd10d34 100644
--- a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
+++ b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
@@ -15,12 +15,12 @@
*/
package mssql.googlecode.concurrentlinkedhashmap;
-import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.IDLE;
-import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.PROCESSING;
-import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.REQUIRED;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
+import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.IDLE;
+import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.PROCESSING;
+import static mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.REQUIRED;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
diff --git a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Weighers.java b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Weighers.java
index 469977a11d..b6de5f12b7 100644
--- a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Weighers.java
+++ b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Weighers.java
@@ -19,7 +19,6 @@
import java.io.Serializable;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
diff --git a/src/samples/README.md b/src/samples/README.md
index 444d5086a4..c06c9ab8c9 100644
--- a/src/samples/README.md
+++ b/src/samples/README.md
@@ -25,7 +25,7 @@ The following samples are available:
5. datatypes
* **BasicDataTypes** - Demonstrates how to retrieve and update basic SQL Server data type values.
* **SqlXmlDataType** - Demonstrates how to store and retrieve XML data as well as how to parse XML data with the SQLXML Java data type.
- * **SpatialDatatypes** - Demonstrates how to store and retreive Spatial Data as well how to parse data using `Geometry` and `Geography` Java types defined by Microsoft JDBC Driver.
+ * **SpatialDatatypes** - Demonstrates how to store and retrieve Spatial Data as well how to parse data using `Geometry` and `Geography` Java types defined by Microsoft JDBC Driver.
6. resultsets
* **CacheRS** - Demonstrates how to retrieve a large set of data and control the amount of data that is fetched and cached on the client
diff --git a/src/samples/constrained/src/main/java/ConstrainedDelegation.java b/src/samples/constrained/src/main/java/ConstrainedDelegation.java
index 11f39b611e..3e952f86bc 100644
--- a/src/samples/constrained/src/main/java/ConstrainedDelegation.java
+++ b/src/samples/constrained/src/main/java/ConstrainedDelegation.java
@@ -74,7 +74,7 @@ public static void main(String... args) throws Exception {
// Create a connection for target service thanks S4U2proxy mechanism
try (Connection con = createConnection(impersonatedUserCreds)) {
- System.out.println("Connection succesfully: " + con);
+ System.out.println("Connection successfully: " + con);
}
}
diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
index 3f330857b8..2a5fd18fcc 100644
--- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
+++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
@@ -1,6 +1,6 @@
/*
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
- * available under the terms of the MIT License. See the LICENSE file in the project root for more information.
+ * available under the terms of the MIT License. See the LICENSE file in the project root for more AEInformation.
*/
package com.microsoft.sqlserver.jdbc.AlwaysEncrypted;
@@ -20,6 +20,7 @@
import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.Properties;
+import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -28,6 +29,7 @@
import org.opentest4j.TestAbortedException;
import com.microsoft.sqlserver.jdbc.RandomData;
+import com.microsoft.sqlserver.jdbc.RandomUtil;
import com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionJavaKeyStoreProvider;
import com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionKeyStoreProvider;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
@@ -36,6 +38,7 @@
import com.microsoft.sqlserver.jdbc.SQLServerStatementColumnEncryptionSetting;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.jdbc.TestUtils;
+import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.DBConnection;
@@ -57,23 +60,25 @@ public class AESetup extends AbstractTest {
static final String cmkName = "JDBC_CMK";
static final String cekName = "JDBC_CEK";
static final String secretstrJks = "password";
- static final String charTable = "JDBCEncryptedCharTable";
- static final String binaryTable = "JDBCEncryptedBinaryTable";
- static final String dateTable = "JDBCEncryptedDateTable";
- static final String numericTable = "JDBCEncryptedNumericTable";
- static final String scaleDateTable = "JDBCEncryptedScaleDateTable";
- static final String uid = "171fbe25-4331-4765-a838-b2e3eea3e7ea";
+ static String charTable = RandomUtil.getIdentifier("JDBCEncryptedChar");
+ static String binaryTable = RandomUtil.getIdentifier("JDBCEncryptedBinary");
+ static String dateTable = RandomUtil.getIdentifier("JDBCEncryptedDate");
+ static String numericTable = RandomUtil.getIdentifier("JDBCEncryptedNumeric");
+ static String scaleDateTable = RandomUtil.getIdentifier("JDBCEncryptedScaleDate");
+
+ static final String uid = UUID.randomUUID().toString();
static String filePath = null;
static String thumbprint = null;
- static SQLServerConnection con = null;
- static SQLServerStatement stmt = null;
static String keyPath = null;
static String javaKeyAliases = null;
static String OS = System.getProperty("os.name").toLowerCase();
static SQLServerColumnEncryptionKeyStoreProvider storeProvider = null;
static SQLServerStatementColumnEncryptionSetting stmtColEncSetting = null;
+ static String AETestConnectionString;
+
+ static Properties AEInfo;
/**
* Create connection, statement and generate path of resource file
@@ -87,9 +92,8 @@ public static void setUpConnection() throws TestAbortedException, Exception {
assumeTrue(13 <= con.getServerVersion(), TestResource.getResource("R_Incompat_SQLServerVersion"));
}
- String AETestConnectionString = connectionString + ";sendTimeAsDateTime=false";
+ AETestConnectionString = connectionString + ";sendTimeAsDateTime=false";
readFromFile(javaKeyStoreInputFile, "Alias name");
-
try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString);
SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
dropCEK(stmt);
@@ -100,14 +104,12 @@ public static void setUpConnection() throws TestAbortedException, Exception {
storeProvider = new SQLServerColumnEncryptionJavaKeyStoreProvider(keyPath, secretstrJks.toCharArray());
stmtColEncSetting = SQLServerStatementColumnEncryptionSetting.Enabled;
- Properties info = new Properties();
- info.setProperty("ColumnEncryptionSetting", "Enabled");
- info.setProperty("keyStoreAuthentication", "JavaKeyStorePassword");
- info.setProperty("keyStoreLocation", keyPath);
- info.setProperty("keyStoreSecret", secretstrJks);
+ AEInfo = new Properties();
+ AEInfo.setProperty("ColumnEncryptionSetting", "Enabled");
+ AEInfo.setProperty("keyStoreAuthentication", "JavaKeyStorePassword");
+ AEInfo.setProperty("keyStoreLocation", keyPath);
+ AEInfo.setProperty("keyStoreSecret", secretstrJks);
- con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString, info);
- stmt = (SQLServerStatement) con.createStatement();
createCMK(keyStoreName, javaKeyAliases);
createCEK(storeProvider);
}
@@ -119,11 +121,17 @@ public static void setUpConnection() throws TestAbortedException, Exception {
* @throws SQLException
*/
@AfterAll
- public static void dropAll() throws SQLException {
- dropTables(stmt);
- dropCEK(stmt);
- dropCMK(stmt);
- TestUtils.close(null, stmt, con);
+ public static void dropAll() throws Exception {
+ try (DBConnection con = new DBConnection(connectionString)) {
+ assumeTrue(13 <= con.getServerVersion(), TestResource.getResource("R_Incompat_SQLServerVersion"));
+ }
+
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(connectionString);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ dropTables(stmt);
+ dropCEK(stmt);
+ dropCMK(stmt);
+ }
}
/**
@@ -162,7 +170,8 @@ private static void readFromFile(String inputFile, String lookupValue) throws IO
* @throws SQLException
*/
protected static void createBinaryTable() throws SQLException {
- String sql = "create table " + binaryTable + " (" + "PlainBinary binary(20) null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(binaryTable) + " ("
+ + "PlainBinary binary(20) null,"
+ "RandomizedBinary binary(20) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
+ cekName + ") NULL,"
+ "DeterministicBinary binary(20) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -194,7 +203,8 @@ protected static void createBinaryTable() throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -208,7 +218,8 @@ protected static void createBinaryTable() throws SQLException {
* @throws SQLException
*/
protected static void createCharTable() throws SQLException {
- String sql = "create table " + charTable + " (" + "PlainChar char(20) null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(charTable) + " ("
+ + "PlainChar char(20) null,"
+ "RandomizedChar char(20) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
+ cekName + ") NULL,"
+ "DeterministicChar char(20) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -264,7 +275,8 @@ protected static void createCharTable() throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -278,7 +290,7 @@ protected static void createCharTable() throws SQLException {
* @throws SQLException
*/
protected void createDateTable() throws SQLException {
- String sql = "create table " + dateTable + " (" + "PlainDate date null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(dateTable) + " (" + "PlainDate date null,"
+ "RandomizedDate date ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
+ cekName + ") NULL,"
+ "DeterministicDate date ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -316,7 +328,8 @@ protected void createDateTable() throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -330,7 +343,7 @@ protected void createDateTable() throws SQLException {
* @throws SQLException
*/
protected void createDatePrecisionTable(int scale) throws SQLException {
- String sql = "create table " + dateTable + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(dateTable) + " ("
// 1
+ "PlainDatetime2 datetime2(" + scale + ") null," + "RandomizedDatetime2 datetime2(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -376,7 +389,8 @@ protected void createDatePrecisionTable(int scale) throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -390,7 +404,7 @@ protected void createDatePrecisionTable(int scale) throws SQLException {
* @throws SQLException
*/
protected static void createDateScaleTable() throws SQLException {
- String sql = "create table " + scaleDateTable + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(scaleDateTable) + " ("
+ "PlainDatetime2 datetime2(2) null,"
+ "RandomizedDatetime2 datetime2(2) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -412,7 +426,8 @@ protected static void createDateScaleTable() throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -426,7 +441,7 @@ protected static void createDateScaleTable() throws SQLException {
* @throws SQLException
*/
protected static void createNumericTable() throws SQLException {
- String sql = "create table " + numericTable + " (" + "PlainBit bit null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(numericTable) + " (" + "PlainBit bit null,"
+ "RandomizedBit bit ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
+ cekName + ") NULL,"
+ "DeterministicBit bit ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -524,7 +539,8 @@ protected static void createNumericTable() throws SQLException {
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -538,8 +554,8 @@ protected static void createNumericTable() throws SQLException {
* @throws SQLException
*/
protected void createNumericPrecisionTable(int floatPrecision, int precision, int scale) throws SQLException {
- String sql = "create table " + numericTable + " (" + "PlainFloat float(" + floatPrecision + ") null,"
- + "RandomizedFloat float(" + floatPrecision
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(numericTable) + " (" + "PlainFloat float("
+ + floatPrecision + ") null," + "RandomizedFloat float(" + floatPrecision
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
+ cekName + ") NULL," + "DeterministicFloat float(" + floatPrecision
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
@@ -561,7 +577,8 @@ protected void createNumericPrecisionTable(int floatPrecision, int precision, in
+ ");";
- try {
+ try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
+ AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
@@ -684,7 +701,7 @@ protected static LinkedList