diff --git a/.gitattributes b/.gitattributes
index eb5d746827..0abcfbee4a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,33 +1,2 @@
# Auto detect text files and perform LF normalization
-* text=auto
-
-#
-# The above will handle all files NOT found below
-#
-# These files are text and should be normalized (Convert crlf => lf)
-*.css text
-*.md text
-*.htm text
-*.html text
-*.java text
-*.js text
-*.json text
-*.properties text
-*.sh text
-*.svg text
-*.txt text
-*.xml text
-
-# These files are binary and should be left untouched
-# (binary is a macro for -text -diff)
-*.class binary
-*.dll binary
-*.ear binary
-*.gif binary
-*.ico binary
-*.jar binary
-*.jpg binary
-*.jpeg binary
-*.png binary
-*.so binary
-*.war binary
+* -text
diff --git a/.travis.yml b/.travis.yml
index a9a2d8f11b..1a4299131d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,13 +2,8 @@
language: java
jdk:
- - oraclejdk9
+ - oraclejdk10
-addons:
- apt:
- packages:
- - oracle-java9-installer
-
services:
- docker
@@ -45,5 +40,5 @@ script:
- docker ps -a
##Test for JDBC Specification 43 & 42 and submit coverage report.
- - mvn test -B -Pbuild41 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43
+ - mvn test -B -Pbuild43 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43
- mvn test -B -Pbuild42 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC42
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e5ed71e15..700f4a6e4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,9 +3,55 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
+## [6.5.4] Preview Release
+### Added
+- Added new connection property "useBulkCopyForBatchInsert" to enable Bulk Copy API support for batch insert operation [#686](https://github.com/Microsoft/mssql-jdbc/pull/686)
+- Added implementation for Java 9 introduced Boundary methods APIs on Connection interface [#708](https://github.com/Microsoft/mssql-jdbc/pull/708)
+- Added support for "Data Classification Specifications" on fetched resultsets [#709](https://github.com/Microsoft/mssql-jdbc/pull/709)
+- Added support for UTF-8 feature extension [#722](https://github.com/Microsoft/mssql-jdbc/pull/722)
+
+### Fixed Issues
+- Fixed issue with escaping catalog name when retrieving from database metadata [#718](https://github.com/Microsoft/mssql-jdbc/pull/718)
+- Fixed issue with tests requiring additional dependencies [#729](https://github.com/Microsoft/mssql-jdbc/pull/729)
+
+### Changed
+- Made driver default compliant to JDBC 4.2 specifications [#711](https://github.com/Microsoft/mssql-jdbc/pull/711)
+- Updated ADAL4J dependency version to 1.6.0 [#711](https://github.com/Microsoft/mssql-jdbc/pull/711)
+- Cleaned up socket handling implementation to generalize functionality for different JVMs and simplified the logic for single address case [#663](https://github.com/Microsoft/mssql-jdbc/pull/663)
+
+## [6.5.3] Preview Release
+### 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)
+
+### Fixed Issues
+- Fixed the driver disposing user created credentials when using Kerberos Constrained Delegation [#636](https://github.com/Microsoft/mssql-jdbc/pull/636)
+- Fixed an issue with HostnameInCertificate when redirected while connected to Azure [#644](https://github.com/Microsoft/mssql-jdbc/pull/644)
+- Fixed an intermittent issue with Prepared Statement handle not found [#648](https://github.com/Microsoft/mssql-jdbc/pull/648)
+- Fixed a conflict with JDBC Compliance where the driver was returning marked columns as SS_IS_COMPUTED instead of IS_GENERATED [#695](https://github.com/Microsoft/mssql-jdbc/pull/695)
+- Fixed maven build warnings and deprecated Java API warnings [#701](https://github.com/Microsoft/mssql-jdbc/pull/701)
+- Fixed some Javadoc related warnings [#702](https://github.com/Microsoft/mssql-jdbc/pull/702)
+
+## [6.5.2] Preview Release
+### Added
+- Added new connection property "cancelQueryTimeout" to cancel QueryTimeout on Connection and Statement [#674](https://github.com/Microsoft/mssql-jdbc/pull/674)
+
+### Fixed Issues
+- Improved performance degradation while maintaining JDBC compliance with results from sp_fkeys [#677](https://github.com/Microsoft/mssql-jdbc/pull/677)
+- Fixed an issue where ResultSetMetaData instances created by a ResultSet that has been closed were not persisting [#685](https://github.com/Microsoft/mssql-jdbc/pull/685)
+- Fixed an issue with PreparedStatement.setBigDecimal when no scale is passed [#684](https://github.com/Microsoft/mssql-jdbc/pull/684)
+- Fixed an issue with Clobs/NClobs not persisting after ResultSet/Connection closes [#682](https://github.com/Microsoft/mssql-jdbc/pull/682)
+
+### Changed
+- Updated the samples to be usable with Eclipse directly, and updated the driver version used by the samples to 6.4.0.jre9 [#679](https://github.com/Microsoft/mssql-jdbc/pull/679)
+- Updated Gradle script for building JDBC Driver [#689](https://github.com/Microsoft/mssql-jdbc/pull/689)
+- Updated Maven dependencies for test suite [#676](https://github.com/Microsoft/mssql-jdbc/pull/676)
+- Updated multiple Maven dependency and plugin versions [#688](https://github.com/Microsoft/mssql-jdbc/pull/688)
+
## [6.5.1] Preview Release
### Added
-- Test cases for Date, Time, and Datetime2 data types. [#558](https://github.com/Microsoft/mssql-jdbc/pull/558)
+- Test cases for Date, Time, and Datetime2 data types [#558](https://github.com/Microsoft/mssql-jdbc/pull/558)
### Fixed Issues
- Fixed an issue where ResultSetMetadata returned incorrect columnType for Geometry and Geography data types [#657](https://github.com/Microsoft/mssql-jdbc/pull/657)
@@ -63,7 +109,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
## [6.3.4] Preview Release
### Added
-- Added new ThreadGroup creation to prevent IllegalThreadStateException if the underlying ThreadGroup has been destroyed. [#474](https://github.com/Microsoft/mssql-jdbc/pull/474)
+- Added new ThreadGroup creation to prevent IllegalThreadStateException if the underlying ThreadGroup has been destroyed [#474](https://github.com/Microsoft/mssql-jdbc/pull/474)
- Added try-with-resources to JUnit tests [#520](https://github.com/Microsoft/mssql-jdbc/pull/520)
### Fixed Issues
diff --git a/README.md b/README.md
index ac50054b5a..ece0f92773 100644
--- a/README.md
+++ b/README.md
@@ -36,14 +36,14 @@ What's coming next? We will look into adding a more comprehensive set of tests,
## Build
### Prerequisites
-* Java 9
+* Java 10
* [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 9 with Maven. You can choose to build a JDBC 4.3 compliant jar file (for use with JRE 9) and/or a JDBC 4.2 compliant jar file (for use with JRE 8).
+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).
* 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.
@@ -51,13 +51,11 @@ To build the jar files, you must use Java 9 with Maven. You can choose to build
* 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
-**NOTE**: Beginning release v6.1.7, we will no longer be maintaining the existing [Gradle build script](build.gradle) and it will be left in the repository for reference. Please refer to issue [#62](https://github.com/Microsoft/mssql-jdbc/issues/62) for this decision.
-
* 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.1 compliant jar or JDBC 4.2 compliant jar in the \build\libs directory.
- * Run `gradle build -Pbuild=build41`. This creates JDBC 4.1 compliant jar in \build\libs directory
- * Run `gradle build -Pbuild=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
@@ -90,7 +88,7 @@ To get the latest preview version of the driver, add the following to your POM f
com.microsoft.sqlservermssql-jdbc
- 6.5.1.jre9-preview
+ 6.5.4.jre10-preview
```
@@ -120,14 +118,14 @@ Projects that require either of the two features need to explicitly declare the
com.microsoft.sqlservermssql-jdbc
- 6.5.1.jre9-preview
+ 6.5.4.jre10-previewcompilecom.microsoft.azureadal4j
- 1.4.0
+ 1.6.0
```
@@ -136,14 +134,14 @@ Projects that require either of the two features need to explicitly declare the
com.microsoft.sqlservermssql-jdbc
- 6.5.1.jre9-preview
+ 6.5.4.jre10-previewcompilecom.microsoft.azureadal4j
- 1.4.0
+ 1.6.0
diff --git a/appveyor.yml b/appveyor.yml
index 5fff6778cd..6ab08769cd 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -4,12 +4,11 @@ init:
- cmd: net start MSSQL$%SQL_Instance%
environment:
- JAVA_HOME: C:\Program Files\Java\jdk9
+ JAVA_HOME: C:\Program Files\Java\jdk10
mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=%SQL_Instance%;databaseName=master;username=sa;password=Password12!;
-
matrix:
- SQL_Instance: SQL2008R2SP2
- - SQL_Instance: SQL2016
+ - SQL_Instance: SQL2017
install:
- ps: Write-Host 'Installing JCE with powershell'
@@ -29,7 +28,7 @@ cache:
- C:\Users\appveyor\.m2 -> pom.xml
build_script:
- - keytool -importkeystore -srckeystore cert.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS -srcstorepass password -deststorepass password
+ - 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
diff --git a/build.gradle b/build.gradle
index 5cc29b949c..d6955d5c3d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,36 +1,49 @@
+/****************************************************************
+ * Gradle Scipt for Building Microsoft JDBC Driver for SQL Server
+ ****************************************************************
+ * Instruction for Building JDBC Driver:
+ * For building jre9 version of the driver,
+ * use command 'gradle build' or 'gradle build -PbuildProfile=build43'
+ * Whereas, for building jre8 version of the driver,
+ * use command 'gradle build -PbuildProfile=build42'
+ ****************************************************************/
+
apply plugin: 'java'
-archivesBaseName = 'mssql-jdbc'
-version = '6.1.6'
+version = '6.5.4'
+def jreVersion = ""
+def testOutputDir = file("build/classes/java/test")
+def archivesBaseName = 'mssql-jdbc'
+def excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'
allprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
-
tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
}
}
-def excludedFile = ''
-
-if(build == "build41") {
- jar.archiveName = "${archivesBaseName}-${version}.jre7.jar"
+if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "build43")){
+
+ jreVersion = "jre10"
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'
- sourceCompatibility = 1.7
- targetCompatibility = 1.7
+ sourceCompatibility = 10
+ targetCompatibility = 10
}
-if(build == "build42") {
- jar.archiveName = "${archivesBaseName}-${version}.jre8.jar"
- excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java'
+if((hasProperty('buildProfile') && buildProfile == "build42")) {
+
+ jreVersion = "jre8"
+ excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc43.java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
+jar.archiveName = "${archivesBaseName}-${version}.${jreVersion}-preview.jar"
jar {
manifest {
attributes 'Title': "Microsoft JDBC Driver ${version} for SQL Server",
@@ -45,7 +58,6 @@ sourceSets {
srcDirs 'src/main/java'
exclude excludedFile
}
-
resources {
srcDirs "$projectDir"
include 'META-INF/services/java.sql.Driver'
@@ -55,7 +67,7 @@ sourceSets {
resources {
srcDirs 'src/test/resources'
include '**/*.csv'
- output.resourcesDir = output.classesDir
+ output.resourcesDir = testOutputDir
}
}
}
@@ -67,17 +79,16 @@ repositories {
dependencies {
compile 'com.microsoft.azure:azure-keyvault:1.0.0',
- 'com.microsoft.azure:adal4j:1.1.3'
-
+ 'com.microsoft.azure:adal4j:1.6.0'
testCompile 'junit:junit:4.12',
- 'org.junit.platform:junit-platform-console:1.0.0-M3',
- 'org.junit.platform:junit-platform-commons:1.0.0-M3',
- 'org.junit.platform:junit-platform-engine:1.0.0-M3',
- 'org.junit.platform:junit-platform-launcher:1.0.0-M3',
- 'org.junit.platform:junit-platform-runner:1.0.0-M3',
- 'org.junit.platform:junit-platform-surefire-provider:1.0.0-M3',
- 'org.junit.jupiter:junit-jupiter-api:5.0.0-M3',
- 'org.junit.jupiter:junit-jupiter-engine:5.0.0-M3',
- 'com.zaxxer:HikariCP:2.6.0',
- 'org.apache.commons:commons-dbcp2:2.1.1'
+ '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',
+ 'com.zaxxer:HikariCP:3.1.0',
+ 'org.apache.commons:commons-dbcp2:2.0'
}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c05cda7cbb..8546b7cb80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,47 +1,48 @@
-4.0.0
-
+
com.microsoft.sqlservermssql-jdbc
- 6.5.2-SNAPSHOT.${jreVersion}-preview
+ 6.5.4jar
-
+
Microsoft JDBC Driver for SQL Server
Microsoft JDBC Driver for SQL Server.
https://github.com/Microsoft/mssql-jdbc
-
+
MIT Licensehttp://www.opensource.org/licenses/mit-license.php
-
+
Microsoft Corporation
-
+
Microsofthttp://www.microsoft.com
-
+
https://github.com/Microsoft/mssql-jdbcUTF-8
- 1.1.0
- 5.1.0
+ 1.2.0
+ 5.2.0
-
+
com.microsoft.azure
@@ -49,15 +50,15 @@
1.0.0true
-
+
com.microsoft.azureadal4j
- 1.4.0
+ 1.6.0true
-
-
+
+
junitjunit
@@ -116,7 +117,7 @@
com.zaxxerHikariCP
- 2.7.8
+ 3.1.0test
@@ -125,25 +126,13 @@
2.2.0test
-
build42
-
-
- jre8
-
-
+ ${project.artifactId}-${project.version}.jre8-previewmaven-compiler-plugin
@@ -169,18 +158,14 @@
-
+
build43true
-
-
- jre9
-
-
+ ${project.artifactId}-${project.version}.jre10-previewmaven-compiler-plugin
@@ -189,8 +174,8 @@
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java
- 9
- 9
+ 10
+ 10
@@ -235,7 +220,7 @@
-
+
@@ -251,13 +236,14 @@
-
+
org.jacocojacoco-maven-plugin
- 0.7.8
+ 0.8.1
+ pre-testprepare-agent
@@ -272,58 +258,58 @@
-
- org.apache.felix
- maven-bundle-plugin
- 3.3.0
- true
-
-
- com.microsoft.sqlserver.jdbc,microsoft.sql
- !microsoft.sql,*
-
-
-
-
- bundle-manifest
- process-classes
-
- manifest
-
-
-
-
-
+
+ org.apache.felix
+ maven-bundle-plugin
+ 3.5.0
+ true
+
+
+ com.microsoft.sqlserver.jdbc,microsoft.sql
+ !microsoft.sql,*
+
+
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
org.apache.maven.plugins
- maven-javadoc-plugin
- 3.0.0-M1
-
-
- true
-
-
-
-
- attach-javadocs
-
- jar
-
-
-
-
+ maven-javadoc-plugin
+ 3.0.0
+
+
+ true
+
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+ org.apache.maven.pluginsmaven-surefire-plugin
- 2.19
+ 2.21.0${skipTestTag}
-
+
org.junit.platform
@@ -336,14 +322,15 @@
org.codehaus.mojoversions-maven-plugin
+ 2.5trueoutdated-dependencies.txtfile:///${session.executionRootDirectory}/maven-version-rules.xml
-
-
+
+
-
+
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
index 0790a06912..8726cb0013 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
@@ -15,8 +15,15 @@ public class Geography extends SQLServerSpatialDatatype {
/**
* Private constructor used for creating a Geography object from WKT and srid.
+ *
+ * @param WellKnownText
+ * Well-Known Text (WKT) provided by the user.
+ * @param srid
+ * Spatial Reference Identifier (SRID) provided by the user.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- private Geography(String WellKnownText, int srid) {
+ private Geography(String WellKnownText, int srid) throws SQLServerException {
this.wkt = WellKnownText;
this.srid = srid;
@@ -24,7 +31,8 @@ private Geography(String WellKnownText, int srid) {
parseWKTForSerialization(this, currentWktPos, -1, false);
}
catch (StringIndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid.");
+ String strError = SQLServerException.getErrString("R_illegalWKT");
+ throw new SQLServerException(strError, null, 0, null);
}
serializeToWkb(false);
@@ -33,8 +41,13 @@ private Geography(String WellKnownText, int srid) {
/**
* Private constructor used for creating a Geography object from WKB.
+ *
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- private Geography(byte[] wkb) {
+ private Geography(byte[] wkb) throws SQLServerException {
this.wkb = wkb;
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -51,19 +64,20 @@ private Geography(byte[] wkb) {
isNull = false;
}
- public Geography() {
- // TODO Auto-generated constructor stub
- }
-
/**
* Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT)
* representation augmented with any Z (elevation) and M (measure) values carried by the instance.
*
- * @param wkt WKT
- * @param srid SRID
- * @return Geography instance
+ * @param wkt
+ * Well-Known Text (WKT) provided by the user.
+ * @param srid
+ * Spatial Reference Identifier (SRID) provided by the user.
+ * @return Geography
+ * Geography instance created from WKT and SRID
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geography STGeomFromText(String wkt, int srid) {
+ public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException {
return new Geography(wkt, srid);
}
@@ -71,20 +85,28 @@ public static Geography STGeomFromText(String wkt, int srid) {
* Returns a Geography instance from an Open Geospatial Consortium (OGC)
* Well-Known Binary (WKB) representation.
*
- * @param wkb WKB
- * @return Geography instance
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @return Geography
+ * Geography instance created from WKB
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geography STGeomFromWKB(byte[] wkb) {
+ public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException {
return new Geography(wkb);
}
/**
* Returns a constructed Geography from an internal SQL Server format for spatial data.
*
- * @param wkb WKB
- * @return Geography instance
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @return Geography
+ * Geography instance created from WKB
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geography deserialize(byte[] wkb) {
+ public static Geography deserialize(byte[] wkb) throws SQLServerException {
return new Geography(wkb);
}
@@ -92,22 +114,32 @@ public static Geography deserialize(byte[] wkb) {
* Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
* SRID is defaulted to 4326.
*
- * @param wkt WKt
- * @return Geography instance
+ * @param wkt
+ * Well-Known Text (WKT) provided by the user.
+ * @return Geography
+ * Geography instance created from WKT
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geography parse(String wkt) {
+ public static Geography parse(String wkt) throws SQLServerException {
return new Geography(wkt, 4326);
}
/**
* Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID.
*
- * @param x x coordinate
- * @param y y coordinate
- * @param srid SRID
- * @return Geography instance
+ * @param x
+ * x coordinate
+ * @param y
+ * y coordinate
+ * @param srid
+ * SRID
+ * @return Geography
+ * Geography instance
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geography point(double x, double y, int srid) {
+ public static Geography point(double x, double y, int srid) throws SQLServerException {
return new Geography("POINT (" + x + " " + y + ")", srid);
}
@@ -115,9 +147,12 @@ public static Geography point(double x, double y, int srid) {
* Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a
* Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance.
*
- * @return the WKT representation without the Z and M values.
+ * @return
+ * the WKT representation without the Z and M values.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public String STAsText() {
+ public String STAsText() throws SQLServerException {
if (null == wktNoZM) {
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -135,7 +170,8 @@ public String STAsText() {
/**
* Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a
* Geography instance. This value will not contain any Z or M values carried by the instance.
- * @return WKB
+ *
+ * @return byte array representation of the Geography object.
*/
public byte[] STAsBinary() {
if (null == wkbNoZM) {
@@ -147,20 +183,35 @@ public byte[] STAsBinary() {
/**
* Returns the bytes that represent an internal SQL Server format of Geography type.
*
- * @return WKB
+ * @return byte array representation of the Geography object.
*/
public byte[] serialize() {
return wkb;
}
+ /**
+ * Returns if the object contains a M (measure) value.
+ *
+ * @return boolean that indicates if the object contains M value.
+ */
public boolean hasM() {
return hasMvalues;
}
+ /**
+ * Returns if the object contains a Z (elevation) value.
+ *
+ * @return boolean that indicates if the object contains Z value.
+ */
public boolean hasZ() {
return hasZvalues;
}
+ /**
+ * Returns the X coordinate value.
+ *
+ * @return double value that represents the X coordinate.
+ */
public Double getX() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[0];
@@ -168,6 +219,11 @@ public Double getX() {
return null;
}
+ /**
+ * Returns the Y coordinate value.
+ *
+ * @return double value that represents the Y coordinate.
+ */
public Double getY() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[1];
@@ -175,6 +231,11 @@ public Double getY() {
return null;
}
+ /**
+ * Returns the M (measure) value of the object.
+ *
+ * @return double value that represents the M value.
+ */
public Double getM() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) {
return mValues[0];
@@ -182,6 +243,11 @@ public Double getM() {
return null;
}
+ /**
+ * Returns the Z (elevation) value of the object.
+ *
+ * @return double value that represents the Z value.
+ */
public Double getZ() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) {
return zValues[0];
@@ -189,14 +255,29 @@ public Double getZ() {
return null;
}
+ /**
+ * Returns the Spatial Reference Identifier (SRID) value.
+ *
+ * @return int value of SRID.
+ */
public int getSrid() {
return srid;
}
+ /**
+ * Returns if the Geography object is null.
+ *
+ * @return boolean that indicates if the object is null.
+ */
public boolean isNull() {
return isNull;
}
+ /**
+ * Returns the number of points in the Geography object.
+ *
+ * @return int that indicates the number of points in the Geography object.
+ */
public int STNumPoints() {
return numberOfPoints;
}
@@ -204,7 +285,7 @@ public int STNumPoints() {
/**
* Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance.
*
- * @return type name
+ * @return String that contains the Geography object's type name
*/
public String STGeographyType() {
if (null != internalType) {
@@ -213,10 +294,21 @@ public String STGeographyType() {
return null;
}
+ /**
+ * Returns the Well-Known Text (WKT) representation of the Geography object.
+ *
+ * @return String that contains the WKT representation of the Geography object.
+ */
public String asTextZM() {
return wkt;
}
+ /**
+ * Returns the String representation of the Geography object.
+ *
+ * @return String that contains the WKT representation of the Geography object.
+ */
+ @Override
public String toString() {
return wkt;
}
@@ -245,7 +337,6 @@ protected void serializeToWkb(boolean noZM) {
buf.putDouble(zValues[i]);
}
}
-
if (hasMvalues) {
for (int i = 0; i < numberOfPoints; i++) {
buf.putDouble(mValues[i]);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java
index 90f4427a5a..45a0960f1e 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java
@@ -12,118 +12,155 @@
import java.nio.ByteOrder;
public class Geometry extends SQLServerSpatialDatatype {
-
+
/**
* Private constructor used for creating a Geometry object from WKT and srid.
+ *
+ * @param WellKnownText
+ * Well-Known Text (WKT) provided by the user.
+ * @param srid
+ * Spatial Reference Identifier (SRID) provided by the user.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- private Geometry(String WellKnownText, int srid) {
+ private Geometry(String WellKnownText,
+ int srid) throws SQLServerException {
this.wkt = WellKnownText;
this.srid = srid;
-
+
try {
parseWKTForSerialization(this, currentWktPos, -1, false);
}
catch (StringIndexOutOfBoundsException e) {
- throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid.");
+ String strError = SQLServerException.getErrString("R_illegalWKT");
+ throw new SQLServerException(strError, null, 0, null);
}
-
+
serializeToWkb(false);
isNull = false;
}
/**
* Private constructor used for creating a Geometry object from WKB.
+ *
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- private Geometry(byte[] wkb) {
+ private Geometry(byte[] wkb) throws SQLServerException {
this.wkb = wkb;
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);
-
+
parseWkb();
-
+
WKTsb = new StringBuffer();
WKTsbNoZM = new StringBuffer();
-
+
constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes);
-
+
wkt = WKTsb.toString();
wktNoZM = WKTsbNoZM.toString();
isNull = false;
}
-
- public Geometry() {
- // TODO Auto-generated constructor stub
- }
-
+
/**
- * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT)
- * representation augmented with any Z (elevation) and M (measure) values carried by the instance.
- *
- * @param wkt WKT
- * @param srid SRID
- * @return Geometry instance
+ * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation augmented with any Z (elevation) and
+ * M (measure) values carried by the instance.
+ *
+ * @param wkt
+ * Well-Known Text (WKT) provided by the user.
+ * @param srid
+ * Spatial Reference Identifier (SRID) provided by the user.
+ * @return Geometry
+ * Geometry instance created from WKT and SRID
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geometry STGeomFromText(String wkt, int srid) {
+ public static Geometry STGeomFromText(String wkt,
+ int srid) throws SQLServerException {
return new Geometry(wkt, srid);
}
-
+
/**
- * Returns a Geometry instance from an Open Geospatial Consortium (OGC)
- * Well-Known Binary (WKB) representation.
+ * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation.
*
- * @param wkb WKB
- * @return Geometry instance
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @return Geometry
+ * Geometry instance created from WKB
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geometry STGeomFromWKB(byte[] wkb) {
+ public static Geometry STGeomFromWKB(byte[] wkb) throws SQLServerException {
return new Geometry(wkb);
}
-
+
/**
* Returns a constructed Geometry from an internal SQL Server format for spatial data.
*
- * @param wkb WKB
- * @return Geometry instance
+ * @param wkb
+ * Well-Known Binary (WKB) provided by the user.
+ * @return Geometry
+ * Geometry instance created from WKB
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geometry deserialize(byte[] wkb) {
+ public static Geometry deserialize(byte[] wkb) throws SQLServerException {
return new Geometry(wkb);
}
/**
- * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
- * SRID is defaulted to 0.
+ * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID is defaulted to 0.
*
- * @param wkt WKT
- * @return Geometry instance
+ * @param wkt
+ * Well-Known Text (WKT) provided by the user.
+ * @return Geometry
+ * Geometry instance created from WKT
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geometry parse(String wkt) {
+ public static Geometry parse(String wkt) throws SQLServerException {
return new Geometry(wkt, 0);
}
-
+
/**
* Constructs a Geometry instance that represents a Point instance from its X and Y values and an SRID.
*
- * @param x x coordinate
- * @param y y coordinate
- * @param srid SRID
- * @return Geometry instance
+ * @param x
+ * x coordinate
+ * @param y
+ * y coordinate
+ * @param srid
+ * SRID
+ * @return Geometry
+ * Geography instance
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public static Geometry point(double x, double y, int srid) {
+ public static Geometry point(double x,
+ double y,
+ int srid) throws SQLServerException {
return new Geometry("POINT (" + x + " " + y + ")", srid);
}
-
+
/**
- * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a
- * Geometry instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance.
+ * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance. This text will not contain any Z
+ * (elevation) or M (measure) values carried by the instance.
*
- * @return the WKT representation without the Z and M values.
+ * @return
+ * the WKT representation without the Z and M values.
+ * @throws SQLServerException
+ * if an exception occurs
*/
- public String STAsText() {
+ public String STAsText() throws SQLServerException {
if (null == wktNoZM) {
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);
-
+
parseWkb();
-
+
WKTsb = new StringBuffer();
WKTsbNoZM = new StringBuffer();
constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes);
@@ -131,11 +168,12 @@ public String STAsText() {
}
return wktNoZM;
}
-
+
/**
- * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a
- * Geometry instance. This value will not contain any Z or M values carried by the instance.
- * @return WKB
+ * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance. This value will not contain any Z
+ * or M values carried by the instance.
+ *
+ * @return byte array representation of the Geometry object.
*/
public byte[] STAsBinary() {
if (null == wkbNoZM) {
@@ -143,45 +181,75 @@ public byte[] STAsBinary() {
}
return wkbNoZM;
}
-
+
/**
- * Returns the bytes that represent an internal SQL Server format of Geometry type.
+ * Returns the bytes that represent an internal SQL Server format of Geometry type.
*
- * @return WKB
+ * @return byte array representation of the Geometry object.
*/
public byte[] serialize() {
return wkb;
}
-
+
+ /**
+ * Returns if the object contains a M (measure) value.
+ *
+ * @return boolean that indicates if the object contains M value.
+ */
public boolean hasM() {
return hasMvalues;
}
-
+
+ /**
+ * Returns if the object contains a Z (elevation) value.
+ *
+ * @return boolean that indicates if the object contains Z value.
+ */
public boolean hasZ() {
return hasZvalues;
}
-
+
+ /**
+ * Returns the X coordinate value.
+ *
+ * @return double value that represents the X coordinate.
+ */
public Double getX() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[0];
}
return null;
}
-
+
+ /**
+ * Returns the Y coordinate value.
+ *
+ * @return double value that represents the Y coordinate.
+ */
public Double getY() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[1];
}
return null;
}
-
+
+ /**
+ * Returns the M (measure) value of the object.
+ *
+ * @return double value that represents the M value.
+ */
public Double getM() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) {
return mValues[0];
}
return null;
}
-
+
+ /**
+ * Returns the Z (elevation) value of the object.
+ *
+ * @return double value that represents the Z value.
+ */
public Double getZ() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) {
return zValues[0];
@@ -189,14 +257,29 @@ public Double getZ() {
return null;
}
+ /**
+ * Returns the Spatial Reference Identifier (SRID) value.
+ *
+ * @return int value of SRID.
+ */
public int getSrid() {
return srid;
}
-
+
+ /**
+ * Returns if the Geometry object is null.
+ *
+ * @return boolean that indicates if the object is null.
+ */
public boolean isNull() {
return isNull;
}
-
+
+ /**
+ * Returns the number of points in the Geometry object.
+ *
+ * @return int that indicates the number of points in the Geometry object.
+ */
public int STNumPoints() {
return numberOfPoints;
}
@@ -204,7 +287,7 @@ public int STNumPoints() {
/**
* Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance.
*
- * @return type name
+ * @return String that contains the Geometry object's type name
*/
public String STGeometryType() {
if (null != internalType) {
@@ -212,105 +295,117 @@ public String STGeometryType() {
}
return null;
}
-
+
+ /**
+ * Returns the Well-Known Text (WKT) representation of the Geometry object.
+ *
+ * @return String that contains the WKT representation of the Geometry object.
+ */
public String asTextZM() {
return wkt;
}
-
+
+ /**
+ * Returns the String representation of the Geometry object.
+ *
+ * @return String that contains the WKT representation of the Geometry object.
+ */
+ @Override
public String toString() {
return wkt;
}
-
+
protected void serializeToWkb(boolean noZM) {
ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity());
createSerializationProperties();
-
+
buf.order(ByteOrder.LITTLE_ENDIAN);
buf.putInt(srid);
buf.put(version);
buf.put(serializationProperties);
-
+
if (!isSinglePoint && !isSingleLineSegment) {
buf.putInt(numberOfPoints);
}
-
+
for (int i = 0; i < numberOfPoints; i++) {
buf.putDouble(points[2 * i]);
buf.putDouble(points[2 * i + 1]);
}
-
- if (!noZM ) {
+
+ if (!noZM) {
if (hasZvalues) {
for (int i = 0; i < numberOfPoints; i++) {
buf.putDouble(zValues[i]);
}
}
-
+
if (hasMvalues) {
for (int i = 0; i < numberOfPoints; i++) {
buf.putDouble(mValues[i]);
}
}
}
-
+
if (isSinglePoint || isSingleLineSegment) {
wkb = buf.array();
return;
}
-
+
buf.putInt(numberOfFigures);
for (int i = 0; i < numberOfFigures; i++) {
buf.put(figures[i].getFiguresAttribute());
buf.putInt(figures[i].getPointOffset());
}
-
+
buf.putInt(numberOfShapes);
for (int i = 0; i < numberOfShapes; i++) {
buf.putInt(shapes[i].getParentOffset());
buf.putInt(shapes[i].getFigureOffset());
buf.put(shapes[i].getOpenGISType());
}
-
+
if (version == 2 && null != segments) {
buf.putInt(numberOfSegments);
for (int i = 0; i < numberOfSegments; i++) {
buf.put(segments[i].getSegmentType());
}
}
-
- if (noZM) {
+
+ if (noZM) {
wkbNoZM = buf.array();
- } else {
+ }
+ else {
wkb = buf.array();
}
return;
}
-
+
protected void parseWkb() {
srid = buffer.getInt();
version = buffer.get();
serializationProperties = buffer.get();
-
+
interpretSerializationPropBytes();
readNumberOfPoints();
readPoints();
-
+
if (hasZvalues) {
readZvalues();
}
-
+
if (hasMvalues) {
readMvalues();
}
-
+
if (!(isSinglePoint || isSingleLineSegment)) {
readNumberOfFigures();
readFigures();
readNumberOfShapes();
readShapes();
}
-
+
determineInternalType();
if (buffer.hasRemaining()) {
@@ -320,7 +415,7 @@ protected void parseWkb() {
}
}
}
-
+
private void readPoints() {
points = new double[2 * numberOfPoints];
for (int i = 0; i < numberOfPoints; i++) {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
index 8813ef622e..94e62341a4 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
@@ -73,6 +73,9 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
+
+import com.microsoft.sqlserver.jdbc.dataclassification.SensitivityClassification;
+
import java.nio.Buffer;
final class TDS {
@@ -100,9 +103,11 @@ final class TDS {
static final int TDS_DONEPROC = 0xFE;
static final int TDS_DONEINPROC = 0xFF;
static final int TDS_FEDAUTHINFO = 0xEE;
+ static final int TDS_SQLRESCOLSRCS = 0xa2;
+ static final int TDS_SQLDATACLASSIFICATION = 0xa3;
// FedAuth
- static final int TDS_FEATURE_EXT_FEDAUTH = 0x02;
+ static final byte TDS_FEATURE_EXT_FEDAUTH = 0x02;
static final int TDS_FEDAUTH_LIBRARY_SECURITYTOKEN = 0x01;
static final int TDS_FEDAUTH_LIBRARY_ADAL = 0x02;
static final int TDS_FEDAUTH_LIBRARY_RESERVED = 0x7F;
@@ -112,12 +117,22 @@ final class TDS {
static final byte FEDAUTH_INFO_ID_SPN = 0x02; // FedAuthInfoData is the SPN to use for acquiring fed auth token
// AE constants
- static final int TDS_FEATURE_EXT_AE = 0x04;
- static final int MAX_SUPPORTED_TCE_VERSION = 0x01; // max version
+ // 0x03 is for x_eFeatureExtensionId_Rcs
+ static final byte TDS_FEATURE_EXT_AE = 0x04;
+ static final byte MAX_SUPPORTED_TCE_VERSION = 0x01; // max version
static final int CUSTOM_CIPHER_ALGORITHM_ID = 0; // max version
+ // 0x06 is for x_eFeatureExtensionId_LoginToken
+ // 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
+ // Data Classification constants
+ static final byte TDS_FEATURE_EXT_DATACLASSIFICATION = 0x09;
+ static final byte DATA_CLASSIFICATION_NOT_ENABLED = 0x00;
+ static final byte MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION = 0x01;
+
static final int AES_256_CBC = 1;
static final int AEAD_AES_256_CBC_HMAC_SHA256 = 2;
static final int AE_METADATA = 0x08;
+
+ static final byte TDS_FEATURE_EXT_UTF8SUPPORT = 0x0A;
static final int TDS_TVP = 0xF3;
static final int TVP_ROW = 0x01;
@@ -177,6 +192,10 @@ static final String getTokenName(int tdsTokenType) {
return "TDS_DONEINPROC (0xFF)";
case TDS_FEDAUTHINFO:
return "TDS_FEDAUTHINFO (0xEE)";
+ case TDS_FEATURE_EXT_DATACLASSIFICATION:
+ return "TDS_FEATURE_EXT_DATACLASSIFICATION (0x09)";
+ case TDS_FEATURE_EXT_UTF8SUPPORT:
+ return "TDS_FEATURE_EXT_UTF8SUPPORT (0x0A)";
default:
return "unknown token (0x" + Integer.toHexString(tdsTokenType).toUpperCase() + ")";
}
@@ -2329,58 +2348,22 @@ else if (!useTnir) {
conn.terminate(SQLServerException.DRIVER_ERROR_UNSUPPORTED_CONFIG, errorStr);
}
+ if (inetAddrs.length == 1) {
+ // Single address so do not start any threads
+ return getConnectedSocket(inetAddrs[0], portNumber, timeoutInMilliSeconds);
+ }
+ timeoutInMilliSeconds = Math.max(timeoutInMilliSeconds, minTimeoutForParallelConnections);
if (Util.isIBM()) {
- timeoutInMilliSeconds = Math.max(timeoutInMilliSeconds, minTimeoutForParallelConnections);
if (logger.isLoggable(Level.FINER)) {
logger.finer(this.toString() + "Using Java NIO with timeout:" + timeoutInMilliSeconds);
}
findSocketUsingJavaNIO(inetAddrs, portNumber, timeoutInMilliSeconds);
}
else {
- LinkedList inet4Addrs = new LinkedList<>();
- LinkedList inet6Addrs = new LinkedList<>();
-
- for (InetAddress inetAddr : inetAddrs) {
- if (inetAddr instanceof Inet4Address) {
- inet4Addrs.add((Inet4Address) inetAddr);
- }
- else {
- assert inetAddr instanceof Inet6Address : "Unexpected IP address " + inetAddr.toString();
- inet6Addrs.add((Inet6Address) inetAddr);
- }
- }
-
- // use half timeout only if both IPv4 and IPv6 addresses are present
- int timeoutForEachIPAddressType;
- if ((!inet4Addrs.isEmpty()) && (!inet6Addrs.isEmpty())) {
- timeoutForEachIPAddressType = Math.max(timeoutInMilliSeconds / 2, minTimeoutForParallelConnections);
- }
- else
- timeoutForEachIPAddressType = Math.max(timeoutInMilliSeconds, minTimeoutForParallelConnections);
-
- if (!inet4Addrs.isEmpty()) {
- if (logger.isLoggable(Level.FINER)) {
- logger.finer(this.toString() + "Using Java Threading with timeout:" + timeoutForEachIPAddressType);
- }
-
- findSocketUsingThreading(inet4Addrs, portNumber, timeoutForEachIPAddressType);
- }
-
- if (!result.equals(Result.SUCCESS)) {
- // try threading logic
- if (!inet6Addrs.isEmpty()) {
- // do not start any threads if there is only one ipv6 address
- if (inet6Addrs.size() == 1) {
- return getConnectedSocket(inet6Addrs.get(0), portNumber, timeoutForEachIPAddressType);
- }
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer(this.toString() + "Using Threading with timeout:" + timeoutForEachIPAddressType);
- }
-
- findSocketUsingThreading(inet6Addrs, portNumber, timeoutForEachIPAddressType);
- }
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer(this.toString() + "Using Threading with timeout:" + timeoutInMilliSeconds);
}
+ findSocketUsingThreading(inetAddrs, portNumber, timeoutInMilliSeconds);
}
// If the thread continued execution due to timeout, the result may not be known.
@@ -2633,12 +2616,12 @@ private Socket getConnectedSocket(InetSocketAddress addr,
return selectedSocket;
}
- private void findSocketUsingThreading(LinkedList inetAddrs,
+ private void findSocketUsingThreading(InetAddress[] inetAddrs,
int portNumber,
int timeoutInMilliSeconds) throws IOException, InterruptedException {
assert timeoutInMilliSeconds != 0 : "The timeout cannot be zero";
- assert inetAddrs.isEmpty() == false : "Number of inetAddresses should not be zero in this function";
+ assert inetAddrs.length != 0 : "Number of inetAddresses should not be zero in this function";
LinkedList sockets = new LinkedList<>();
LinkedList socketConnectors = new LinkedList<>();
@@ -2646,7 +2629,7 @@ private void findSocketUsingThreading(LinkedList inetAddrs,
try {
// create a socket, inetSocketAddress and a corresponding socketConnector per inetAddress
- noOfSpawnedThreads = inetAddrs.size();
+ noOfSpawnedThreads = inetAddrs.length;
for (InetAddress inetAddress : inetAddrs) {
Socket s = new Socket();
sockets.add(s);
@@ -6348,7 +6331,8 @@ final class TDSReaderMark {
final class TDSReader {
private final static Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.TDS.Reader");
final private String traceID;
-
+ private TimeoutTimer tcpKeepAliveTimeoutTimer;
+
final public String toString() {
return traceID;
}
@@ -6366,7 +6350,7 @@ final TDSCommand getCommand() {
final SQLServerConnection getConnection() {
return con;
}
-
+
private TDSPacket currentPacket = new TDSPacket(0);
private TDSPacket lastPacket = currentPacket;
private int payloadOffset = 0;
@@ -6375,8 +6359,12 @@ final SQLServerConnection getConnection() {
private boolean isStreaming = true;
private boolean useColumnEncryption = false;
private boolean serverSupportsColumnEncryption = false;
+ private boolean serverSupportsDataClassification = false;
private final byte valueBytes[] = new byte[256];
+
+ protected SensitivityClassification sensitivityClassification;
+
private static final AtomicInteger lastReaderID = new AtomicInteger(0);
private static int nextReaderID() {
@@ -6389,7 +6377,12 @@ private static int nextReaderID() {
this.tdsChannel = tdsChannel;
this.con = con;
this.command = command; // may be null
- // if the logging level is not detailed than fine or more we will not have proper readerids.
+ if(null != command) {
+ //if cancelQueryTimeout is set, we should wait for the total amount of queryTimeout + cancelQueryTimeout to terminate the connection.
+ this.tcpKeepAliveTimeoutTimer = (command.getCancelQueryTimeoutSeconds() > 0 && command.getQueryTimeoutSeconds() > 0 ) ?
+ (new TimeoutTimer(command.getCancelQueryTimeoutSeconds() + command.getQueryTimeoutSeconds(), null, con)) : null;
+ }
+ // if the logging level is not detailed than fine or more we will not have proper reader IDs.
if (logger.isLoggable(Level.FINE))
traceID = "TDSReader@" + nextReaderID() + " (" + con.toString() + ")";
else
@@ -6398,6 +6391,7 @@ private static int nextReaderID() {
useColumnEncryption = true;
}
serverSupportsColumnEncryption = con.getServerSupportsColumnEncryption();
+ serverSupportsDataClassification = con.getServerSupportsDataClassification();
}
final boolean isColumnEncryptionSettingEnabled() {
@@ -6408,6 +6402,10 @@ final boolean getServerSupportsColumnEncryption() {
return serverSupportsColumnEncryption;
}
+ final boolean getServerSupportsDataClassification() {
+ return serverSupportsDataClassification;
+ }
+
final void throwInvalidTDS() throws SQLServerException {
if (logger.isLoggable(Level.SEVERE))
logger.severe(toString() + " got unexpected value in TDS response at offset:" + payloadOffset);
@@ -6487,7 +6485,12 @@ synchronized final boolean readPacket() throws SQLServerException {
+ tdsChannel.numMsgsSent;
TDSPacket newPacket = new TDSPacket(con.getTDSPacketSize());
-
+ if (null != tcpKeepAliveTimeoutTimer) {
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest(this.toString() + ": starting timer...");
+ }
+ tcpKeepAliveTimeoutTimer.start();
+ }
// First, read the packet header.
for (int headerBytesRead = 0; headerBytesRead < TDS.PACKET_HEADER_SIZE;) {
int bytesRead = tdsChannel.read(newPacket.header, headerBytesRead, TDS.PACKET_HEADER_SIZE - headerBytesRead);
@@ -6501,7 +6504,14 @@ synchronized final boolean readPacket() throws SQLServerException {
headerBytesRead += bytesRead;
}
-
+
+ // if execution was subject to timeout then stop timing
+ if (null != tcpKeepAliveTimeoutTimer) {
+ if (logger.isLoggable(Level.FINEST)) {
+ logger.finest(this.toString() + ":stopping timer...");
+ }
+ tcpKeepAliveTimeoutTimer.stop();
+ }
// Header size is a 2 byte unsigned short integer in big-endian order.
int packetLength = Util.readUnsignedShortBigEndian(newPacket.header, TDS.PACKET_HEADER_MESSAGE_LENGTH);
@@ -7087,7 +7097,7 @@ final void skip(int bytesToSkip) throws SQLServerException {
}
}
- final void TryProcessFeatureExtAck(boolean featureExtAckReceived) throws SQLServerException {
+ final void tryProcessFeatureExtAck(boolean featureExtAckReceived) throws SQLServerException {
// in case of redirection, do not check if TDS_FEATURE_EXTENSION_ACK is received or not.
if (null != this.con.getRoutingInfo()) {
return;
@@ -7096,6 +7106,10 @@ final void TryProcessFeatureExtAck(boolean featureExtAckReceived) throws SQLServ
if (isColumnEncryptionSettingEnabled() && !featureExtAckReceived)
throw new SQLServerException(this, SQLServerException.getErrString("R_AE_NotSupportedByServer"), null, 0, false);
}
+
+ final void trySetSensitivityClassification(SensitivityClassification sensitivityClassification) {
+ this.sensitivityClassification = sensitivityClassification;
+ }
}
/**
@@ -7109,7 +7123,8 @@ final class TimeoutTimer implements Runnable {
private final int timeoutSeconds;
private final TDSCommand command;
private volatile Future> task;
-
+ private final SQLServerConnection con;
+
private static final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
private final AtomicReference tgr = new AtomicReference<>();
private final AtomicInteger threadNumber = new AtomicInteger(0);
@@ -7134,12 +7149,13 @@ public Thread newThread(Runnable r)
private volatile boolean canceled = false;
TimeoutTimer(int timeoutSeconds,
- TDSCommand command) {
+ TDSCommand command,
+ SQLServerConnection con) {
assert timeoutSeconds > 0;
- assert null != command;
this.timeoutSeconds = timeoutSeconds;
this.command = command;
+ this.con = con;
}
final void start() {
@@ -7173,12 +7189,22 @@ public void run() {
// If the timer wasn't canceled before it ran out of
// time then interrupt the registered command.
try {
- command.interrupt(SQLServerException.getErrString("R_queryTimedOut"));
+ // If TCP Connection to server is silently dropped, exceeding the query timeout on the same connection does not throw SQLTimeoutException
+ // The application stops responding instead until SocketTimeoutException is thrown. In this case, we must manually terminate the connection.
+ if (null == command && null != con) {
+ con.terminate(SQLServerException.DRIVER_ERROR_IO_FAILED, SQLServerException.getErrString("R_connectionIsClosed"));
+ }
+ else {
+ // If the timer wasn't canceled before it ran out of
+ // time then interrupt the registered command.
+ command.interrupt(SQLServerException.getErrString("R_queryTimedOut"));
+ }
}
catch (SQLServerException e) {
// Unfortunately, there's nothing we can do if we
// fail to time out the request. There is no way
// to report back what happened.
+ assert null != command;
command.log(Level.FINE, "Command could not be timed out. Reason: " + e.getMessage());
}
}
@@ -7306,7 +7332,17 @@ protected void setProcessedResponse(boolean processedResponse) {
// any attention ack. The command's response is read either on demand as it is processed,
// or by detaching.
private volatile boolean readingResponse;
+ private int queryTimeoutSeconds;
+ private int cancelQueryTimeoutSeconds;
+ protected int getQueryTimeoutSeconds() {
+ return this.queryTimeoutSeconds;
+ }
+
+ protected int getCancelQueryTimeoutSeconds() {
+ return this.cancelQueryTimeoutSeconds;
+ }
+
final boolean readingResponse() {
return readingResponse;
}
@@ -7320,9 +7356,11 @@ final boolean readingResponse() {
* (optional) the time before which the command must complete before it is interrupted. A value of 0 means no timeout.
*/
TDSCommand(String logContext,
- int timeoutSeconds) {
+ int queryTimeoutSeconds, int cancelQueryTimeoutSeconds) {
this.logContext = logContext;
- this.timeoutTimer = (timeoutSeconds > 0) ? (new TimeoutTimer(timeoutSeconds, this)) : null;
+ this.queryTimeoutSeconds = queryTimeoutSeconds;
+ this.cancelQueryTimeoutSeconds = cancelQueryTimeoutSeconds;
+ this.timeoutTimer = (queryTimeoutSeconds > 0) ? (new TimeoutTimer(queryTimeoutSeconds, this, null)) : null;
}
/**
@@ -7770,7 +7808,7 @@ final TDSReader startResponse(boolean isAdaptive) throws SQLServerException {
*/
abstract class UninterruptableTDSCommand extends TDSCommand {
UninterruptableTDSCommand(String logContext) {
- super(logContext, 0);
+ super(logContext, 0, 0);
}
final void interrupt(String reason) throws SQLServerException {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
index 9589cc2398..0bf41d9440 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
@@ -1,90 +1,181 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.util.Set;
-
-/**
- * The ISQLServerBulkRecord interface can be used to create classes that read in data from any source (such as a file) and allow a SQLServerBulkCopy
- * class to write the data to SQL Server tables.
- */
-public interface ISQLServerBulkRecord {
- /**
- * Get the ordinals for each of the columns represented in this data record.
- *
- * @return Set of ordinals for the columns.
- */
- public Set getColumnOrdinals();
-
- /**
- * Get the name of the given column.
- *
- * @param column
- * Column ordinal
- * @return Name of the column
- */
- public String getColumnName(int column);
-
- /**
- * Get the JDBC data type of the given column.
- *
- * @param column
- * Column ordinal
- * @return JDBC data type of the column
- */
- public int getColumnType(int column);
-
- /**
- * Get the precision for the given column.
- *
- * @param column
- * Column ordinal
- * @return Precision of the column
- */
- public int getPrecision(int column);
-
- /**
- * Get the scale for the given column.
- *
- * @param column
- * Column ordinal
- * @return Scale of the column
- */
- public int getScale(int column);
-
- /**
- * Indicates whether the column represents an identity column.
- *
- * @param column
- * Column ordinal
- * @return True if the column is an identity column; false otherwise.
- */
- public boolean isAutoIncrement(int column);
-
- /**
- * Gets the data for the current row as an array of Objects.
- *
- * Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the given column. For more
- * information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings.
- *
- * @return The data for the row.
- * @throws SQLServerException
- * If there are any errors in obtaining the data.
- */
- public Object[] getRowData() throws SQLServerException;
-
- /**
- * Advances to the next data row.
- *
- * @return True if rows are available; false if there are no more rows
- * @throws SQLServerException
- * If there are any errors in advancing to the next row.
- */
- public boolean next() throws SQLServerException;
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.time.format.DateTimeFormatter;
+
+/**
+ * The ISQLServerBulkRecord interface can be used to create classes that read in data from any source (such as a file) and allow a SQLServerBulkCopy
+ * class to write the data to SQL Server tables.
+ *
+ * This interface is implemented by {@link SQLServerBulkCommon} Class
+ */
+public interface ISQLServerBulkRecord {
+
+ /**
+ * Get the ordinals for each of the columns represented in this data record.
+ *
+ * @return Set of ordinals for the columns.
+ */
+ public java.util.Set getColumnOrdinals();
+
+ /**
+ * Get the name of the given column.
+ *
+ * @param column
+ * Column ordinal
+ * @return Name of the column
+ */
+ public String getColumnName(int column);
+
+ /**
+ * Get the JDBC data type of the given column.
+ *
+ * @param column
+ * Column ordinal
+ * @return JDBC data type of the column
+ */
+ public int getColumnType(int column);
+
+ /**
+ * Get the precision for the given column.
+ *
+ * @param column
+ * Column ordinal
+ * @return Precision of the column
+ */
+ public int getPrecision(int column);
+
+ /**
+ * Get the scale for the given column.
+ *
+ * @param column
+ * Column ordinal
+ * @return Scale of the column
+ */
+ public int getScale(int column);
+
+ /**
+ * Indicates whether the column represents an identity column.
+ *
+ * @param column
+ * Column ordinal
+ * @return True if the column is an identity column; false otherwise.
+ */
+ public boolean isAutoIncrement(int column);
+
+ /**
+ * Gets the data for the current row as an array of Objects.
+ *
+ * Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the given column. For more
+ * information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings.
+ *
+ * @return The data for the row.
+ * @throws SQLServerException
+ * If there are any errors in obtaining the data.
+ */
+ public Object[] getRowData() throws SQLServerException;
+
+ /**
+ * Advances to the next data row.
+ *
+ * @return True if rows are available; false if there are no more rows
+ * @throws SQLServerException
+ * If there are any errors in advancing to the next row.
+ */
+ public boolean next() throws SQLServerException;
+
+ /**
+ * Adds metadata for the given column in the file.
+ *
+ * @param positionInFile
+ * Indicates which column the metadata is for. Columns start at 1.
+ * @param name
+ * Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)
+ * @param jdbcType
+ * JDBC data type of the column
+ * @param precision
+ * Precision for the column (ignored for the appropriate data types)
+ * @param scale
+ * Scale for the column (ignored for the appropriate data types)
+ * @param dateTimeFormatter
+ * format to parse data that is sent
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void addColumnMetadata(int positionInFile,
+ String name,
+ int jdbcType,
+ int precision,
+ int scale,
+ DateTimeFormatter dateTimeFormatter) throws SQLServerException;
+
+ /**
+ * Adds metadata for the given column in the file.
+ *
+ * @param positionInFile
+ * Indicates which column the metadata is for. Columns start at 1.
+ * @param name
+ * Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)
+ * @param jdbcType
+ * JDBC data type of the column
+ * @param precision
+ * Precision for the column (ignored for the appropriate data types)
+ * @param scale
+ * Scale for the column (ignored for the appropriate data types)
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void addColumnMetadata(int positionInFile,
+ String name,
+ int jdbcType,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Set the format for reading in dates from the file.
+ *
+ * @param dateTimeFormat
+ * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
+ */
+ public void setTimestampWithTimezoneFormat(String dateTimeFormat);
+
+ /**
+ * Set the format for reading in dates from the file.
+ *
+ * @param dateTimeFormatter
+ * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
+ */
+ public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);
+
+ /**
+ * Set the format for reading in dates from the file.
+ *
+ * @param timeFormat
+ * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
+ */
+ public void setTimeWithTimezoneFormat(String timeFormat);
+
+ /**
+ * Set the format for reading in dates from the file.
+ *
+ * @param dateTimeFormatter
+ * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
+ */
+ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter);
+
+ /**
+ * Retreives dateTimeFormatter for the given column
+ *
+ * @param column
+ * Column ordinal
+ * @return dateTimeFormatter
+ */
+ public DateTimeFormatter getColumnDateTimeFormatter(int column);
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
index 280f66f1aa..7be9957b39 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
@@ -8,49 +8,1159 @@
package com.microsoft.sqlserver.jdbc;
-import java.sql.SQLException;
+import java.math.BigDecimal;
+import java.sql.SQLType;
+import java.sql.Timestamp;
+import java.util.Calendar;
/**
- *
- * This interface is implemented by SQLServerCallableStatement Class.
- *
+ * This interface is implemented by {@link SQLServerCallableStatement} Class.
*/
public interface ISQLServerCallableStatement extends java.sql.CallableStatement, ISQLServerPreparedStatement {
+
+ @Deprecated
+ public BigDecimal getBigDecimal(String parameterName,
+ int scale) throws SQLServerException;
+
/**
- * Sets parameter parameterName to DateTimeOffset x
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getDateTime(int index) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
*
* @param parameterName
- * the name of the parameter
- * @param x
- * DateTimeOffset value
- * @throws SQLException
- * if parameterName does not correspond to a named parameter; if the driver can detect that a data conversion error could occur; if a
- * database access error occurs or this method is called on a closed CallableStatement
+ * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
+ * column
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
*/
- public void setDateTimeOffset(String parameterName,
- microsoft.sql.DateTimeOffset x) throws SQLException;
+ public Timestamp getDateTime(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
+ * not store timezone information.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param cal
+ * the java.util.Calendar object to use in constructing the dateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getDateTime(int index,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
+ * not store timezone information.
+ *
+ * @param name
+ * the name of the column
+ * @param cal
+ * the java.util.Calendar object to use in constructing the dateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getDateTime(String name,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getSmallDateTime(int index) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param parameterName
+ * The name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getSmallDateTime(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param cal
+ * the java.util.Calendar object to use in constructing the smalldateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getSmallDateTime(int index,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param name
+ * The name of a column
+ * @param cal
+ * the java.util.Calendar object to use in constructing the smalldateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Timestamp getSmallDateTime(String name,
+ Calendar cal) throws SQLServerException;
/**
* Gets the DateTimeOffset value of parameter with index parameterIndex
*
* @param parameterIndex
* the first parameter is 1, the second is 2, and so on
- * @return DateTimeOffset value
- * @throws SQLException
+ * @return DateTimeOffset value if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
* if parameterIndex is out of range; if a database access error occurs or this method is called on a closed
* CallableStatement
*/
- public microsoft.sql.DateTimeOffset getDateTimeOffset(int parameterIndex) throws SQLException;
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(int parameterIndex) throws SQLServerException;
/**
* Gets the DateTimeOffset value of parameter with name parameterName
*
* @param parameterName
* the name of the parameter
- * @return DateTimeOffset value
- * @throws SQLException
+ * @return DateTimeOffset value if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters. The
+ * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARCHAR values.
+ * The JDBC driver will do any necessary conversion from the database format into ASCII.
+ *
+ *
+ * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
+ * implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether
+ * there is data available or not.
+ *
+ * @param parameterIndex
+ * the first column is 1, the second is 2, ...
+ * @return a Java input stream that delivers the database column value as a stream of one-byte ASCII characters; if the value is SQL
+ * NULL, the value returned is null
+ * @throws SQLServerException
+ * if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
+ */
+ public java.io.InputStream getAsciiStream(int parameterIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters. The
+ * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARCHAR values.
+ * The JDBC driver will do any necessary conversion from the database format into ASCII.
+ *
+ *
+ * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
+ * implicitly closes the stream. Also, a stream may return 0 when the method available is called whether there is data
+ * available or not.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @return a Java input stream that delivers the database column value as a stream of one-byte ASCII characters. If the value is SQL
+ * NULL, the value returned is null.
+ * @throws SQLServerException
+ * if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
+ */
+ public java.io.InputStream getAsciiStream(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param parameterIndex
+ * The zero-based ordinal of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public BigDecimal getMoney(int parameterIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param parameterName
+ * The name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public BigDecimal getMoney(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param parameterIndex
+ * The zero-based ordinal of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public BigDecimal getSmallMoney(int parameterIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param parameterName
+ * The name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public BigDecimal getSmallMoney(String parameterName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted bytes. The
+ * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARBINARY values.
+ *
+ *
+ * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
+ * implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether
+ * there is data available or not.
+ *
+ * @param parameterIndex
+ * the first column is 1, the second is 2, ...
+ * @return a Java input stream that delivers the database column value as a stream of uninterpreted bytes; if the value is SQL NULL,
+ * the value returned is null
+ * @throws SQLServerException
+ * if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
+ */
+ public java.io.InputStream getBinaryStream(int parameterIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted
+ * bytes. The value can then be read in chunks from the stream. This method is particularly suitable for retrieving large
+ * LONGVARBINARY values.
+ *
+ *
+ * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
+ * implicitly closes the stream. Also, a stream may return 0 when the method available is called whether there is data
+ * available or not.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @return a Java input stream that delivers the database column value as a stream of uninterpreted bytes; if the value is SQL NULL,
+ * the result is null
+ * @throws SQLServerException
+ * if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
+ */
+ public java.io.InputStream getBinaryStream(String parameterName) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param calendar
+ * a java.util.Calendar
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTimestamp
+ */
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
+ Calendar calendar,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value, using the given Calendar object. The driver uses the
+ * Calendar object to construct an SQL TIME value, which the driver then sends to the database. With a a
+ * Calendar object, the driver can calculate the time taking into account a custom timezone. If no Calendar object is
+ * specified, the driver uses the default timezone, which is that of the virtual machine running the application.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param calendar
+ * the Calendar object the driver will use to construct the time
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTime
+ */
+ public void setTime(String parameterName,
+ java.sql.Time value,
+ Calendar calendar,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the
+ * Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a a
+ * Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is
+ * specified, the driver uses the default timezone, which is that of the virtual machine running the application.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param calendar
+ * the Calendar object the driver will use to construct the date
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getDate
+ */
+ public void setDate(String parameterName,
+ java.sql.Date value,
+ Calendar calendar,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String object. The driver converts this to a SQL NCHAR or
+ * NVARCHAR or LONGNVARCHAR
+ *
+ * @param parameterName
+ * the name of the parameter to be set
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if the driver does not support national character sets; if the driver
+ * can detect that a data conversion error could occur; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setNString(String parameterName,
+ String value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the value of the designated parameter with the given object.
+ *
+ *
+ * The given Java object will be converted to the given targetSqlType before being sent to the database.
+ *
+ * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
+ * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
+ * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
+ * Array, the driver should pass it to the database as a value of the corresponding SQL type.
+ *
+ * Note that this method may be used to pass database- specific abstract data types.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the object containing the input parameter value
+ * @param sqlType
+ * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
+ * @param decimals
+ * for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other
+ * types, this value will be ignored.
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see java.sql.Types
+ * @see #getObject
+ */
+ public void setObject(String parameterName,
+ Object value,
+ int sqlType,
+ int decimals,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the value of the designated parameter with the given object.
+ *
+ *
+ * The given Java object will be converted to the given targetSqlType before being sent to the database.
+ *
+ * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
+ * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
+ * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
+ * Array, the driver should pass it to the database as a value of the corresponding SQL type.
+ *
+ * Note that this method may be used to pass datatabase- specific abstract data types.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the object containing the input parameter value
+ * @param targetSqlType
+ * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
+ * @param precision
+ * the precision of the column.
+ * @param scale
+ * the scale of the column.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see java.sql.Types
+ * @see #getObject
+ */
+ public void setObject(String parameterName,
+ Object value,
+ int targetSqlType,
+ Integer precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param scale
+ * the scale of the parameter
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTimestamp
+ */
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param scale
+ * the scale of the parameter
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTimestamp
+ */
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets parameter parameterName to DateTimeOffset x
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * DateTimeOffset value
+ * @throws SQLServerException
+ * if an error occurs
+ */
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value) throws SQLServerException;
+
+ /**
+ * Sets parameter parameterName to DateTimeOffset x
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * DateTimeOffset value
+ * @param scale
+ * the scale of the parameter
+ * @throws SQLServerException
+ * if an error occurs
+ */
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets parameter parameterName to DateTimeOffset x
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * DateTimeOffset value
+ * @param scale
+ * the scale of the parameter
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if an error occurs
+ */
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTime
+ */
+ public void setTime(String parameterName,
+ java.sql.Time value,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ * @see #getTime
+ */
+ public void setTime(String parameterName,
+ java.sql.Time value,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL DATETIME
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setDateTime(String parameterName,
+ java.sql.Timestamp value) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL DATETIME
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setDateTime(String parameterName,
+ java.sql.Timestamp value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL SMALLDATETIME
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setSmallDateTime(String parameterName,
+ java.sql.Timestamp value) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL SMALLDATETIME
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setSmallDateTime(String parameterName,
+ java.sql.Timestamp value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String value. The driver converts this to an SQL uniqueIdentifier value
+ * when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param guid
+ * the parameter value
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setUniqueIdentifier(String parameterName,
+ String guid) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String value. The driver converts this to an SQL uniqueIdentifier value
+ * when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param guid
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setUniqueIdentifier(String parameterName,
+ String guid,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or
+ * LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it
+ * to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setBytes(String parameterName,
+ byte[] value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java byte value. The driver converts this to an SQL TINYINT value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setByte(String parameterName,
+ byte value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java String value. The driver converts this to an SQL VARCHAR or
+ * LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends
+ * it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setString(String parameterName,
+ String value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL Money
+ * value.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setMoney(String parameterName,
+ BigDecimal value) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL Money
+ * value.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setMoney(String parameterName,
+ BigDecimal value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL
+ * smallMoney value.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setSmallMoney(String parameterName,
+ BigDecimal value) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL
+ * smallMoney value.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setSmallMoney(String parameterName,
+ BigDecimal value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setBigDecimal(String parameterName,
+ BigDecimal value,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setBigDecimal(String parameterName,
+ BigDecimal value,
+ int precision,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java double value. The driver converts this to an SQL DOUBLE value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setDouble(String parameterName,
+ double value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java float value. The driver converts this to an SQL FLOAT value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setFloat(String parameterName,
+ float value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java int value. The driver converts this to an SQL INTEGER value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setInt(String parameterName,
+ int value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java long value. The driver converts this to an SQL BIGINT value when it
+ * sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setLong(String parameterName,
+ long value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java short value. The driver converts this to an SQL SMALLINT value when
+ * it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setShort(String parameterName,
+ short value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT or
+ * BOOLEAN value when it sends it to the database.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
+ * CallableStatement
+ */
+ public void setBoolean(String parameterName,
+ boolean value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter passed to a stored procedure with a data table.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param tvpName
+ * the name of the type TVP
+ * @param tvpDataTable
+ * the data table object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(String parameterName,
+ String tvpName,
+ SQLServerDataTable tvpDataTable) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter passed to a stored procedure with a ResultSet retrieved from another table
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param tvpName
+ * the name of the type TVP
+ * @param tvpResultSet
+ * the source result set object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(String parameterName,
+ String tvpName,
+ java.sql.ResultSet tvpResultSet) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter passed to a stored procedure with an ISQLServerDataRecord object.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param tvpName
+ * the name of the type TVP
+ * @param tvpDataRecord
+ * ISQLServerDataRecord is used for streaming data and the user decides how to use it. tvpDataRecord is an ISQLServerDataRecord
+ * object.the source result set object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(String parameterName,
+ String tvpName,
+ ISQLServerDataRecord tvpDataRecord) throws SQLServerException;
+
+ /**
+ * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
+ * is executed.
+ *
+ * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
+ * parameter.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param sqlType
+ * the JDBC type code defined by SQLType to use to register the OUT Parameter.
+ * @param precision
+ * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
+ * @param scale
+ * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void registerOutParameter(String parameterName,
+ SQLType sqlType,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
+ * is executed.
+ *
+ * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
+ * parameter.
+ *
+ * @param parameterIndex
+ * the first column is 1, the second is 2, ...
+ * @param sqlType
+ * the JDBC type code defined by SQLType to use to register the OUT Parameter.
+ * @param precision
+ * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
+ * @param scale
+ * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void registerOutParameter(int parameterIndex,
+ SQLType sqlType,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
+ * is executed.
+ *
+ * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
+ * parameter.
+ *
+ * @param parameterIndex
+ * the first column is 1, the second is 2, ...
+ * @param sqlType
+ * the JDBC type code defined by SQLType to use to register the OUT Parameter.
+ * @param precision
+ * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
+ * @param scale
+ * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void registerOutParameter(int parameterIndex,
+ int sqlType,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
+ * is executed.
+ *
+ * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
+ * parameter.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param sqlType
+ * the JDBC type code defined by SQLType to use to register the OUT Parameter.
+ * @param precision
+ * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
+ * @param scale
+ * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void registerOutParameter(String parameterName,
+ int sqlType,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the value of the designated parameter with the given object.
+ *
+ *
+ * The given Java object will be converted to the given targetSqlType before being sent to the database.
+ *
+ * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
+ * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
+ * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
+ * Array, the driver should pass it to the database as a value of the corresponding SQL type.
+ *
+ * Note that this method may be used to pass datatabase- specific abstract data types.
+ *
+ * @param parameterName
+ * the name of the parameter
+ * @param value
+ * the object containing the input parameter value
+ * @param jdbcType
+ * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
+ * @param scale
+ * the scale of the column.
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
* if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
* CallableStatement
+ * @see java.sql.Types
+ * @see #getObject
*/
- public microsoft.sql.DateTimeOffset getDateTimeOffset(String parameterName) throws SQLException;
+ public void setObject(String parameterName,
+ Object value,
+ SQLType jdbcType,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java
deleted file mode 100644
index 4684ec4ac4..0000000000
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.SQLType;
-
-/**
- * This interface requires all the CallableStatement methods including those are specific to JDBC 4.2
- *
- */
-public interface ISQLServerCallableStatement42 extends ISQLServerCallableStatement, ISQLServerPreparedStatement42 {
-
- public void registerOutParameter(int index,
- SQLType sqlType) throws SQLServerException;
-
- public void registerOutParameter(int index,
- SQLType sqlType,
- String typeName) throws SQLServerException;
-
- public void registerOutParameter(int index,
- SQLType sqlType,
- int scale) throws SQLServerException;
-
- /**
- * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
- * is executed.
- *
- * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
- * parameter.
- *
- * @param index
- * the first parameter is 1, the second is 2,...
- * @param sqlType
- * the JDBC type code defined by SQLType to use to register the OUT Parameter.
- * @param precision
- * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
- * @param scale
- * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
- * @throws SQLServerException
- * If any errors occur.
- */
- public void registerOutParameter(int index,
- SQLType sqlType,
- int precision,
- int scale) throws SQLServerException;
-
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType) throws SQLServerException;
-
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType,
- int scale) throws SQLServerException;
-
- /**
- * Sets the value of the designated parameter with the given object.
- *
- * @param sCol
- * the name of the parameter
- * @param obj
- * the object containing the input parameter value
- * @param jdbcType
- * the SQL type to be sent to the database
- * @param scale
- * scale the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
- * @param forceEncrypt
- * true if force encryption is on, false if force encryption is off
- * @throws SQLServerException
- * If any errors occur.
- */
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType,
- int scale,
- boolean forceEncrypt) throws SQLServerException;
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- String typeName) throws SQLServerException;
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- int scale) throws SQLServerException;
-
- /**
- * Registers the parameter in ordinal position index to be of JDBC type sqlType. All OUT parameters must be registered before a stored procedure
- * is executed.
- *
- * The JDBC type specified by sqlType for an OUT parameter determines the Java type that must be used in the get method to read the value of that
- * parameter.
- *
- * @param parameterName
- * the name of the parameter
- * @param sqlType
- * the JDBC type code defined by SQLType to use to register the OUT Parameter.
- * @param precision
- * the sum of the desired number of digits to the left and right of the decimal point. It must be greater than or equal to zero.
- * @param scale
- * the desired number of digits to the right of the decimal point. It must be greater than or equal to zero.
- * @throws SQLServerException
- * If any errors occur.
- */
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- int precision,
- int scale) throws SQLServerException;
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType) throws SQLServerException;
-}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
index 57ea5e94a1..7ebf9dcfce 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
@@ -1,32 +1,344 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.SQLException;
-import java.util.UUID;
-
-/**
- *
- * This interface is implemented by SQLServerConnection Class.
- */
-public interface ISQLServerConnection extends java.sql.Connection {
- // Transaction types.
- // TRANSACTION_SNAPSHOT corresponds to -> SET TRANSACTION ISOLATION LEVEL SNAPSHOT
- public final static int TRANSACTION_SNAPSHOT = 0x1000;
-
- /**
- * Gets the connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.
- *
- * @return 16-byte GUID representing the connection ID of the most recent connection attempt. Or, NULL if there is a failure after the connection
- * request is initiated and the pre-login handshake.
- * @throws SQLException
- * If any errors occur.
- */
- public UUID getClientConnectionId() throws SQLException;
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+import java.util.UUID;
+
+/**
+ * This interface is implemented by {@link SQLServerConnection} and {@link SQLServerConnectionPoolProxy} Classes.
+ */
+public interface ISQLServerConnection extends java.sql.Connection {
+
+ // Transaction types.
+ // TRANSACTION_SNAPSHOT corresponds to -> SET TRANSACTION ISOLATION LEVEL SNAPSHOT
+ public final static int TRANSACTION_SNAPSHOT = 0x1000;
+
+ /**
+ * Gets the connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.
+ *
+ * @return 16-byte GUID representing the connection ID of the most recent connection attempt. Or, NULL if there is a failure after the connection
+ * request is initiated and the pre-login handshake.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public UUID getClientConnectionId() throws SQLServerException;
+
+ /**
+ * Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
+ * This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and
+ * holdability to be overridden.
+ *
+ * @param nType
+ * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
+ * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
+ * @param nConcur
+ * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
+ * ResultSet.CONCUR_UPDATABLE
+ * @param nHold
+ * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
+ * ResultSet.CLOSE_CURSORS_AT_COMMIT
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new Statement object that will generate ResultSet objects with the given type, concurrency, and holdability
+ * @throws SQLServerException
+ * if a database access error occurs, this method is called on a closed connection or the given parameters are not
+ * ResultSet constants indicating type, concurrency, and holdability
+ */
+ public Statement createStatement(int nType,
+ int nConcur,
+ int nHold,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the
+ * driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an
+ * INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
+ *
+ * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
+ * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
+ * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
+ * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
+ *
+ * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
+ * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
+ * {@link #getHoldability}.
+ *
+ * @param sql
+ * an SQL statement that may contain one or more '?' IN parameter placeholders
+ * @param flag
+ * a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or
+ * Statement.NO_GENERATED_KEYS
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning
+ * auto-generated keys
+ * @throws SQLServerException
+ * if a database access error occurs, this method is called on a closed connection or the given parameter is not a
+ * Statement constant indicating whether auto-generated keys should be returned
+ */
+ public PreparedStatement prepareStatement(String sql,
+ int flag,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
+ * contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will
+ * ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list
+ * of such statements is vendor-specific).
+ *
+ * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
+ * be used to efficiently execute this statement multiple times.
+ *
+ * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
+ * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
+ * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
+ * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
+ *
+ * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
+ * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
+ * {@link #getHoldability}.
+ *
+ * @param sql
+ * an SQL statement that may contain one or more '?' IN parameter placeholders
+ * @param columnIndexes
+ * an array of column indexes indicating the columns that should be returned from the inserted row or rows
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
+ * keys designated by the given array of column indexes
+ * @throws SQLServerException
+ * if a database access error occurs or this method is called on a closed connection
+ */
+ public PreparedStatement prepareStatement(String sql,
+ int[] columnIndexes,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
+ * contains the names of the columns in the target table that contain the auto-generated keys that should be returned. The driver will ignore the
+ * array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such
+ * statements is vendor-specific).
+ *
+ * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
+ * be used to efficiently execute this statement multiple times.
+ *
+ * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
+ * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
+ * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
+ * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
+ *
+ * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
+ * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
+ * {@link #getHoldability}.
+ *
+ * @param sql
+ * an SQL statement that may contain one or more '?' IN parameter placeholders
+ * @param columnNames
+ * an array of column names indicating the columns that should be returned from the inserted row or rows
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
+ * keys designated by the given array of column names
+ * @throws SQLServerException
+ * if a database access error occurs or this method is called on a closed connection
+ */
+ public PreparedStatement prepareStatement(String sql,
+ String[] columnNames,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and
+ * holdability.
+ *
+ * This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and
+ * holdability to be overridden.
+ *
+ * @param sql
+ * a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
+ * @param nType
+ * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
+ * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
+ * @param nConcur
+ * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
+ * ResultSet.CONCUR_UPDATABLE
+ * @param resultSetHoldability
+ * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
+ * ResultSet.CLOSE_CURSORS_AT_COMMIT
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will generate ResultSet
+ * objects with the given type, concurrency, and holdability
+ * @throws SQLServerException
+ * if a database access error occurs, this method is called on a closed connection or the given parameters are not
+ * ResultSet constants indicating type, concurrency, and holdability
+ */
+ public PreparedStatement prepareStatement(java.lang.String sql,
+ int nType,
+ int nConcur,
+ int resultSetHoldability,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This
+ * method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and
+ * holdability to be overridden.
+ *
+ * @param sql
+ * a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters
+ * @param nType
+ * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
+ * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
+ * @param nConcur
+ * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
+ * ResultSet.CONCUR_UPDATABLE
+ * @param nHold
+ * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
+ * ResultSet.CLOSE_CURSORS_AT_COMMIT
+ * @param stmtColEncSetting
+ * Specifies how data will be sent and received when reading and writing encrypted columns.
+ * @return a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet
+ * objects with the given type, concurrency, and holdability
+ * @throws SQLServerException
+ * if a database access error occurs, this method is called on a closed connection or the given parameters are not
+ * ResultSet constants indicating type, concurrency, and holdability
+ */
+ public CallableStatement prepareCall(String sql,
+ int nType,
+ int nConcur,
+ int nHold,
+ SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException;
+
+ /**
+ * Modifies the setting of the sendTimeAsDatetime connection property. When true, java.sql.Time values will be sent to the server as SQL
+ * Serverdatetime values. When false, java.sql.Time values will be sent to the server as SQL Servertime values. sendTimeAsDatetime can also be
+ * modified programmatically with SQLServerDataSource.setSendTimeAsDatetime. The default value for this property may change in a future release.
+ *
+ * @param sendTimeAsDateTimeValue
+ * enables/disables setting the sendTimeAsDatetime connection property. For more information about how the Microsoft JDBC Driver for
+ * SQL Server configures java.sql.Time values before sending them to the server, see
+ * Configuring How java.sql.Time Values are Sent to the
+ * Server.
+ *
+ * @throws SQLServerException
+ * if a database access error occurs
+ */
+ public void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException;
+
+ /**
+ * Checks the sendTimeAsDatetime property.
+ *
+ * @return boolean value of sendTimeAsDatetime
+ *
+ * @throws SQLServerException
+ * if a database access error occurs
+ */
+ public boolean getSendTimeAsDatetime() throws SQLServerException;
+
+ /**
+ * Returns the number of currently outstanding prepared statement un-prepare actions.
+ *
+ * @return Returns the current value per the description.
+ */
+ public int getDiscardedServerPreparedStatementCount();
+
+ /**
+ * Forces the un-prepare requests for any outstanding discarded prepared statements to be executed.
+ */
+ public void closeUnreferencedPreparedStatementHandles();
+
+ /**
+ * Returns the behavior for a specific connection instance. If false the first execution will call sp_executesql and not prepare a statement, once
+ * the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will call
+ * sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only executed once. The default for this
+ * option can be changed by calling setDefaultEnablePrepareOnFirstPreparedStatementCall().
+ *
+ * @return Returns the current setting per the description.
+ */
+ public boolean getEnablePrepareOnFirstPreparedStatementCall();
+
+ /**
+ * Specifies the behavior for a specific connection instance. If value is false the first execution will call sp_executesql and not prepare a
+ * statement, once the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will
+ * call sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only executed once.
+ *
+ * @param value
+ * Changes the setting per the description.
+ */
+ public void setEnablePrepareOnFirstPreparedStatementCall(boolean value);
+
+ /**
+ * Returns the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions
+ * (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is
+ * {@literal <=} 1, unprepare actions will be executed immedietely on prepared statement close. If it is set to {@literal >} 1, these calls will
+ * be batched together to avoid overhead of calling sp_unprepare too often. The default for this option can be changed by calling
+ * getDefaultServerPreparedStatementDiscardThreshold().
+ *
+ * @return Returns the current setting per the description.
+ */
+ public int getServerPreparedStatementDiscardThreshold();
+
+ /**
+ * Specifies the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions
+ * (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is
+ * {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to {@literal >} 1 these calls will be
+ * batched together to avoid overhead of calling sp_unprepare too often.
+ *
+ * @param value
+ * Changes the setting per the description.
+ */
+ public void setServerPreparedStatementDiscardThreshold(int value);
+
+ /**
+ * Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache.
+ *
+ * @param value
+ * The new cache size.
+ *
+ */
+ public void setStatementPoolingCacheSize(int value);
+
+ /**
+ * Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public int getStatementPoolingCacheSize();
+
+ /**
+ * Whether statement pooling is enabled or not for this connection.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public boolean isStatementPoolingEnabled();
+
+ /**
+ * Returns the current number of pooled prepared statement handles.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public int getStatementHandleCacheEntryCount();
+
+ /**
+ * Disable/enable statement pooling.
+ *
+ * @param value
+ * true to disable statement pooling, false to enable it.
+ */
+ public void setDisableStatementPooling(boolean value);
+
+ /**
+ * Determine whether statement pooling is disabled.
+ *
+ * @return true if statement pooling is disabled, false if it is enabled.
+ */
+ public boolean getDisableStatementPooling();
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java
index 1689cde873..c7dca8ee13 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java
@@ -1,19 +1,59 @@
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.ShardingKey;
-
-public interface ISQLServerConnection43 extends ISQLServerConnection {
-
- public void setShardingKey(ShardingKey shardingKey) throws SQLServerException;
-
- public void setShardingKey(ShardingKey shardingKey,
- ShardingKey superShardingKey) throws SQLServerException;
-
- public boolean setShardingKeyIfValid(ShardingKey shardingKey,
- int timeout) throws SQLServerException;
-
- public boolean setShardingKeyIfValid(ShardingKey shardingKey,
- ShardingKey superShardingKey,
- int timeout) throws SQLServerException;
-
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.sql.SQLException;
+
+/**
+ * This interface is implemented by {@link SQLServerConnection43} class.
+ */
+public interface ISQLServerConnection43 extends ISQLServerConnection {
+
+ /**
+ * Hints to the driver that a request, an independent unit of work, is beginning on this connection. It backs up the values of the connection
+ * properties that are modifiable through public methods. Each request is independent of all other requests with regard to state local to the
+ * connection either on the client or the server. Work done between {@code beginRequest}, {@code endRequest} pairs does not depend on any other
+ * work done on the connection either as part of another request or outside of any request. A request may include multiple transactions. There may
+ * be dependencies on committed database state as that is not local to the connection. {@code beginRequest} marks the beginning of the work unit.
+ *
+ * Local state is defined as any state associated with a Connection that is local to the current Connection either in the client or the database
+ * that is not transparently reproducible.
+ *
+ * Calls to {@code beginRequest} and {@code endRequest} are not nested. Multiple calls to {@code beginRequest} without an intervening call to
+ * {@code endRequest} is not an error. The first {@code beginRequest} call marks the start of the request and subsequent calls are treated as a
+ * no-op It is recommended to enclose each unit of work in {@code beginRequest}, {@code endRequest} pairs such that there is no open transaction
+ * at the beginning or end of the request and no dependency on local state that crosses request boundaries. Committed database state is not local.
+ *
+ * This method is to be used by Connection pooling managers.
+ *
+ * The pooling manager should call {@code beginRequest} on the underlying connection prior to returning a connection to the caller.
+ *
+ *
+ * @throws SQLException
+ * if an error occurs
+ * @see #endRequest()
+ */
+ @Override
+ public void beginRequest() throws SQLException;
+
+ /**
+ * Hints to the driver that a request, an independent unit of work, has completed. It rolls back the open transactions. Resets the connection
+ * properties that are modifiable through public methods back to their original values. Calls to {@code beginRequest} and {@code endRequest} are
+ * not nested. Multiple calls to {@code endRequest} without an intervening call to {@code beginRequest} is not an error. The first
+ * {@code endRequest} call marks the request completed and subsequent calls are treated as a no-op. If {@code endRequest} is called without an
+ * initial call to {@code beginRequest} is a no-op. This method is to be used by Connection pooling managers.
+ *
+ *
+ * @throws SQLException
+ * if an error occurs
+ * @see #beginRequest()
+ */
+ @Override
+ public void endRequest() throws SQLException;
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java
index 79e109b7cd..a4ee9f7cd7 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java
@@ -1,49 +1,51 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-/**
- * The ISQLServerDataRecord interface can be used to create classes that read in data from any source (such as a file) and allow a structured type to
- * be sent to SQL Server tables.
- */
-
-public interface ISQLServerDataRecord {
- /**
- * Get the column meta data
- *
- * @param column
- * the first column is 1, the second is 2, and so on
- * @return SQLServerMetaData of column
- */
- public SQLServerMetaData getColumnMetaData(int column);
-
- /**
- * Get the column count.
- *
- * @return Set of ordinals for the columns.
- */
- public int getColumnCount();
-
- /**
- * Gets the data for the current row as an array of Objects.
- *
- * Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the given column. For more
- * information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings.
- *
- * @return The data for the row.
- */
- public Object[] getRowData();
-
- /**
- * Advances to the next data row.
- *
- * @return True if rows are available; false if there are no more rows
- */
- public boolean next();
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+/**
+ * This interface can be used to create classes that read in data from any
+ * source (such as a file) and allow a structured type to be sent to SQL Server
+ * tables.
+ */
+public interface ISQLServerDataRecord {
+ /**
+ * Get the column meta data
+ *
+ * @param column
+ * the first column is 1, the second is 2, and so on
+ * @return SQLServerMetaData of column
+ */
+ public SQLServerMetaData getColumnMetaData(int column);
+
+ /**
+ * Get the column count.
+ *
+ * @return Set of ordinals for the columns.
+ */
+ public int getColumnCount();
+
+ /**
+ * Gets the data for the current row as an array of Objects.
+ *
+ * Each Object must match the Java language Type that is used to represent
+ * the indicated JDBC data type for the given column. For more information,
+ * see 'Understanding the JDBC Driver Data Types' for the appropriate
+ * mappings.
+ *
+ * @return The data for the row.
+ */
+ public Object[] getRowData();
+
+ /**
+ * Advances to the next data row.
+ *
+ * @return True if rows are available; false if there are no more rows
+ */
+ public boolean next();
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
index 4925592445..08168cac1e 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
@@ -8,12 +8,15 @@
package com.microsoft.sqlserver.jdbc;
-import javax.sql.CommonDataSource;
+import org.ietf.jgss.GSSCredential;
/**
* A factory to create connections to the data source represented by this object. This interface was added in SQL Server JDBC Driver 3.0.
+ *
+ * This interface is implemented by {@link SQLServerDataSource} Class.
*/
-public interface ISQLServerDataSource extends CommonDataSource {
+public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
+
/**
* Sets the application intent.
*
@@ -112,11 +115,36 @@ public interface ISQLServerDataSource extends CommonDataSource {
*/
public boolean getEncrypt();
+ /**
+ * Beginning in version 6.0 of the Microsoft JDBC Driver for SQL Server, a new connection property transparentNetworkIPResolution (TNIR) is added
+ * for transparent connection to Always On availability groups or to a server which has multiple IP addresses associated. When
+ * transparentNetworkIPResolution is true, the driver attempts to connect to the first IP address available. If the first attempt fails, the
+ * driver tries to connect to all IP addresses in parallel until the timeout expires, discarding any pending connection attempts when one of them
+ * succeeds.
+ *
+ * transparentNetworkIPResolution is ignored if multiSubnetFailover is true
+ *
+ * transparentNetworkIPResolution is ignored if database mirroring is used
+ *
+ * transparentNetworkIPResolution is ignored if there are more than 64 IP addresses
+ *
+ * @param tnir
+ * if set to true, the driver attempts to connect to the first IP address available. It is true by default.
+ */
+ public void setTransparentNetworkIPResolution(boolean tnir);
+
+ /**
+ * Retrieves the TransparentNetworkIPResolution value.
+ *
+ * @return if enabled, returns true. Otherwise, false.
+ */
+ public boolean getTransparentNetworkIPResolution();
+
/**
* Sets a Boolean value that indicates if the trustServerCertificate property is enabled.
*
* @param e
- * true if the server Secure Sockets Layer (SSL) certificate should be automatically trusted when the communication layer is encrypted
+ * true, if the server Secure Sockets Layer (SSL) certificate should be automatically trusted when the communication layer is encrypted
* using SSL. Otherwise, false.
*/
public void setTrustServerCertificate(boolean e);
@@ -128,36 +156,51 @@ public interface ISQLServerDataSource extends CommonDataSource {
*/
public boolean getTrustServerCertificate();
+ /**
+ * This parameter defines the keystore type for the trustStore.
+ *
+ * @param trustStoreType
+ * A String that contains the trust store type
+ */
+ public void setTrustStoreType(String trustStoreType);
+
+ /**
+ * Returns the keyStore Type for the trustStore
+ *
+ * @return trustStoreType A String that contains the trust store type
+ */
+ public String getTrustStoreType();
+
/**
* Sets the path (including file name) to the certificate trustStore file.
*
- * @param st
+ * @param trustStore
* A String that contains the path (including file name) to the certificate trustStore file.
*/
- public void setTrustStore(String st);
+ public void setTrustStore(String trustStore);
/**
* Returns the path (including file name) to the certificate trustStore file.
*
- * @return A String that contains the path (including file name) to the certificate trustStore file, or null if no value is set.
+ * @return trustStore A String that contains the path (including file name) to the certificate trustStore file, or null if no value is set.
*/
public String getTrustStore();
/**
* Sets the password that is used to check the integrity of the trustStore data.
*
- * @param p
+ * @param trustStorePassword
* A String that contains the password that is used to check the integrity of the trustStore data.
*/
- public void setTrustStorePassword(String p);
+ public void setTrustStorePassword(String trustStorePassword);
/**
* Sets the host name to be used in validating the SQL Server Secure Sockets Layer (SSL) certificate.
*
- * @param host
+ * @param hostName
* A String that contains the host name.
*/
- public void setHostNameInCertificate(String host);
+ public void setHostNameInCertificate(String hostName);
/**
* Returns the host name used in validating the SQL Server Secure Sockets Layer (SSL) certificate.
@@ -222,11 +265,11 @@ public interface ISQLServerDataSource extends CommonDataSource {
/**
* Sets the response buffering mode for connections created by using this SQLServerDataSource object.
*
- * @param respo
+ * @param bufferingMode
* A String that contains the buffering and streaming mode. The valid mode can be one of the following case-insensitive Strings: full
* or adaptive.
*/
- public void setResponseBuffering(String respo);
+ public void setResponseBuffering(String bufferingMode);
/**
* Returns the response buffering mode for this SQLServerDataSource object.
@@ -267,6 +310,21 @@ public interface ISQLServerDataSource extends CommonDataSource {
*/
public boolean getSendStringParametersAsUnicode();
+ /**
+ * Translates the serverName from Unicode to ASCII Compatible Encoding (ACE)
+ *
+ * @param serverNameAsACE
+ * if enabled the servername will be translated to ASCII Compatible Encoding (ACE)
+ */
+ public void setServerNameAsACE(boolean serverNameAsACE);
+
+ /**
+ * Retrieves if the serverName should be translated from Unicode to ASCII Compatible Encoding (ACE)
+ *
+ * @return if enabled, will return true. Otherwise, false.
+ */
+ public boolean getServerNameAsACE();
+
/**
* Sets the name of the computer that is running SQL Server.
*
@@ -410,6 +468,21 @@ public interface ISQLServerDataSource extends CommonDataSource {
*/
public void setAuthenticationScheme(String authenticationScheme);
+ /**
+ * sets the authentication mode
+ *
+ * @param authentication
+ * the authentication mode
+ */
+ public void setAuthentication(String authentication);
+
+ /**
+ * Retrieves the authentication mode
+ *
+ * @return the authentication value
+ */
+ public String getAuthentication();
+
/**
* Sets the server spn
*
@@ -424,4 +497,297 @@ public interface ISQLServerDataSource extends CommonDataSource {
* @return A String that contains the server spn
*/
public String getServerSpn();
+
+ /**
+ * sets GSSCredential
+ *
+ * @param userCredential
+ * the credential
+ */
+ public void setGSSCredentials(GSSCredential userCredential);
+
+ /**
+ * Retrieves the GSSCredential
+ *
+ * @return GSSCredential
+ */
+ public GSSCredential getGSSCredentials();
+
+ /**
+ * Sets the access token.
+ *
+ * @param accessToken
+ * to be set in the string property.
+ */
+ public void setAccessToken(String accessToken);
+
+ /**
+ * Retrieves the access token.
+ *
+ * @return the access token.
+ */
+ public String getAccessToken();
+
+ /**
+ * Enables/disables Always Encrypted functionality for the data source object. The default is Disabled.
+ *
+ * @param columnEncryptionSetting
+ * Enables/disables Always Encrypted functionality for the data source object. The default is Disabled.
+ */
+ public void setColumnEncryptionSetting(String columnEncryptionSetting);
+
+ /**
+ * Retrieves the Always Encrypted functionality setting for the data source object.
+ *
+ * @return the Always Encrypted functionality setting for the data source object.
+ */
+ public String getColumnEncryptionSetting();
+
+ /**
+ * Sets the name that identifies a key store. Only value supported is the "JavaKeyStorePassword" for identifying the Java Key Store. The default
+ * is null.
+ *
+ * @param keyStoreAuthentication
+ * the name that identifies a key store.
+ */
+ public void setKeyStoreAuthentication(String keyStoreAuthentication);
+
+ /**
+ * Gets the value of the keyStoreAuthentication setting for the data source object.
+ *
+ * @return the value of the keyStoreAuthentication setting for the data source object.
+ */
+ public String getKeyStoreAuthentication();
+
+ /**
+ * Sets the password for the Java keystore. Note that, for Java Key Store provider the password for the keystore and the key must be the same.
+ * Note that, keyStoreAuthentication must be set with "JavaKeyStorePassword".
+ *
+ * @param keyStoreSecret
+ * the password to use for the keystore as well as for the key
+ */
+ public void setKeyStoreSecret(String keyStoreSecret);
+
+ /**
+ * Sets the location including the file name for the Java keystore. Note that, keyStoreAuthentication must be set with "JavaKeyStorePassword".
+ *
+ * @param keyStoreLocation
+ * the location including the file name for the Java keystore.
+ */
+ public void setKeyStoreLocation(String keyStoreLocation);
+
+ /**
+ * Retrieves the keyStoreLocation for the Java Key Store.
+ *
+ * @return the keyStoreLocation for the Java Key Store.
+ */
+ public String getKeyStoreLocation();
+
+ /**
+ * Setting the query timeout
+ *
+ * @param queryTimeout
+ * The number of seconds to wait before a timeout has occurred on a query. The default value is 0, which means infinite timeout.
+ */
+ public void setQueryTimeout(int queryTimeout);
+
+ /**
+ * Getting the query timeout
+ *
+ * @return The number of seconds to wait before a timeout has occurred on a query.
+ */
+ public int getQueryTimeout();
+
+ /**
+ * Setting the cancel timeout
+ *
+ * @param cancelQueryTimeout
+ * The number of seconds to wait before we wait for the query timeout to happen.
+ */
+ public void setCancelQueryTimeout(int cancelQueryTimeout);
+
+ /**
+ * Getting the cancel timeout
+ *
+ * @return the number of seconds to wait before we wait for the query timeout to happen.
+ */
+ public int getCancelQueryTimeout();
+
+ /**
+ * If this configuration is false the first execution of a prepared statement will call sp_executesql and not prepare a statement, once the second
+ * execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will call sp_execute. This
+ * relieves the need for sp_unprepare on prepared statement close if the statement is only executed once.
+ *
+ * @param enablePrepareOnFirstPreparedStatementCall
+ * Changes the setting per the description.
+ */
+ public void setEnablePrepareOnFirstPreparedStatementCall(boolean enablePrepareOnFirstPreparedStatementCall);
+
+ /**
+ * If this configuration returns false the first execution of a prepared statement will call sp_executesql and not prepare a statement, once the
+ * second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will call sp_execute.
+ * This relieves the need for sp_unprepare on prepared statement close if the statement is only executed once.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public boolean getEnablePrepareOnFirstPreparedStatementCall();
+
+ /**
+ * This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding per connection before a call to
+ * clean-up the outstanding handles on the server is executed. If the setting is {@literal <=} 1 unprepare actions will be executed immedietely on
+ * prepared statement close. If it is set to {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too
+ * often.
+ *
+ * @param serverPreparedStatementDiscardThreshold
+ * Changes the setting per the description.
+ */
+ public void setServerPreparedStatementDiscardThreshold(int serverPreparedStatementDiscardThreshold);
+
+ /**
+ * This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding per connection before a call to
+ * clean-up the outstanding handles on the server is executed. If the setting is {@literal <=} 1 unprepare actions will be executed immedietely on
+ * prepared statement close. If it is set to {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too
+ * often.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public int getServerPreparedStatementDiscardThreshold();
+
+ /**
+ * Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache.
+ *
+ * @param statementPoolingCacheSize
+ * Changes the setting per the description.
+ */
+ public void setStatementPoolingCacheSize(int statementPoolingCacheSize);
+
+ /**
+ * Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
+ *
+ * @return Returns the current setting per the description.
+ */
+ public int getStatementPoolingCacheSize();
+
+ /**
+ * Disable/enable statement pooling.
+ *
+ * @param disableStatementPooling
+ * true to disable statement pooling, false to enable it.
+ */
+ public void setDisableStatementPooling(boolean disableStatementPooling);
+
+ /**
+ * Determine whether statement pooling is disabled.
+ *
+ * @return true if statement pooling is disabled, false if it is enabled.
+ */
+ public boolean getDisableStatementPooling();
+
+ /**
+ * Setting the socket timeout
+ *
+ * @param socketTimeout
+ * The number of milliseconds to wait before a timeout is occurred on a socket read or accept. The default value is 0, which means
+ * infinite timeout.
+ */
+ public void setSocketTimeout(int socketTimeout);
+
+ /**
+ * Getting the socket timeout
+ *
+ * @return The number of milliseconds to wait before a timeout is occurred on a socket read or accept.
+ */
+ public int getSocketTimeout();
+
+ /**
+ * Sets the login configuration file for Kerberos authentication. This overrides the default configuration SQLJDBCDriver
+ *
+ * @param configurationName
+ * the configuration name
+ */
+ public void setJASSConfigurationName(String configurationName);
+
+ /**
+ * Retrieves the login configuration file for Kerberos authentication.
+ *
+ * @return login configuration file name
+ */
+ public String getJASSConfigurationName();
+
+ /**
+ * Enables Fips Mode on the connection For FIPS enabled JVM this property should be true.
+ *
+ * @param fips
+ * Boolean property to enable/disable fips
+ */
+ public void setFIPS(boolean fips);
+
+ /**
+ * Retrieves value of connection property "fips" For FIPS enabled JVM this property should be true.
+ *
+ * @return fips boolean value
+ */
+ public boolean getFIPS();
+
+ /**
+ * Sets the sslProtocol property for connection Set this value to specify TLS protocol keyword.
+ *
+ * Acceptable values are: TLS, TLSv1, TLSv1.1, and TLSv1.2.
+ *
+ * @param sslProtocol
+ * Value for SSL Protocol to be set.
+ */
+ public void setSSLProtocol(String sslProtocol);
+
+ /**
+ * Retrieves value of connection property 'sslProtocol'
+ *
+ * @return sslProtocol property value
+ */
+ public String getSSLProtocol();
+
+ /**
+ * Sets the connection property 'trustManagerClass' on the connection
+ *
+ * @param trustManagerClass
+ * The fully qualified class name of a custom javax.net.ssl.TrustManager.
+ */
+ public void setTrustManagerClass(String trustManagerClass);
+
+ /**
+ * Retrieves value for the connection property 'trustManagerClass'
+ *
+ * @return trustManagerClass property value
+ */
+ public String getTrustManagerClass();
+
+ /**
+ * Sets Constructor Arguments to be provided on constructor of 'trustManagerClass'
+ *
+ * @param trustManagerConstructorArg
+ * 'trustManagerClass' constructor arguments
+ */
+ public void setTrustManagerConstructorArg(String trustManagerConstructorArg);
+
+ /**
+ * Retrieves value for the connection property 'trustManagerConstructorArg'
+ *
+ * @return trustManagerConstructorArg property value
+ */
+ public String getTrustManagerConstructorArg();
+
+ /**
+ * Getting the use Bulk Copy API for Batch Insert
+ *
+ * @return whether the driver should use Bulk Copy API for Batch Insert operations.
+ */
+ public boolean getUseBulkCopyForBatchInsert();
+
+ /**
+ * Setting the use Bulk Copy API for Batch Insert
+ *
+ * @param useBulkCopyForBatchInsert
+ * indicates whether Bulk Copy API should be used for Batch Insert operations.
+ */
+ public void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert);
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java
index ee954f1514..17fc6b558d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java
@@ -8,8 +8,14 @@
package com.microsoft.sqlserver.jdbc;
-import java.sql.SQLException;
+import java.math.BigDecimal;
+import java.sql.ParameterMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLType;
+/**
+ * This interface is implemented by {@link SQLServerPreparedStatement} class.
+ */
public interface ISQLServerPreparedStatement extends java.sql.PreparedStatement, ISQLServerStatement {
/**
* Sets the designated parameter to the given microsoft.sql.DateTimeOffset value.
@@ -18,10 +24,819 @@ public interface ISQLServerPreparedStatement extends java.sql.PreparedStatement,
* the first parameter is 1, the second is 2, ...
* @param x
* the parameter value
- * @throws SQLException
+ * @throws SQLServerException
* if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method
* is called on a closed PreparedStatement
*/
public void setDateTimeOffset(int parameterIndex,
- microsoft.sql.DateTimeOffset x) throws SQLException;
+ microsoft.sql.DateTimeOffset x) throws SQLServerException;
+
+ /**
+ * Sets the value of the designated parameter with the given object.
+ *
+ * This method is similar to {@link #setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)}, except that it assumes a
+ * scale of zero.
+ *
+ * The default implementation will throw {@code SQLFeatureNotSupportedException}
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the object containing the input parameter value
+ * @param targetSqlType
+ * the SQL type to be sent to the database
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method
+ * is called on a closed {@code PreparedStatement}
+ */
+ public void setObject(int parameterIndex,
+ Object x,
+ SQLType targetSqlType,
+ Integer precision,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Sets the value of the designated parameter with the given object.
+ *
+ * This method is similar to {@link #setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)}, except that it assumes a
+ * scale of zero.
+ *
+ * The default implementation will throw {@code SQLFeatureNotSupportedException}
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the object containing the input parameter value
+ * @param targetSqlType
+ * the SQL type to be sent to the database
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method
+ * is called on a closed {@code PreparedStatement}
+ */
+ public void setObject(int parameterIndex,
+ Object x,
+ SQLType targetSqlType,
+ Integer precision,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * The server handle for this prepared statement. If a value {@literal <} 1 is returned no handle has been created.
+ *
+ * @return Per the description.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public int getPreparedStatementHandle() throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setBigDecimal(int parameterIndex,
+ BigDecimal x,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setBigDecimal(int parameterIndex,
+ BigDecimal x,
+ int precision,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setMoney(int parameterIndex,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setMoney(int parameterIndex,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setSmallMoney(int parameterIndex,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setSmallMoney(int parameterIndex,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT or
+ * BOOLEAN value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setBoolean(int parameterIndex,
+ boolean x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java byte value. The driver converts this to an SQL TINYINT value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setByte(int parameterIndex,
+ byte x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or
+ * LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it
+ * to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setBytes(int parameterIndex,
+ byte x[],
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String. The driver converts this to an SQL GUID
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param guid
+ * string representation of the uniqueIdentifier value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setUniqueIdentifier(int parameterIndex,
+ String guid) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String. The driver converts this to an SQL GUID
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param guid
+ * string representation of the uniqueIdentifier value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setUniqueIdentifier(int parameterIndex,
+ String guid,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java double value. The driver converts this to an SQL DOUBLE value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDouble(int parameterIndex,
+ double x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java float value. The driver converts this to an SQL REAL value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setFloat(int parameterIndex,
+ float x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given microsoft.sql.Geometry Class object. The driver converts this to an SQL
+ * REAL value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setGeometry(int parameterIndex,
+ Geometry x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given microsoft.sql.Geography Class object. The driver converts this to an SQL
+ * REAL value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setGeography(int parameterIndex,
+ Geography x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java int value. The driver converts this to an SQL INTEGER value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setInt(int parameterIndex,
+ int value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java long value. The driver converts this to an SQL BIGINT value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setLong(int parameterIndex,
+ long x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ *
+ * Sets the value of the designated parameter with the given object.
+ *
+ *
+ * The given Java object will be converted to the given targetSqlType before being sent to the database.
+ *
+ * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
+ * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
+ * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
+ * Array, the driver should pass it to the database as a value of the corresponding SQL type.
+ *
+ *
+ * Note that this method may be used to pass database-specific abstract data types.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the object containing the input parameter value
+ * @param targetSqlType
+ * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setObject(int parameterIndex,
+ Object x,
+ int targetSqlType,
+ Integer precision,
+ int scale) throws SQLServerException;
+
+ /**
+ *
+ * Sets the value of the designated parameter with the given object.
+ *
+ *
+ * The given Java object will be converted to the given targetSqlType before being sent to the database.
+ *
+ * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
+ * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
+ * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
+ * Array, the driver should pass it to the database as a value of the corresponding SQL type.
+ *
+ *
+ * Note that this method may be used to pass database-specific abstract data types.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the object containing the input parameter value
+ * @param targetSqlType
+ * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setObject(int parameterIndex,
+ Object x,
+ int targetSqlType,
+ Integer precision,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java short value. The driver converts this to an SQL SMALLINT value when
+ * it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setShort(int parameterIndex,
+ short x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given Java String value. The driver converts this to an SQL VARCHAR or
+ * LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends
+ * it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param str
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setString(int parameterIndex,
+ String str,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given String object. The driver converts this to a SQL NCHAR or
+ * NVARCHAR or LONGNVARCHAR value (depending on the argument's size relative to the driver's limits on
+ * NVARCHAR values) when it sends it to the database.
+ *
+ * @param parameterIndex
+ * of the first parameter is 1, the second is 2, ...
+ * @param value
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setNString(int parameterIndex,
+ String value,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTime(int parameterIndex,
+ java.sql.Time x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTime(int parameterIndex,
+ java.sql.Time x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTimestamp(int parameterIndex,
+ java.sql.Timestamp x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTimestamp(int parameterIndex,
+ java.sql.Timestamp x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDateTimeOffset(int parameterIndex,
+ microsoft.sql.DateTimeOffset x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDateTimeOffset(int parameterIndex,
+ microsoft.sql.DateTimeOffset x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDateTime(int parameterIndex,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDateTime(int parameterIndex,
+ java.sql.Timestamp x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setSmallDateTime(int parameterIndex,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setSmallDateTime(int parameterIndex,
+ java.sql.Timestamp x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter with a data table
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param tvpName
+ * the name of the table valued parameter
+ * @param tvpDataTable
+ * the source datatable object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(int parameterIndex,
+ String tvpName,
+ SQLServerDataTable tvpDataTable) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter with a data table
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param tvpName
+ * the name of the table valued parameter
+ * @param tvpResultSet
+ * the source resultset object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(int parameterIndex,
+ String tvpName,
+ ResultSet tvpResultSet) throws SQLServerException;
+
+ /**
+ * Populates a table valued parameter with a data table
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param tvpName
+ * the name of the table valued parameter
+ * @param tvpBulkRecord
+ * an ISQLServerDataRecord object
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setStructured(int parameterIndex,
+ String tvpName,
+ ISQLServerDataRecord tvpBulkRecord) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the
+ * Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a
+ * Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is
+ * specified, the driver uses the default timezone, which is that of the virtual machine running the application.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param cal
+ * the Calendar object the driver will use to construct the date
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setDate(int parameterIndex,
+ java.sql.Date x,
+ java.util.Calendar cal,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it
+ * sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param cal
+ * the Calendar object the driver will use to construct the date
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTime(int parameterIndex,
+ java.sql.Time x,
+ java.util.Calendar cal,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
+ * value when it sends it to the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * the parameter value
+ * @param cal
+ * the Calendar object the driver will use to construct the date
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void setTimestamp(int parameterIndex,
+ java.sql.Timestamp x,
+ java.util.Calendar cal,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Returns parameter metadata for the prepared statement.
+ *
+ * @param forceRefresh:
+ * If true the cache will not be used to retrieve the metadata.
+ *
+ * @return Per the description.
+ *
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public ParameterMetaData getParameterMetaData(boolean forceRefresh) throws SQLServerException;
+
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java
deleted file mode 100644
index 229af83ee3..0000000000
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.SQLType;
-
-/**
- * This interface requires all the PreparedStatement methods including those are specific to JDBC 4.2
- *
- */
-public interface ISQLServerPreparedStatement42 extends ISQLServerPreparedStatement {
-
- public void setObject(int index,
- Object obj,
- SQLType jdbcType) throws SQLServerException;
-
- public void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- int scaleOrLength) throws SQLServerException;
-
- /**
- * Sets the value of the designated parameter with the given object.
- *
- * This method is similar to {@link #setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)}, except that it assumes a
- * scale of zero.
- *
- * The default implementation will throw {@code SQLFeatureNotSupportedException}
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the object containing the input parameter value
- * @param targetSqlType
- * the SQL type to be sent to the database
- * @param precision
- * the precision of the column
- * @param scale
- * the scale of the column
- * @throws SQLServerException
- * if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method
- * is called on a closed {@code PreparedStatement}
- */
- public void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- Integer precision,
- Integer scale) throws SQLServerException;
-
- /**
- * Sets the value of the designated parameter with the given object.
- *
- * This method is similar to {@link #setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)}, except that it assumes a
- * scale of zero.
- *
- * The default implementation will throw {@code SQLFeatureNotSupportedException}
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the object containing the input parameter value
- * @param targetSqlType
- * the SQL type to be sent to the database
- * @param precision
- * the precision of the column
- * @param scale
- * the scale of the column
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method
- * is called on a closed {@code PreparedStatement}
- */
- public void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- Integer precision,
- Integer scale,
- boolean forceEncrypt) throws SQLServerException;
-}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java
index d0bab83cfc..e9fa6ccb6d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java
@@ -8,8 +8,15 @@
package com.microsoft.sqlserver.jdbc;
-import java.sql.SQLException;
+import java.math.BigDecimal;
+import java.sql.SQLType;
+import java.util.Calendar;
+import com.microsoft.sqlserver.jdbc.dataclassification.SensitivityClassification;
+
+/**
+ * This interface is implemented by {@link SQLServerResultSet} class.
+ */
public interface ISQLServerResultSet extends java.sql.ResultSet {
public static final int TYPE_SS_DIRECT_FORWARD_ONLY = 2003; // TYPE_FORWARD_ONLY + 1000
@@ -23,16 +30,195 @@ public interface ISQLServerResultSet extends java.sql.ResultSet {
public static final int CONCUR_SS_SCROLL_LOCKS = 1009; // CONCUR_UPDATABLE + 1
public static final int CONCUR_SS_OPTIMISTIC_CCVAL = 1010; // CONCUR_UPDATABLE + 2
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a com.microsoft.sqlserver.jdbc.Geometry object in
+ * the Java programming language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Geometry getGeometry(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a com.microsoft.sqlserver.jdbc.Geometry object in
+ * the Java programming language.
+ *
+ * @param columnName
+ * the name of the column
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Geometry getGeometry(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a com.microsoft.sqlserver.jdbc.Geography object in
+ * the Java programming language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Geography getGeography(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a com.microsoft.sqlserver.jdbc.Geography object in
+ * the Java programming language.
+ *
+ * @param columnName
+ * the name of the column
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public Geography getGeography(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a String object in the Java programming language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public String getUniqueIdentifier(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a String object in the Java programming language.
+ *
+ * @param columnLabel
+ * the name of the column
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public String getUniqueIdentifier(String columnLabel) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public java.sql.Timestamp getDateTime(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param columnName
+ * is the name of the column
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getDateTime(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
+ * not store timezone information.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @param cal
+ * the java.util.Calendar object to use in constructing the dateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getDateTime(int columnIndex,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
+ * not store timezone information.
+ *
+ * @param colName
+ * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
+ * column
+ * @param cal
+ * the java.util.Calendar object to use in constructing the dateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getDateTime(String colName,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public java.sql.Timestamp getSmallDateTime(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param columnName
+ * is the name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getSmallDateTime(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
+ * language.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @param cal
+ * the java.util.Calendar object to use in constructing the smalldateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getSmallDateTime(int columnIndex,
+ Calendar cal) throws SQLServerException;
+
+ /**
+ *
+ * @param colName
+ * The name of a column
+ * @param cal
+ * the java.util.Calendar object to use in constructing the smalldateTime
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public java.sql.Timestamp getSmallDateTime(String colName,
+ Calendar cal) throws SQLServerException;
+
/**
* Retrieves the value of the designated column as a microsoft.sql.DateTimeOffset object, given a zero-based column ordinal.
*
* @param columnIndex
* The zero-based ordinal of a column.
* @return A DateTimeOffset Class object.
- * @throws SQLException
+ * @throws SQLServerException
* when an error occurs
*/
- public microsoft.sql.DateTimeOffset getDateTimeOffset(int columnIndex) throws SQLException;
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(int columnIndex) throws SQLServerException;
/**
* Retrieves the value of the column specified as a microsoft.sql.DateTimeOffset object, given a column name.
@@ -40,10 +226,54 @@ public interface ISQLServerResultSet extends java.sql.ResultSet {
* @param columnName
* The name of a column.
* @return A DateTimeOffset Class object.
- * @throws SQLException
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param columnIndex
+ * The zero-based ordinal of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
* when an error occurs
*/
- public microsoft.sql.DateTimeOffset getDateTimeOffset(String columnName) throws SQLException;
+ public BigDecimal getMoney(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param columnName
+ * is the name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public BigDecimal getMoney(String columnName) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param columnIndex
+ * The zero-based ordinal of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public BigDecimal getSmallMoney(int columnIndex) throws SQLServerException;
+
+ /**
+ * Retrieves the value of the column specified as a java.math.BigDecimal object.
+ *
+ * @param columnName
+ * is the name of a column.
+ * @return the column value; if the value is SQL NULL, the value returned is null.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public BigDecimal getSmallMoney(String columnName) throws SQLServerException;
/**
* Updates the value of the column specified to the DateTimeOffset Class value, given a zero-based column ordinal.
@@ -52,11 +282,11 @@ public interface ISQLServerResultSet extends java.sql.ResultSet {
* The zero-based ordinal of a column.
* @param x
* A DateTimeOffset Class object.
- * @throws SQLException
+ * @throws SQLServerException
* when an error occurs
*/
public void updateDateTimeOffset(int index,
- microsoft.sql.DateTimeOffset x) throws SQLException;
+ microsoft.sql.DateTimeOffset x) throws SQLServerException;
/**
* Updates the value of the column specified to the DateTimeOffset Class value, given a column name.
@@ -65,10 +295,1408 @@ public void updateDateTimeOffset(int index,
* The name of a column.
* @param x
* A DateTimeOffset Class object.
- * @throws SQLException
+ * @throws SQLServerException
* when an error occurs
*/
public void updateDateTimeOffset(String columnName,
- microsoft.sql.DateTimeOffset x) throws SQLException;
+ microsoft.sql.DateTimeOffset x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an {@code Object} value.
+ *
+ * The updater methods are used to update column values in the current row or the insert row. The updater methods do not update the underlying
+ * database; instead the {@code updateRow} or {@code insertRow} methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateObject(int index,
+ Object x,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an Object value. The updater methods are used to update column values in the current row or the insert row.
+ * The updater methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the database. If the
+ * second argument is an InputStream then the stream must contain the number of bytes specified by scaleOrLength. If the second argument is a
+ * Reader then the reader must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver will
+ * generate a SQLServerException when the statement is executed. The default implementation will throw SQLFeatureNotSupportedException
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param obj
+ * the new column value
+ * @param targetSqlType
+ * the SQL type to be sent to the database
+ * @param scale
+ * for an object of java.math.BigDecimal , this is the number of digits after the decimal point. For Java Object types InputStream and
+ * Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement.If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateObject(int index,
+ Object obj,
+ SQLType targetSqlType,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ *
+ * Updates the designated column with an Object value. The updater methods are used to update column values in the current row or the insert row.
+ * The updater methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the database. If the
+ * second argument is an InputStream then the stream must contain the number of bytes specified by scaleOrLength. If the second argument is a
+ * Reader then the reader must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver will
+ * generate a SQLServerException when the statement is executed. The default implementation will throw SQLFeatureNotSupportedException
+ *
+ * @param columnName
+ * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
+ * column
+ * @param obj
+ * the new column value
+ * @param targetSqlType
+ * the SQL type to be sent to the database
+ * @param scale
+ * for an object of java.math.BigDecimal , this is the number of digits after the decimal point. For Java Object types InputStream and
+ * Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement.If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateObject(String columnName,
+ Object obj,
+ SQLType targetSqlType,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a boolean value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateBoolean(int index,
+ boolean x,
+ boolean forceEncrypt) throws SQLServerException;
+ /**
+ * Updates the designated column with a byte value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateByte(int index,
+ byte x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a short value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateShort(int index,
+ short x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an int value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateInt(int index,
+ int x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a long value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateLong(int index,
+ long x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a float value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateFloat(int index,
+ float x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a double value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDouble(int index,
+ double x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a money value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateMoney(int index,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a money value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateMoney(int index,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a money value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * the column name
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateMoney(String columnName,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a money value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * the column name
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateMoney(String columnName,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a smallmoney value. The updater methods are used to update column values in the current row or
+ * the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods
+ * are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateSmallMoney(int index,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a smallmoney value. The updater methods are used to update column values in the current row or
+ * the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods
+ * are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateSmallMoney(int index,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a smallmoney value. The updater methods are used to update column values in the current row or
+ * the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods
+ * are called to update the database.
+ *
+ * @param columnName
+ * the column name
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateSmallMoney(String columnName,
+ BigDecimal x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a smallmoney value. The updater methods are used to update column values in the current row or
+ * the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods
+ * are called to update the database.
+ *
+ * @param columnName
+ * the column name
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateSmallMoney(String columnName,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.math.BigDecimal value. The updater methods are used to update column values in the
+ * current row or the insert row. The updater methods do not update the underlying database; instead the updateRow or
+ * insertRow methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateBigDecimal(int index,
+ BigDecimal x,
+ Integer precision,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.math.BigDecimal value. The updater methods are used to update column values in the
+ * current row or the insert row. The updater methods do not update the underlying database; instead the updateRow or
+ * insertRow methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateBigDecimal(int index,
+ BigDecimal x,
+ Integer precision,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnIndex
+ * the first column is 1, the second is 2, ...
+ * @param stringValue
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateString(int columnIndex,
+ String stringValue,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. It is intended for use when updating NCHAR,NVARCHAR
+ * and LONGNVARCHAR columns. The updater methods are used to update column values in the current row or the insert row. The updater
+ * methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the
+ * database.
+ *
+ * @param columnIndex
+ * the first column is 1, the second 2, ...
+ * @param nString
+ * the value for the column to be updated
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateNString(int columnIndex,
+ String nString,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. It is intended for use when updating NCHAR,NVARCHAR
+ * and LONGNVARCHAR columns. The updater methods are used to update column values in the current row or the insert row. The updater
+ * methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the
+ * database.
+ *
+ * @param columnLabel
+ * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
+ * column
+ * @param nString
+ * the value for the column to be updated
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateNString(String columnLabel,
+ String nString,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a byte array value. The updater methods are used to update column values in the current row or
+ * the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods
+ * are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateBytes(int index,
+ byte x[],
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Date value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDate(int index,
+ java.sql.Date x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Time value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateTime(int index,
+ java.sql.Time x,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Time value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateTime(int index,
+ java.sql.Time x,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateTimestamp(int index,
+ java.sql.Timestamp x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateTimestamp(int index,
+ java.sql.Timestamp x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDateTime(int index,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDateTime(int index,
+ java.sql.Timestamp x,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDateTime(int index,
+ java.sql.Timestamp x,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateSmallDateTime(int index,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateSmallDateTime(int index,
+ java.sql.Timestamp x,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateSmallDateTime(int index,
+ java.sql.Timestamp x,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the value of the column specified to the DateTimeOffset Class value, given a zero-based column ordinal.
+ *
+ * @param index
+ * The zero-based ordinal of a column.
+ * @param x
+ * A DateTimeOffset Class object.
+ * @param scale
+ * scale of the column
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDateTimeOffset(int index,
+ microsoft.sql.DateTimeOffset x,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the value of the column specified to the DateTimeOffset Class value, given a zero-based column ordinal.
+ *
+ * @param index
+ * The zero-based ordinal of a column.
+ * @param x
+ * A DateTimeOffset Class object.
+ * @param scale
+ * scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateDateTimeOffset(int index,
+ microsoft.sql.DateTimeOffset x,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * The zero-based ordinal of a column.
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateUniqueIdentifier(int index,
+ String x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param index
+ * The zero-based ordinal of a column.
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateUniqueIdentifier(int index,
+ String x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an {@code Object} value.
+ *
+ * The updater methods are used to update column values in the current row or the insert row. The updater methods do not update the underlying
+ * database; instead the {@code updateRow} or {@code insertRow} methods are called to update the database.
+ *
+ * @param index
+ * the first column is 1, the second is 2, ...
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateObject(int index,
+ Object x,
+ int precision,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a boolean value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public void updateBoolean(String columnName,
+ boolean x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a byte value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ *
+ * @param columnName
+ * the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateByte(String columnName,
+ byte x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a short value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateShort(String columnName,
+ short x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an int value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateInt(String columnName,
+ int x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a long value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateLong(String columnName,
+ long x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a float value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateFloat(String columnName,
+ float x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a double value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDouble(String columnName,
+ double x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.BigDecimal value. The updater methods are used to update column values in the
+ * current row or the insert row. The updater methods do not update the underlying database; instead the updateRow or
+ * insertRow methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateBigDecimal(String columnName,
+ BigDecimal x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.BigDecimal value. The updater methods are used to update column values in the
+ * current row or the insert row. The updater methods do not update the underlying database; instead the updateRow or
+ * insertRow methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set
+ * to false, the driver will not force encryption on parameters.
+ * @param x
+ * BigDecimal value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateBigDecimal(String columnName,
+ BigDecimal x,
+ Integer precision,
+ Integer scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.BigDecimal value. The updater methods are used to update column values in the
+ * current row or the insert row. The updater methods do not update the underlying database; instead the updateRow or
+ * insertRow methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set
+ * to false, the driver will not force encryption on parameters.
+ * @param x
+ * BigDecimal value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateBigDecimal(String columnName,
+ BigDecimal x,
+ Integer precision,
+ Integer scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a String value. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateString(String columnName,
+ String x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a byte array value.
+ *
+ * The updater methods are used to update column values in the current row or the insert row. The updater methods do not update the underlying
+ * database; instead the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateBytes(String columnName,
+ byte x[],
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Date value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDate(String columnName,
+ java.sql.Date x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Time value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateTime(String columnName,
+ java.sql.Time x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Time value. The updater methods are used to update column values in the current row
+ * or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateTime(String columnName,
+ java.sql.Time x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateTimestamp(String columnName,
+ java.sql.Timestamp x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateTimestamp(String columnName,
+ java.sql.Timestamp x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDateTime(String columnName,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDateTime(String columnName,
+ java.sql.Timestamp x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDateTime(String columnName,
+ java.sql.Timestamp x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateSmallDateTime(String columnName,
+ java.sql.Timestamp x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateSmallDateTime(String columnName,
+ java.sql.Timestamp x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a java.sql.Timestamp value. The updater methods are used to update column values in the current
+ * row or the insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow
+ * methods are called to update the database.
+ *
+ * @param columnName
+ * is the name of the column
+ * @param x
+ * the new column value
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateSmallDateTime(String columnName,
+ java.sql.Timestamp x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the value of the column specified to the DateTimeOffset Class value, given a column name.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * A DateTimeOffset Class object.
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDateTimeOffset(String columnName,
+ microsoft.sql.DateTimeOffset x,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the value of the column specified to the DateTimeOffset Class value, given a column name.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * A DateTimeOffset Class object.
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateDateTimeOffset(String columnName,
+ microsoft.sql.DateTimeOffset x,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a Stringvalue. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * the new column value
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateUniqueIdentifier(String columnName,
+ String x) throws SQLServerException;
+
+ /**
+ * Updates the designated column with a Stringvalue. The updater methods are used to update column values in the current row or the
+ * insert row. The updater methods do not update the underlying database; instead the updateRow or insertRow methods are
+ * called to update the database.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * the new column value
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateUniqueIdentifier(String columnName,
+ String x,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an {@code Object} value.
+ *
+ * The updater methods are used to update column values in the current row or the insert row. The updater methods do not update the underlying
+ * database; instead the {@code updateRow} or {@code insertRow} methods are called to update the database.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateObject(String columnName,
+ Object x,
+ int precision,
+ int scale) throws SQLServerException;
+
+ /**
+ * Updates the designated column with an {@code Object} value.
+ *
+ * The updater methods are used to update column values in the current row or the insert row. The updater methods do not update the underlying
+ * database; instead the {@code updateRow} or {@code insertRow} methods are called to update the database.
+ *
+ * @param columnName
+ * The name of a column.
+ * @param x
+ * the new column value
+ * @param precision
+ * the precision of the column
+ * @param scale
+ * the scale of the column
+ * @param forceEncrypt
+ * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
+ * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
+ * encryption on parameters.
+ * @throws SQLServerException
+ * If any errors occur.
+ */
+ public void updateObject(String columnName,
+ Object x,
+ int precision,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException;
+
+ /**
+ * Exposes Data Classification information for the current ResultSet For SQL Servers that do not support Data Classification or results that do
+ * not fetch any classified columns, this data can be null
+ *
+ * @return SensitivityClassification
+ */
+ public SensitivityClassification getSensitivityClassification();
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java
deleted file mode 100644
index 1f75ec99ff..0000000000
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.SQLType;
-
-/**
- * This interface requires all the ResultSet methods including those are specific to JDBC 4.2
- *
- */
-public interface ISQLServerResultSet42 extends ISQLServerResultSet {
-
- public void updateObject(int index,
- Object obj,
- SQLType targetSqlType) throws SQLServerException;
-
- public void updateObject(int index,
- Object obj,
- SQLType targetSqlType,
- int scale) throws SQLServerException;
-
- /**
- * Updates the designated column with an Object value. The updater methods are used to update column values in the current row or the insert row.
- * The updater methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the database. If the
- * second argument is an InputStream then the stream must contain the number of bytes specified by scaleOrLength. If the second argument is a
- * Reader then the reader must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver will
- * generate a SQLException when the statement is executed. The default implementation will throw SQLFeatureNotSupportedException
- *
- * @param index
- * the first column is 1, the second is 2, ...
- * @param obj
- * the new column value
- * @param targetSqlType
- * the SQL type to be sent to the database
- * @param scale
- * for an object of java.math.BigDecimal , this is the number of digits after the decimal point. For Java Object types InputStream and
- * Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement.If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * If any errors occur.
- */
- public void updateObject(int index,
- Object obj,
- SQLType targetSqlType,
- int scale,
- boolean forceEncrypt) throws SQLServerException;
-
- public void updateObject(String columnName,
- Object obj,
- SQLType targetSqlType,
- int scale) throws SQLServerException;
-
- /**
- *
- * Updates the designated column with an Object value. The updater methods are used to update column values in the current row or the insert row.
- * The updater methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the database. If the
- * second argument is an InputStream then the stream must contain the number of bytes specified by scaleOrLength. If the second argument is a
- * Reader then the reader must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver will
- * generate a SQLException when the statement is executed. The default implementation will throw SQLFeatureNotSupportedException
- *
- * @param columnName
- * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
- * column
- * @param obj
- * the new column value
- * @param targetSqlType
- * the SQL type to be sent to the database
- * @param scale
- * for an object of java.math.BigDecimal , this is the number of digits after the decimal point. For Java Object types InputStream and
- * Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement.If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * If any errors occur.
- */
- public void updateObject(String columnName,
- Object obj,
- SQLType targetSqlType,
- int scale,
- boolean forceEncrypt) throws SQLServerException;
-
- public void updateObject(String columnName,
- Object obj,
- SQLType targetSqlType) throws SQLServerException;
-}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java
new file mode 100644
index 0000000000..25f88d7332
--- /dev/null
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.sql.ResultSetMetaData;
+
+/**
+ * This interface is implemented by {@link SQLServerResultSetMetaData} class.
+ */
+public interface ISQLServerResultSetMetaData extends ResultSetMetaData {
+
+ /**
+ * Returns true if the column is a SQLServer SparseColumnSet
+ *
+ * @param column
+ * The column number
+ * @return true if a column in a result set is a sparse column set, otherwise false.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public boolean isSparseColumnSet(int column) throws SQLServerException;
+
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java
new file mode 100644
index 0000000000..4fd4dbb1a8
--- /dev/null
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.sql.Savepoint;
+
+/**
+ * This interface is implemented by {@link SQLServerSavepoint} class.
+ */
+public interface ISQLServerSavepoint extends Savepoint {
+
+ /**
+ * Get the savepoint name
+ *
+ * @return the name of savepoint
+ */
+ public String getSavepointName() throws SQLServerException;
+
+ /**
+ * Get the savepoint label
+ *
+ * @return the label for Savepoint
+ */
+ public String getLabel();
+
+ /**
+ * Checks if the savepoint label is null
+ *
+ * @return true is the savepoint is named. Otherwise, false.
+ */
+ public boolean isNamed();
+
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java
index 518a74cb2e..a1ba642a7c 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java
@@ -1,39 +1,62 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-public interface ISQLServerStatement extends java.sql.Statement {
- /**
- * Sets the response buffering mode for this SQLServerStatement object to case-insensitive String full or adaptive.
- *
- * Response buffering controls the driver's buffering of responses from SQL Server.
- *
- * Possible values are:
- *
- * "full" - Fully buffer the response at execution time.
- *
- * "adaptive" - Data Pipe adaptive buffering
- *
- * @param value
- * A String that contains the response buffering mode. The valid mode can be one of the following case-insensitive Strings: full or
- * adaptive.
- * @throws SQLServerException
- * If there are any errors in setting the response buffering mode.
- */
- public void setResponseBuffering(String value) throws SQLServerException;
-
- /**
- * Retrieves the response buffering mode for this SQLServerStatement object.
- *
- * @return A String that contains a lower-case full or adaptive.
- * @throws SQLServerException
- * If there are any errors in retrieving the response buffering mode.
- */
- public String getResponseBuffering() throws SQLServerException;
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+/**
+ * This interface is implemented by {@link SQLServerStatement} class.
+ */
+public interface ISQLServerStatement extends java.sql.Statement {
+ /**
+ * Sets the response buffering mode for this SQLServerStatement object to case-insensitive String full or adaptive.
+ *
+ * Response buffering controls the driver's buffering of responses from SQL Server.
+ *
+ * Possible values are:
+ *
+ * "full" - Fully buffer the response at execution time.
+ *
+ * "adaptive" - Data Pipe adaptive buffering
+ *
+ * @param value
+ * A String that contains the response buffering mode. The valid mode can be one of the following case-insensitive Strings: full or
+ * adaptive.
+ * @throws SQLServerException
+ * If there are any errors in setting the response buffering mode.
+ */
+ public void setResponseBuffering(String value) throws SQLServerException;
+
+ /**
+ * Retrieves the response buffering mode for this SQLServerStatement object.
+ *
+ * @return A String that contains a lower-case full or adaptive.
+ * @throws SQLServerException
+ * If there are any errors in retrieving the response buffering mode.
+ */
+ public String getResponseBuffering() throws SQLServerException;
+
+ /**
+ * Retrieves the cancelQueryTimeout property set on this SQLServerStatement object.
+ *
+ * @return cancelQueryTimeout Time duration in seconds.
+ * @throws SQLServerException
+ * if any error occurs
+ */
+ public int getCancelQueryTimeout() throws SQLServerException;
+
+ /**
+ * Sets the cancelQueryTimeout property on this SQLServerStatement object to cancel queryTimeout set on Connection or
+ * Statement level.
+ *
+ * @param seconds
+ * Time duration in seconds.
+ * @throws SQLServerException
+ * if any error occurs
+ */
+ public void setCancelQueryTimeout(int seconds) throws SQLServerException;
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java
index a4fc6edfb6..003e30f5d4 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java
@@ -1,3 +1,11 @@
+/*
+ * 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.
+ */
+
package com.microsoft.sqlserver.jdbc;
public enum InternalSpatialDatatype {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
index 01ace73651..d3707c2fe1 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java
@@ -49,6 +49,7 @@ final class KerbAuthentication extends SSPIAuthentication {
private final GSSManager manager = GSSManager.getInstance();
private LoginContext lc = null;
+ private boolean isUserCreatedCredential = false;
private GSSCredential peerCredentials = null;
private GSSContext peerContext = null;
@@ -388,9 +389,10 @@ interface RealmValidator {
KerbAuthentication(SQLServerConnection con,
String address,
int port,
- GSSCredential ImpersonatedUserCred) throws SQLServerException {
+ GSSCredential ImpersonatedUserCred, Boolean isUserCreated) throws SQLServerException {
this(con, address, port);
peerCredentials = ImpersonatedUserCred;
+ this.isUserCreatedCredential = (isUserCreated == null ? false : isUserCreated);
}
byte[] GenerateClientContext(byte[] pin,
@@ -403,8 +405,11 @@ byte[] GenerateClientContext(byte[] pin,
int ReleaseClientContext() throws SQLServerException {
try {
- if (null != peerCredentials)
+ if (null != peerCredentials && !isUserCreatedCredential) {
peerCredentials.dispose();
+ } else if (null != peerCredentials && isUserCreatedCredential) {
+ peerCredentials = null;
+ }
if (null != peerContext)
peerContext.dispose();
if (null != lc)
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java
index 6f861c4bbd..f2e3120083 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java
@@ -1,3 +1,11 @@
+/*
+ * 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.
+ */
+
package com.microsoft.sqlserver.jdbc;
import java.io.IOException;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java
index d0b5693c3d..4700782423 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java
@@ -24,8 +24,10 @@
*/
class KeyVaultCredential extends KeyVaultCredentials {
+ SQLServerKeyVaultAuthenticationCallback authenticationCallback = null;
String clientId = null;
String clientKey = null;
+ String accessToken = null;
KeyVaultCredential(String clientId,
String clientKey) {
@@ -33,11 +35,22 @@ class KeyVaultCredential extends KeyVaultCredentials {
this.clientKey = clientKey;
}
+ KeyVaultCredential(SQLServerKeyVaultAuthenticationCallback authenticationCallback) {
+ this.authenticationCallback = authenticationCallback;
+ }
+
public String doAuthenticate(String authorization,
String resource,
String scope) {
- AuthenticationResult token = getAccessTokenFromClientCredentials(authorization, resource, clientId, clientKey);
- return token.getAccessToken();
+ String accessToken;
+ if (null == authenticationCallback) {
+ AuthenticationResult token = getAccessTokenFromClientCredentials(authorization, resource, clientId, clientKey);
+ accessToken = token.getAccessToken();
+ }
+ else {
+ accessToken = authenticationCallback.getAccessToken(authorization, resource, scope);
+ }
+ return accessToken;
}
private static AuthenticationResult getAccessTokenFromClientCredentials(String authorization,
@@ -61,7 +74,7 @@ private static AuthenticationResult getAccessTokenFromClientCredentials(String a
service.shutdown();
}
- if (result == null) {
+ if (null == result) {
throw new RuntimeException("authentication result was null");
}
return result;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
index b614ad5fe3..2a9c757d04 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
@@ -415,6 +415,10 @@ Object getValue(JDBCType jdbcType,
// statement level), cryptoMeta would be null.
return getterDTV.getValue(jdbcType, outScale, getterArgs, cal, typeInfo, cryptoMeta, tdsReader);
}
+
+ Object getSetterValue() {
+ return setterDTV.getSetterValue();
+ }
int getInt(TDSReader tdsReader) throws SQLServerException {
Integer value = (Integer) getValue(JDBCType.INTEGER, null, null, tdsReader);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
index d89a95e111..6dcf58cf6c 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
@@ -35,10 +35,16 @@
*/
final class SQLCollation implements java.io.Serializable
{
- private final int info; // First 4 bytes of TDS collation.
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6748833280721312349L;
+
+ private final int info; // First 4 bytes of TDS collation.
private int langID() { return info & 0x0000FFFF; }
private final int sortId; // 5th byte of TDS collation.
private final Encoding encoding;
+ private static final int UTF8_IN_TDSCOLLATION = 0x4000000;
// Utility methods for getting details of this collation's encoding
final Charset getCharset() throws SQLServerException { return encoding.charset(); }
@@ -77,8 +83,13 @@ int getCollationSortID() {
*/
info = tdsReader.readInt(); // 4 bytes, contains: LCID ColFlags Version
sortId = tdsReader.readUnsignedByte(); // 1 byte, contains: SortId
- // For a SortId==0 collation, the LCID bits correspond to a LocaleId
- encoding = (0 == sortId) ? encodingFromLCID() : encodingFromSortId();
+ if (UTF8_IN_TDSCOLLATION == (info & UTF8_IN_TDSCOLLATION)) {
+ encoding = Encoding.UTF8;
+ }
+ else {
+ // For a SortId==0 collation, the LCID bits correspond to a LocaleId
+ encoding = (0 == sortId) ? encodingFromLCID() : encodingFromSortId();
+ }
}
/**
@@ -549,6 +560,7 @@ private Encoding encodingFromSortId() throws UnsupportedEncodingException {
enum Encoding
{
UNICODE ("UTF-16LE", true, false),
+ UTF8 ("UTF-8", true, false),
CP437 ("Cp437", false, false),
CP850 ("Cp850", false, false),
CP874 ("MS874", true, true),
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
index c27ee70de5..41028eb8e7 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java
@@ -11,6 +11,6 @@
final class SQLJdbcVersion {
static final int major = 6;
static final int minor = 5;
- static final int patch = 1;
+ static final int patch = 4;
static final int build = 0;
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerADAL4JUtils.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerADAL4JUtils.java
index 096543ffdc..a04b98296a 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerADAL4JUtils.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerADAL4JUtils.java
@@ -1,3 +1,11 @@
+/*
+ * 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.
+ */
+
package com.microsoft.sqlserver.jdbc;
import java.io.IOException;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java
index 9dc4017171..3631e23744 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java
@@ -12,9 +12,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
-import java.sql.Blob;
import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
@@ -25,7 +23,10 @@
* SQLServerBlob represents a binary LOB object and implements a java.sql.Blob.
*/
-public final class SQLServerBlob implements java.sql.Blob, java.io.Serializable {
+public final class SQLServerBlob extends SQLServerLob implements java.sql.Blob, java.io.Serializable {
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
private static final long serialVersionUID = -3526170228097889085L;
// The value of the BLOB that this Blob object represents.
@@ -38,15 +39,17 @@ public final class SQLServerBlob implements java.sql.Blob, java.io.Serializable
// Active streams which must be closed when the Blob is closed
//
// Initial size of the array is based on an assumption that a Blob object is
- // typically used either for input or output, and then only once. The array size
+ // typically used either for input or output, and then only once. The array
+ // size
// grows automatically if multiple streams are used.
ArrayList activeStreams = new ArrayList<>(1);
static private final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerBlob");
- static private final AtomicInteger baseID = new AtomicInteger(0); // Unique id generator for each instance (used for logging).
+ // Unique id generator for each instance (use for logging).
+ static private final AtomicInteger baseID = new AtomicInteger(0);
final private String traceID;
-
+
final public String toString() {
return traceID;
}
@@ -63,7 +66,7 @@ private static int nextInstanceID() {
* the database connection this blob is implemented on
* @param data
* the BLOB's data
- * @deprecated Use {@link SQLServerConnection#createBlob()} instead.
+ * @deprecated Use {@link SQLServerConnection#createBlob()} instead.
*/
@Deprecated
public SQLServerBlob(SQLServerConnection connection,
@@ -71,8 +74,10 @@ public SQLServerBlob(SQLServerConnection connection,
traceID = " SQLServerBlob:" + nextInstanceID();
con = connection;
- // Disallow Blobs with internal null values. We throw a NullPointerException here
- // because the method signature of the public constructor does not permit a SQLException
+ // Disallow Blobs with internal null values. We throw a
+ // NullPointerException here
+ // because the method signature of the public constructor does not
+ // permit a SQLException
// to be thrown.
if (null == data)
throw new NullPointerException(SQLServerException.getErrString("R_cantSetNull"));
@@ -100,15 +105,11 @@ public SQLServerBlob(SQLServerConnection connection,
logger.fine(toString() + " created by (null connection)");
}
- /**
- * Frees this Blob object and releases the resources that it holds.
- *
- * After free() has been called, any attempt to invoke a method other than free() will result in a SQLException being thrown. If free() is called
- * multiple times, the subsequent calls to free are treated as a no-op.
- */
+ @Override
public void free() throws SQLException {
if (!isClosed) {
- // Close active streams, ignoring any errors, since nothing can be done with them after that point anyway.
+ // Close active streams, ignoring any errors, since nothing can be
+ // done with them after that point anyway.
if (null != activeStreams) {
for (Closeable stream : activeStreams) {
try {
@@ -123,7 +124,6 @@ public void free() throws SQLException {
// Discard the value
value = null;
-
isClosed = true;
}
}
@@ -138,9 +138,9 @@ private void checkClosed() throws SQLServerException {
}
}
+ @Override
public InputStream getBinaryStream() throws SQLException {
checkClosed();
-
if (null == value && !activeStreams.isEmpty()) {
InputStream stream = (InputStream) activeStreams.get(0);
try {
@@ -159,10 +159,11 @@ public InputStream getBinaryStream() throws SQLException {
}
}
+ @Override
public InputStream getBinaryStream(long pos,
long length) throws SQLException {
- // Not implemented - partial materialization
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwFeatureNotSupportedException();
+ return null;
}
private InputStream getBinaryStreamInternal(int pos,
@@ -177,19 +178,7 @@ private InputStream getBinaryStreamInternal(int pos,
return getterStream;
}
- /**
- * Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes. This byte array contains up to length
- * consecutive bytes starting at position pos.
- *
- * @param pos
- * - the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
- * @param length
- * - the number of consecutive bytes to be copied; the value for length must be 0 or greater
- * @return a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at
- * position pos
- * @throws SQLException
- * - if there is an error accessing the BLOB value; if pos is less than 1 or length is less than 0
- */
+ @Override
public byte[] getBytes(long pos,
int length) throws SQLException {
checkClosed();
@@ -223,34 +212,26 @@ public byte[] getBytes(long pos,
return bTemp;
}
- /**
- * Return the length of the BLOB
- *
- * @throws SQLException
- * when an error occurs
- * @return the data length
- */
+ @Override
public long length() throws SQLException {
checkClosed();
if (value == null && activeStreams.get(0) instanceof PLPInputStream) {
- return (long)((PLPInputStream)activeStreams.get(0)).payloadLength;
+ return (long) ((PLPInputStream) activeStreams.get(0)).payloadLength;
}
getBytesFromStream();
return value.length;
}
-
- /**
- * Function for the result set to maintain blobs it has created
- * @throws SQLException
- */
- void fillByteArray() throws SQLException {
- if(!isClosed) {
- getBytesFromStream();
- }
+
+ @Override
+ void fillFromStream() throws SQLException {
+ if (!isClosed) {
+ getBytesFromStream();
+ }
}
-
+
/**
* Converts stream to byte[]
+ *
* @throws SQLServerException
*/
private void getBytesFromStream() throws SQLServerException {
@@ -266,21 +247,11 @@ private void getBytesFromStream() throws SQLServerException {
}
}
- /**
- * Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins. The search begins at position start.
- *
- * @param pattern
- * - the Blob object designating the BLOB value for which to search
- * @param start
- * - the position in the BLOB value at which to begin searching; the first position is 1
- * @return the postion at which the pattern begins, else -1
- * @throws SQLException
- * - if there is an error accessing the BLOB value or if start is less than 1
- */
- public long position(Blob pattern,
+ @Override
+ public long position(java.sql.Blob pattern,
long start) throws SQLException {
checkClosed();
-
+
getBytesFromStream();
if (start < 1) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPositionIndex"));
@@ -294,18 +265,7 @@ public long position(Blob pattern,
return position(pattern.getBytes((long) 1, (int) pattern.length()), start);
}
- /**
- * Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents. The search
- * for pattern begins at position start.
- *
- * @param bPattern
- * - the byte array for which to search
- * @param start
- * - the position at which to begin searching; the first position is 1
- * @return the position at which the pattern appears, else -1
- * @throws SQLException
- * - if there is an error accessing the BLOB or if start is less than 1
- */
+ @Override
public long position(byte[] bPattern,
long start) throws SQLException {
checkClosed();
@@ -316,7 +276,8 @@ public long position(byte[] bPattern,
SQLServerException.makeFromDriverError(con, null, form.format(msgArgs), null, true);
}
- // Back compat: Handle null search string as not found rather than throw an exception.
+ // Back compat: Handle null search string as not found rather than throw
+ // an exception.
// JDBC spec doesn't describe the behavior for a null pattern.
if (null == bPattern)
return -1;
@@ -342,20 +303,11 @@ public long position(byte[] bPattern,
return -1;
}
- /* JDBC 3.0 methods */
-
- /**
- * Truncate a BLOB
- *
- * @param len
- * the new length for the BLOB
- * @throws SQLException
- * when an error occurs
- */
+ @Override
public void truncate(long len) throws SQLException {
checkClosed();
getBytesFromStream();
-
+
if (len < 0) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidLength"));
Object[] msgArgs = {len};
@@ -369,15 +321,7 @@ public void truncate(long len) throws SQLException {
}
}
- /**
- * Retrieves a stream that can be used to write to the BLOB value that this Blob object represents
- *
- * @param pos
- * - the position in the BLOB value at which to start writing; the first position is 1
- * @return a java.io.OutputStream object to which data can be written
- * @throws SQLException
- * - if there is an error accessing the BLOB value or if pos is less than 1
- */
+ @Override
public java.io.OutputStream setBinaryStream(long pos) throws SQLException {
checkClosed();
@@ -389,21 +333,11 @@ public java.io.OutputStream setBinaryStream(long pos) throws SQLException {
return new SQLServerBlobOutputStream(this, pos);
}
- /**
- * Writes the given array of bytes into the Blob starting at position pos, and returns the number of bytes written.
- *
- * @param pos
- * the position (1 based) in the Blob object at which to start writing the data.
- * @param bytes
- * the array of bytes to be written into the Blob.
- * @throws SQLException
- * if there is an error accessing the BLOB value.
- * @return the number of bytes written.
- */
+ @Override
public int setBytes(long pos,
byte[] bytes) throws SQLException {
checkClosed();
-
+
getBytesFromStream();
if (null == bytes)
SQLServerException.makeFromDriverError(con, null, SQLServerException.getErrString("R_cantSetNull"), null, true);
@@ -411,26 +345,7 @@ public int setBytes(long pos,
return setBytes(pos, bytes, 0, bytes.length);
}
- /**
- * Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing
- * starts at position pos in the BLOB value; len bytes from the given byte wrray are written. The array of bytes will overwrite the existing bytes
- * in the Blob object starting at the position pos. If the end of the Blob value is reached while writing the array bytes, then the length of the
- * Blob value will be increased to accomodate the extra bytes.
- *
- * SQL Server behavior: If the value specified for pos is greater than the length+1 of the BLOB value then a SQLException is thrown.
- *
- * @param pos
- * - the position in the BLOB object at which to start writing; the first position is 1
- * @param bytes
- * - the array of bytes to be written to this BLOB object.
- * @param offset
- * - the offset (0-based) into the array bytes at which to start reading the bytes to set
- * @param len
- * - the number of bytes to be written to the BLOB value from the array of bytes bytes
- * @return the number of bytes written.
- * @throws SQLException
- * - if there is an error accessing the BLOB value or if pos is less than 1
- */
+ @Override
public int setBytes(long pos,
byte[] bytes,
int offset,
@@ -469,7 +384,8 @@ public int setBytes(long pos,
// Overwrite past end of value case.
if (len >= value.length - pos) {
- // Make sure the new value length wouldn't exceed the maximum allowed
+ // Make sure the new value length wouldn't exceed the maximum
+ // allowed
DataTypes.getCheckedLength(con, JDBCType.BLOB, pos + len, false);
assert pos + len <= Integer.MAX_VALUE;
@@ -506,14 +422,14 @@ final class SQLServerBlobOutputStream extends java.io.OutputStream {
this.currentPos = startPos;
}
- // java.io.OutputStream interface methods.
-
+ @Override
public void write(byte[] b) throws IOException {
if (null == b)
return;
write(b, 0, b.length);
}
+ @Override
public void write(byte[] b,
int off,
int len) throws IOException {
@@ -529,6 +445,7 @@ public void write(byte[] b,
}
}
+ @Override
public void write(int b) throws java.io.IOException {
byte[] bTemp = new byte[1];
bTemp[0] = (byte) (b & 0xFF);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java
new file mode 100644
index 0000000000..8ded138acd
--- /dev/null
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java
@@ -0,0 +1,482 @@
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.sql.Types;
+import java.text.DecimalFormat;
+import java.text.MessageFormat;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map.Entry;
+
+import java.util.Set;
+
+/**
+ * A simple implementation of the ISQLServerBulkRecord interface that can be
+ * used to read in the basic Java data types from an ArrayList of Parameters
+ * that were provided by pstmt/cstmt.
+ */
+public class SQLServerBulkBatchInsertRecord extends SQLServerBulkCommon {
+
+ private List batchParam;
+ private int batchParamIndex = -1;
+ private List columnList;
+ private List valueList;
+
+ /*
+ * Class name for logging.
+ */
+ private static final String loggerClassName = "com.microsoft.sqlserver.jdbc.SQLServerBulkBatchInsertRecord";
+
+ /*
+ * Logger
+ */
+ private static final java.util.logging.Logger loggerExternal = java.util.logging.Logger
+ .getLogger(loggerClassName);
+
+ public SQLServerBulkBatchInsertRecord(ArrayList batchParam,
+ ArrayList columnList, ArrayList valueList,
+ String encoding) throws SQLServerException {
+ loggerExternal.entering(loggerClassName,
+ "SQLServerBulkBatchInsertRecord",
+ new Object[]{batchParam, encoding});
+
+ if (null == batchParam) {
+ throwInvalidArgument("batchParam");
+ }
+
+ if (null == valueList) {
+ throwInvalidArgument("valueList");
+ }
+
+ this.batchParam = batchParam;
+ this.columnList = columnList;
+ this.valueList = valueList;
+ columnMetadata = new HashMap<>();
+
+ loggerExternal.exiting(loggerClassName,
+ "SQLServerBulkBatchInsertRecord");
+ }
+
+ @Override
+ public DateTimeFormatter getColumnDateTimeFormatter(int column) {
+ return columnMetadata.get(column).dateTimeFormatter;
+ }
+
+ @Override
+ public Set getColumnOrdinals() {
+ return columnMetadata.keySet();
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return columnMetadata.get(column).columnName;
+ }
+
+ @Override
+ public int getColumnType(int column) {
+ return columnMetadata.get(column).columnType;
+ }
+
+ @Override
+ public int getPrecision(int column) {
+ return columnMetadata.get(column).precision;
+ }
+
+ @Override
+ public int getScale(int column) {
+ return columnMetadata.get(column).scale;
+ }
+
+ @Override
+ public boolean isAutoIncrement(int column) {
+ return false;
+ }
+
+ private Object convertValue(ColumnMetadata cm, Object data)
+ throws SQLServerException {
+ switch (cm.columnType) {
+ case Types.INTEGER : {
+ // Formatter to remove the decimal part as SQL Server floors the
+ // decimal in integer types
+ DecimalFormat decimalFormatter = new DecimalFormat("#");
+ decimalFormatter.setRoundingMode(RoundingMode.DOWN);
+ String formatedfInput = decimalFormatter
+ .format(Double.parseDouble(data.toString()));
+ return Integer.valueOf(formatedfInput);
+ }
+
+ case Types.TINYINT :
+ case Types.SMALLINT : {
+ // Formatter to remove the decimal part as SQL Server floors the
+ // decimal in integer types
+ DecimalFormat decimalFormatter = new DecimalFormat("#");
+ decimalFormatter.setRoundingMode(RoundingMode.DOWN);
+ String formatedfInput = decimalFormatter
+ .format(Double.parseDouble(data.toString()));
+ return Short.valueOf(formatedfInput);
+ }
+
+ case Types.BIGINT : {
+ BigDecimal bd = new BigDecimal(data.toString().trim());
+ try {
+ return bd.setScale(0, RoundingMode.DOWN).longValueExact();
+ } catch (ArithmeticException ex) {
+ String value = "'" + data + "'";
+ MessageFormat form = new MessageFormat(SQLServerException
+ .getErrString("R_errorConvertingValue"));
+ throw new SQLServerException(form.format(
+ new Object[]{value, JDBCType.of(cm.columnType)}),
+ null, 0, ex);
+ }
+ }
+
+ case Types.DECIMAL :
+ case Types.NUMERIC : {
+ BigDecimal bd = new BigDecimal(data.toString().trim());
+ return bd.setScale(cm.scale, RoundingMode.HALF_UP);
+ }
+
+ case Types.BIT : {
+ // "true" => 1, "false" => 0
+ // Any non-zero value (integer/double) => 1, 0/0.0 => 0
+ try {
+ return (0 == Double.parseDouble(data.toString()))
+ ? Boolean.FALSE
+ : Boolean.TRUE;
+ } catch (NumberFormatException e) {
+ return Boolean.parseBoolean(data.toString());
+ }
+ }
+
+ case Types.REAL : {
+ return Float.parseFloat(data.toString());
+ }
+
+ case Types.DOUBLE : {
+ return Double.parseDouble(data.toString());
+ }
+
+ case Types.BINARY :
+ case Types.VARBINARY :
+ case Types.LONGVARBINARY :
+ case Types.BLOB : {
+ // Strip off 0x if present.
+ String binData = data.toString().trim();
+ if (binData.startsWith("0x") || binData.startsWith("0X")) {
+ return binData.substring(2);
+ } else {
+ return binData;
+ }
+ }
+
+ case java.sql.Types.TIME_WITH_TIMEZONE : {
+ OffsetTime offsetTimeValue;
+
+ // The per-column DateTimeFormatter gets priority.
+ if (null != cm.dateTimeFormatter)
+ offsetTimeValue = OffsetTime.parse(data.toString(),
+ cm.dateTimeFormatter);
+ else if (timeFormatter != null)
+ offsetTimeValue = OffsetTime.parse(data.toString(),
+ timeFormatter);
+ else
+ offsetTimeValue = OffsetTime.parse(data.toString());
+
+ return offsetTimeValue;
+ }
+
+ case java.sql.Types.TIMESTAMP_WITH_TIMEZONE : {
+ OffsetDateTime offsetDateTimeValue;
+
+ // The per-column DateTimeFormatter gets priority.
+ if (null != cm.dateTimeFormatter)
+ offsetDateTimeValue = OffsetDateTime.parse(data.toString(),
+ cm.dateTimeFormatter);
+ else if (dateTimeFormatter != null)
+ offsetDateTimeValue = OffsetDateTime.parse(data.toString(),
+ dateTimeFormatter);
+ else
+ offsetDateTimeValue = OffsetDateTime.parse(data.toString());
+
+ return offsetDateTimeValue;
+ }
+
+ case Types.NULL : {
+ return null;
+ }
+
+ case Types.DATE :
+ case Types.CHAR :
+ case Types.NCHAR :
+ case Types.VARCHAR :
+ case Types.NVARCHAR :
+ case Types.LONGVARCHAR :
+ case Types.LONGNVARCHAR :
+ case Types.CLOB :
+ default : {
+ // The string is copied as is.
+ return data;
+ }
+ }
+ }
+
+ private String removeSingleQuote(String s) {
+ int len = s.length();
+ return (s.charAt(0) == '\'' && s.charAt(len - 1) == '\'')
+ ? s.substring(1, len - 1)
+ : s;
+ }
+
+ @Override
+ public Object[] getRowData() throws SQLServerException {
+ Object[] data = new Object[columnMetadata.size()];
+ int valueIndex = 0;
+ String valueData;
+ Object rowData;
+ int columnListIndex = 0;
+
+ // check if the size of the list of values = size of the list of columns
+ // (which is optional)
+ if (null != columnList && columnList.size() != valueList.size()) {
+ MessageFormat form = new MessageFormat(
+ SQLServerException.getErrString("R_DataSchemaMismatch"));
+ Object[] msgArgs = {};
+ throw new SQLServerException(form.format(msgArgs),
+ SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
+ }
+
+ for (Entry pair : columnMetadata.entrySet()) {
+ int index = pair.getKey() - 1;
+
+ // To explain what each variable represents:
+ // columnMetadata = map containing the ENTIRE list of columns in the
+ // table.
+ // columnList = the *optional* list of columns the user can provide.
+ // For example, the (c1, c3) part of this query: INSERT into t1 (c1,
+ // c3) values (?, ?)
+ // valueList = the *mandatory* list of columns the user needs
+ // provide. This is the (?, ?) part of the previous query. The size
+ // of this valueList will always equal the number of
+ // the entire columns in the table IF columnList has NOT been
+ // provided. If columnList HAS been provided, then this valueList
+ // may be smaller than the list of all columns (which is
+ // columnMetadata).
+
+ // case when the user has not provided the optional list of column
+ // names.
+ if (null == columnList || columnList.size() == 0) {
+ valueData = valueList.get(index);
+ // if the user has provided a wildcard for this column, fetch
+ // the set value from the batchParam.
+ if (valueData.equalsIgnoreCase("?")) {
+ rowData = batchParam.get(batchParamIndex)[valueIndex++]
+ .getSetterValue();
+ } else if (valueData.equalsIgnoreCase("null")) {
+ rowData = null;
+ }
+ // if the user has provided a hardcoded value for this column,
+ // rowData is simply set to the hardcoded value.
+ else {
+ rowData = removeSingleQuote(valueData);
+ }
+ }
+ // case when the user has provided the optional list of column
+ // names.
+ else {
+ // columnListIndex is a separate counter we need to keep track
+ // of for each time we've processed a column
+ // that the user provided.
+ // for example, if the user provided an optional columnList of
+ // (c1, c3, c5, c7) in a table that has 8 columns (c1~c8),
+ // then the columnListIndex would increment only when we're
+ // dealing with the four columns inside columnMetadata.
+ // compare the list of the optional list of column names to the
+ // table's metadata, and match each other, so we assign the
+ // correct value to each column.
+ if (columnList.size() > columnListIndex
+ && columnList.get(columnListIndex).equalsIgnoreCase(
+ columnMetadata.get(index + 1).columnName)) {
+ valueData = valueList.get(columnListIndex);
+ if (valueData.equalsIgnoreCase("?")) {
+ rowData = batchParam.get(batchParamIndex)[valueIndex++]
+ .getSetterValue();
+ } else if (valueData.equalsIgnoreCase("null")) {
+ rowData = null;
+ } else {
+ rowData = removeSingleQuote(valueData);
+ }
+ columnListIndex++;
+ } else {
+ rowData = null;
+ }
+ }
+
+ try {
+ if (null == rowData) {
+ data[index] = null;
+ continue;
+ } else if (0 == rowData.toString().length()) {
+ data[index] = "";
+ continue;
+ }
+ data[index] = convertValue(pair.getValue(), rowData);
+ } catch (IllegalArgumentException e) {
+ String value = "'" + rowData + "'";
+ MessageFormat form = new MessageFormat(SQLServerException
+ .getErrString("R_errorConvertingValue"));
+ throw new SQLServerException(
+ form.format(new Object[]{value,
+ JDBCType.of(pair.getValue().columnType)}),
+ null, 0, e);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new SQLServerException(
+ SQLServerException.getErrString("R_DataSchemaMismatch"),
+ e);
+ }
+ }
+ return data;
+ }
+
+ @Override
+ void addColumnMetadataInternal(int positionInSource, String name,
+ int jdbcType, int precision, int scale,
+ DateTimeFormatter dateTimeFormatter) throws SQLServerException {
+ loggerExternal.entering(loggerClassName, "addColumnMetadata",
+ new Object[]{positionInSource, name, jdbcType, precision,
+ scale});
+
+ String colName = "";
+
+ if (0 >= positionInSource) {
+ MessageFormat form = new MessageFormat(
+ SQLServerException.getErrString("R_invalidColumnOrdinal"));
+ Object[] msgArgs = {positionInSource};
+ throw new SQLServerException(form.format(msgArgs),
+ SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
+ }
+
+ if (null != name)
+ colName = name.trim();
+ else if ((null != columnNames)
+ && (columnNames.length >= positionInSource))
+ colName = columnNames[positionInSource - 1];
+
+ if ((null != columnNames) && (positionInSource > columnNames.length)) {
+ MessageFormat form = new MessageFormat(
+ SQLServerException.getErrString("R_invalidColumn"));
+ Object[] msgArgs = {positionInSource};
+ throw new SQLServerException(form.format(msgArgs),
+ SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
+ }
+
+ checkDuplicateColumnName(positionInSource, name);
+ switch (jdbcType) {
+ /*
+ * SQL Server supports numerous string literal formats for temporal
+ * types, hence sending them as varchar with approximate
+ * precision(length) needed to send supported string literals.
+ * string literal formats supported by temporal types are available
+ * in MSDN page on data types.
+ */
+ case java.sql.Types.DATE :
+ case java.sql.Types.TIME :
+ case java.sql.Types.TIMESTAMP :
+ case microsoft.sql.Types.DATETIMEOFFSET :
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName,
+ jdbcType, precision, scale, dateTimeFormatter));
+ break;
+
+ // Redirect SQLXML as LONGNVARCHAR
+ // SQLXML is not valid type in TDS
+ case java.sql.Types.SQLXML :
+ columnMetadata.put(positionInSource,
+ new ColumnMetadata(colName, java.sql.Types.LONGNVARCHAR,
+ precision, scale, dateTimeFormatter));
+ break;
+
+ // Redirecting Float as Double based on data type mapping
+ // https://msdn.microsoft.com/en-us/library/ms378878%28v=sql.110%29.aspx
+ case java.sql.Types.FLOAT :
+ columnMetadata.put(positionInSource,
+ new ColumnMetadata(colName, java.sql.Types.DOUBLE,
+ precision, scale, dateTimeFormatter));
+ break;
+
+ // redirecting BOOLEAN as BIT
+ case java.sql.Types.BOOLEAN :
+ columnMetadata.put(positionInSource,
+ new ColumnMetadata(colName, java.sql.Types.BIT,
+ precision, scale, dateTimeFormatter));
+ break;
+
+ default :
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName,
+ jdbcType, precision, scale, dateTimeFormatter));
+ }
+
+ loggerExternal.exiting(loggerClassName, "addColumnMetadata");
+ }
+
+ @Override
+ public void setTimestampWithTimezoneFormat(String dateTimeFormat) {
+ loggerExternal.entering(loggerClassName,
+ "setTimestampWithTimezoneFormat", dateTimeFormat);
+
+ super.setTimestampWithTimezoneFormat(dateTimeFormat);
+
+ loggerExternal.exiting(loggerClassName,
+ "setTimestampWithTimezoneFormat");
+ }
+
+ @Override
+ public void setTimestampWithTimezoneFormat(
+ DateTimeFormatter dateTimeFormatter) {
+ loggerExternal.entering(loggerClassName,
+ "setTimestampWithTimezoneFormat",
+ new Object[]{dateTimeFormatter});
+
+ super.setTimestampWithTimezoneFormat(dateTimeFormatter);
+
+ loggerExternal.exiting(loggerClassName,
+ "setTimestampWithTimezoneFormat");
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(String timeFormat) {
+ loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat",
+ timeFormat);
+
+ super.setTimeWithTimezoneFormat(timeFormat);
+
+ loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
+ loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat",
+ new Object[]{dateTimeFormatter});
+
+ super.setTimeWithTimezoneFormat(dateTimeFormatter);
+
+ loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
+ }
+
+ @Override
+ public boolean next() throws SQLServerException {
+ batchParamIndex++;
+ return batchParamIndex < batchParam.size();
+ }
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java
index cce49a416d..31e1014633 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java
@@ -23,38 +23,15 @@
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
-import java.util.Map;
import java.util.Map.Entry;
+
import java.util.Set;
/**
* A simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types from a delimited file where
* each line represents a row of data.
*/
-public class SQLServerBulkCSVFileRecord implements ISQLServerBulkRecord, java.lang.AutoCloseable {
- /*
- * Class to represent the column metadata
- */
- private class ColumnMetadata {
- String columnName;
- int columnType;
- int precision;
- int scale;
- DateTimeFormatter dateTimeFormatter = null;
-
- ColumnMetadata(String name,
- int type,
- int precision,
- int scale,
- DateTimeFormatter dateTimeFormatter) {
- columnName = name;
- columnType = type;
- this.precision = precision;
- this.scale = scale;
- this.dateTimeFormatter = dateTimeFormatter;
- }
- }
-
+public class SQLServerBulkCSVFileRecord extends SQLServerBulkCommon implements java.lang.AutoCloseable {
/*
* Resources associated with reading in the file
*/
@@ -62,12 +39,6 @@ private class ColumnMetadata {
private InputStreamReader sr;
private FileInputStream fis;
- /*
- * Metadata to represent the columns in the file. Each column should be mapped to its corresponding position within the file (from position 1 and
- * onwards)
- */
- private Map columnMetadata;
-
/*
* Current line of data to parse.
*/
@@ -78,21 +49,6 @@ private class ColumnMetadata {
*/
private final String delimiter;
- /*
- * Contains all the column names if firstLineIsColumnNames is true
- */
- private String[] columnNames = null;
-
- /*
- * Contains the format that java.sql.Types.TIMESTAMP_WITH_TIMEZONE data should be read in as.
- */
- private DateTimeFormatter dateTimeFormatter = null;
-
- /*
- * Contains the format that java.sql.Types.TIME_WITH_TIMEZONE data should be read in as.
- */
- private DateTimeFormatter timeFormatter = null;
-
/*
* Class name for logging.
*/
@@ -162,7 +118,7 @@ else if (null == delimiter) {
loggerExternal.exiting(loggerClassName, "SQLServerBulkCSVFileRecord");
}
-
+
/**
* Creates a simple reader to parse data from a delimited file with the given encoding.
*
@@ -253,199 +209,6 @@ public SQLServerBulkCSVFileRecord(String fileToParse,
this(fileToParse, null, ",", firstLineIsColumnNames);
}
- /**
- * Adds metadata for the given column in the file.
- *
- * @param positionInFile
- * Indicates which column the metadata is for. Columns start at 1.
- * @param name
- * Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)
- * @param jdbcType
- * JDBC data type of the column
- * @param precision
- * Precision for the column (ignored for the appropriate data types)
- * @param scale
- * Scale for the column (ignored for the appropriate data types)
- * @param dateTimeFormatter
- * format to parse data that is sent
- * @throws SQLServerException
- * when an error occurs
- */
- public void addColumnMetadata(int positionInFile,
- String name,
- int jdbcType,
- int precision,
- int scale,
- DateTimeFormatter dateTimeFormatter) throws SQLServerException {
- addColumnMetadataInternal(positionInFile, name, jdbcType, precision, scale, dateTimeFormatter);
- }
-
- /**
- * Adds metadata for the given column in the file.
- *
- * @param positionInFile
- * Indicates which column the metadata is for. Columns start at 1.
- * @param name
- * Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)
- * @param jdbcType
- * JDBC data type of the column
- * @param precision
- * Precision for the column (ignored for the appropriate data types)
- * @param scale
- * Scale for the column (ignored for the appropriate data types)
- * @throws SQLServerException
- * when an error occurs
- */
- public void addColumnMetadata(int positionInFile,
- String name,
- int jdbcType,
- int precision,
- int scale) throws SQLServerException {
- addColumnMetadataInternal(positionInFile, name, jdbcType, precision, scale, null);
- }
-
- /**
- * Adds metadata for the given column in the file.
- *
- * @param positionInFile
- * Indicates which column the metadata is for. Columns start at 1.
- * @param name
- * Name for the column (optional if only using column ordinal in a mapping for SQLServerBulkCopy operation)
- * @param jdbcType
- * JDBC data type of the column
- * @param precision
- * Precision for the column (ignored for the appropriate data types)
- * @param scale
- * Scale for the column (ignored for the appropriate data types)
- * @param dateTimeFormatter
- * format to parse data that is sent
- * @throws SQLServerException
- * when an error occurs
- */
- void addColumnMetadataInternal(int positionInFile,
- String name,
- int jdbcType,
- int precision,
- int scale,
- DateTimeFormatter dateTimeFormatter) throws SQLServerException {
- loggerExternal.entering(loggerClassName, "addColumnMetadata", new Object[] {positionInFile, name, jdbcType, precision, scale});
-
- String colName = "";
-
- if (0 >= positionInFile) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidColumnOrdinal"));
- Object[] msgArgs = {positionInFile};
- throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
- }
-
- if (null != name)
- colName = name.trim();
- else if ((columnNames != null) && (columnNames.length >= positionInFile))
- colName = columnNames[positionInFile - 1];
-
- if ((columnNames != null) && (positionInFile > columnNames.length)) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidColumn"));
- Object[] msgArgs = {positionInFile};
- throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
- }
-
- checkDuplicateColumnName(positionInFile, name);
- switch (jdbcType) {
- /*
- * SQL Server supports numerous string literal formats for temporal types, hence sending them as varchar with approximate
- * precision(length) needed to send supported string literals. string literal formats supported by temporal types are available in MSDN
- * page on data types.
- */
- case java.sql.Types.DATE:
- case java.sql.Types.TIME:
- case java.sql.Types.TIMESTAMP:
- case microsoft.sql.Types.DATETIMEOFFSET:
- // The precision is just a number long enough to hold all types of temporal data, doesn't need to be exact precision.
- columnMetadata.put(positionInFile, new ColumnMetadata(colName, jdbcType, 50, scale, dateTimeFormatter));
- break;
-
- // Redirect SQLXML as LONGNVARCHAR
- // SQLXML is not valid type in TDS
- case java.sql.Types.SQLXML:
- columnMetadata.put(positionInFile, new ColumnMetadata(colName, java.sql.Types.LONGNVARCHAR, precision, scale, dateTimeFormatter));
- break;
-
- // Redirecting Float as Double based on data type mapping
- // https://msdn.microsoft.com/en-us/library/ms378878%28v=sql.110%29.aspx
- case java.sql.Types.FLOAT:
- columnMetadata.put(positionInFile, new ColumnMetadata(colName, java.sql.Types.DOUBLE, precision, scale, dateTimeFormatter));
- break;
-
- // redirecting BOOLEAN as BIT
- case java.sql.Types.BOOLEAN:
- columnMetadata.put(positionInFile, new ColumnMetadata(colName, java.sql.Types.BIT, precision, scale, dateTimeFormatter));
- break;
-
- default:
- columnMetadata.put(positionInFile, new ColumnMetadata(colName, jdbcType, precision, scale, dateTimeFormatter));
- }
-
- loggerExternal.exiting(loggerClassName, "addColumnMetadata");
- }
-
- /**
- * Set the format for reading in dates from the file.
- *
- * @param dateTimeFormat
- * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
- */
- public void setTimestampWithTimezoneFormat(String dateTimeFormat) {
- DriverJDBCVersion.checkSupportsJDBC42();
- loggerExternal.entering(loggerClassName, "setTimestampWithTimezoneFormat", dateTimeFormat);
-
- this.dateTimeFormatter = DateTimeFormatter.ofPattern(dateTimeFormat);
-
- loggerExternal.exiting(loggerClassName, "setTimestampWithTimezoneFormat");
- }
-
- /**
- * Set the format for reading in dates from the file.
- *
- * @param dateTimeFormatter
- * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE
- */
- public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
- loggerExternal.entering(loggerClassName, "setTimestampWithTimezoneFormat", new Object[] {dateTimeFormatter});
-
- this.dateTimeFormatter = dateTimeFormatter;
-
- loggerExternal.exiting(loggerClassName, "setTimestampWithTimezoneFormat");
- }
-
- /**
- * Set the format for reading in dates from the file.
- *
- * @param timeFormat
- * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
- */
- public void setTimeWithTimezoneFormat(String timeFormat) {
- DriverJDBCVersion.checkSupportsJDBC42();
- loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat", timeFormat);
-
- this.timeFormatter = DateTimeFormatter.ofPattern(timeFormat);
-
- loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
- }
-
- /**
- * Set the format for reading in dates from the file.
- *
- * @param dateTimeFormatter
- * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE
- */
- public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
- loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat", new Object[] {dateTimeFormatter});
-
- this.timeFormatter = dateTimeFormatter;
-
- loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
- }
-
/**
* Releases any resources associated with the file reader.
*
@@ -478,6 +241,7 @@ public void close() throws SQLServerException {
loggerExternal.exiting(loggerClassName, "close");
}
+ @Override
public DateTimeFormatter getColumnDateTimeFormatter(int column) {
return columnMetadata.get(column).dateTimeFormatter;
}
@@ -518,11 +282,13 @@ public Object[] getRowData() throws SQLServerException {
return null;
else {
// Binary data may be corrupted
- // The limit in split() function should be a negative value, otherwise trailing empty strings are discarded.
+ // The limit in split() function should be a negative value,
+ // otherwise trailing empty strings are discarded.
// Empty string is returned if there is no value.
String[] data = currentLine.split(delimiter, -1);
- // Cannot go directly from String[] to Object[] and expect it to act as an array.
+ // Cannot go directly from String[] to Object[] and expect it to act
+ // as an array.
Object[] dataRow = new Object[data.length];
for (Entry pair : columnMetadata.entrySet()) {
@@ -538,7 +304,7 @@ public Object[] getRowData() throws SQLServerException {
// Source header has more columns than current line read
if (columnNames != null && (columnNames.length > data.length)) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_CSVDataSchemaMismatch"));
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_DataSchemaMismatch"));
Object[] msgArgs = {};
throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
}
@@ -555,8 +321,10 @@ public Object[] getRowData() throws SQLServerException {
* inserted into an numeric column. Our implementation does the same.
*/
case Types.INTEGER: {
- // Formatter to remove the decimal part as SQL Server floors the decimal in integer types
+ // Formatter to remove the decimal part as SQL
+ // Server floors the decimal in integer types
DecimalFormat decimalFormatter = new DecimalFormat("#");
+ decimalFormatter.setRoundingMode(RoundingMode.DOWN);
String formatedfInput = decimalFormatter.format(Double.parseDouble(data[pair.getKey() - 1]));
dataRow[pair.getKey() - 1] = Integer.valueOf(formatedfInput);
break;
@@ -564,8 +332,10 @@ public Object[] getRowData() throws SQLServerException {
case Types.TINYINT:
case Types.SMALLINT: {
- // Formatter to remove the decimal part as SQL Server floors the decimal in integer types
+ // Formatter to remove the decimal part as SQL
+ // Server floors the decimal in integer types
DecimalFormat decimalFormatter = new DecimalFormat("#");
+ decimalFormatter.setRoundingMode(RoundingMode.DOWN);
String formatedfInput = decimalFormatter.format(Double.parseDouble(data[pair.getKey() - 1]));
dataRow[pair.getKey() - 1] = Short.valueOf(formatedfInput);
break;
@@ -575,10 +345,11 @@ public Object[] getRowData() throws SQLServerException {
BigDecimal bd = new BigDecimal(data[pair.getKey() - 1].trim());
try {
dataRow[pair.getKey() - 1] = bd.setScale(0, RoundingMode.DOWN).longValueExact();
- } catch (ArithmeticException ex) {
+ }
+ catch (ArithmeticException ex) {
String value = "'" + data[pair.getKey() - 1] + "'";
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorConvertingValue"));
- throw new SQLServerException(form.format(new Object[]{value, JDBCType.of(cm.columnType)}), null, 0, ex);
+ throw new SQLServerException(form.format(new Object[] {value, JDBCType.of(cm.columnType)}), null, 0, ex);
}
break;
}
@@ -592,10 +363,12 @@ public Object[] getRowData() throws SQLServerException {
case Types.BIT: {
// "true" => 1, "false" => 0
- // Any non-zero value (integer/double) => 1, 0/0.0 => 0
+ // Any non-zero value (integer/double) => 1, 0/0.0
+ // => 0
try {
dataRow[pair.getKey() - 1] = (0 == Double.parseDouble(data[pair.getKey() - 1])) ? Boolean.FALSE : Boolean.TRUE;
- } catch (NumberFormatException e) {
+ }
+ catch (NumberFormatException e) {
dataRow[pair.getKey() - 1] = Boolean.parseBoolean(data[pair.getKey() - 1]);
}
break;
@@ -620,21 +393,20 @@ public Object[] getRowData() throws SQLServerException {
* 'BULK INSERT' except that we will allow 0x prefix whereas 'BULK INSERT' command does not allow 0x prefix. A BULK INSERT
* example: A sample csv file containing data for 2 binary columns and 1 row: 61,62 Table definition: create table t1(c1
* varbinary(10), c2 varbinary(10)) BULK INSERT command: bulk insert t1 from 'C:\in.csv'
- * with(DATAFILETYPE='char',firstrow=1,FIELDTERMINATOR=',') select * from t1 shows 1 row with columns: 0x61, 0x62
+ * with(DATAFILETYPE='char',firstrow=1, FIELDTERMINATOR=',') select * from t1 shows 1 row with columns: 0x61, 0x62
*/
// Strip off 0x if present.
String binData = data[pair.getKey() - 1].trim();
if (binData.startsWith("0x") || binData.startsWith("0X")) {
dataRow[pair.getKey() - 1] = binData.substring(2);
- } else {
+ }
+ else {
dataRow[pair.getKey() - 1] = binData;
}
break;
}
- case 2013: // java.sql.Types.TIME_WITH_TIMEZONE
- {
- DriverJDBCVersion.checkSupportsJDBC42();
+ case java.sql.Types.TIME_WITH_TIMEZONE: {
OffsetTime offsetTimeValue;
// The per-column DateTimeFormatter gets priority.
@@ -649,9 +421,7 @@ else if (timeFormatter != null)
break;
}
- case 2014: // java.sql.Types.TIMESTAMP_WITH_TIMEZONE
- {
- DriverJDBCVersion.checkSupportsJDBC42();
+ case java.sql.Types.TIMESTAMP_WITH_TIMEZONE: {
OffsetDateTime offsetDateTimeValue;
// The per-column DateTimeFormatter gets priority.
@@ -691,18 +461,20 @@ else if (dateTimeFormatter != null)
*
* Handling delimiters in data: Excel allows comma in data when data is surrounded with quotes. For example,
* "Hello, world" is treated as one cell. BCP and BULK INSERT deos not allow field terminators in data:
- * https://technet.microsoft.com/en-us/library/aa196735%28v=sql.80%29.aspx?f=255&MSPPError=-2147217396
+ * https://technet.microsoft.com/en-us/library/ aa196735%28v=sql.80%29.aspx?f=255&MSPPError=- 2147217396
*/
dataRow[pair.getKey() - 1] = data[pair.getKey() - 1];
break;
}
}
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e) {
String value = "'" + data[pair.getKey() - 1] + "'";
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorConvertingValue"));
- throw new SQLServerException(form.format(new Object[]{value, JDBCType.of(cm.columnType)}), null, 0, e);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new SQLServerException(SQLServerException.getErrString("R_CSVDataSchemaMismatch"), e);
+ throw new SQLServerException(form.format(new Object[] {value, JDBCType.of(cm.columnType)}), null, 0, e);
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ throw new SQLServerException(SQLServerException.getErrString("R_DataSchemaMismatch"), e);
}
}
@@ -711,42 +483,115 @@ else if (dateTimeFormatter != null)
}
@Override
- public boolean next() throws SQLServerException {
- try {
- currentLine = fileReader.readLine();
+ void addColumnMetadataInternal(int positionInSource,
+ String name,
+ int jdbcType,
+ int precision,
+ int scale,
+ DateTimeFormatter dateTimeFormatter) throws SQLServerException {
+ loggerExternal.entering(loggerClassName, "addColumnMetadata", new Object[] {positionInSource, name, jdbcType, precision, scale});
+
+ String colName = "";
+
+ if (0 >= positionInSource) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidColumnOrdinal"));
+ Object[] msgArgs = {positionInSource};
+ throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
}
- catch (IOException e) {
- throw new SQLServerException(e.getMessage(), null, 0, e);
+
+ if (null != name)
+ colName = name.trim();
+ else if ((null != columnNames) && (columnNames.length >= positionInSource))
+ colName = columnNames[positionInSource - 1];
+
+ if ((null != columnNames) && (positionInSource > columnNames.length)) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidColumn"));
+ Object[] msgArgs = {positionInSource};
+ throw new SQLServerException(form.format(msgArgs), SQLState.COL_NOT_FOUND, DriverError.NOT_SET, null);
}
- return (null != currentLine);
+
+ checkDuplicateColumnName(positionInSource, name);
+ switch (jdbcType) {
+ /*
+ * SQL Server supports numerous string literal formats for temporal types, hence sending them as varchar with approximate
+ * precision(length) needed to send supported string literals. string literal formats supported by temporal types are available in MSDN
+ * page on data types.
+ */
+ case java.sql.Types.DATE:
+ case java.sql.Types.TIME:
+ case java.sql.Types.TIMESTAMP:
+ case microsoft.sql.Types.DATETIMEOFFSET:
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName, jdbcType, 50, scale, dateTimeFormatter));
+ break;
+
+ // Redirect SQLXML as LONGNVARCHAR
+ // SQLXML is not valid type in TDS
+ case java.sql.Types.SQLXML:
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName, java.sql.Types.LONGNVARCHAR, precision, scale, dateTimeFormatter));
+ break;
+
+ // Redirecting Float as Double based on data type mapping
+ // https://msdn.microsoft.com/en-us/library/ms378878%28v=sql.110%29.aspx
+ case java.sql.Types.FLOAT:
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName, java.sql.Types.DOUBLE, precision, scale, dateTimeFormatter));
+ break;
+
+ // redirecting BOOLEAN as BIT
+ case java.sql.Types.BOOLEAN:
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName, java.sql.Types.BIT, precision, scale, dateTimeFormatter));
+ break;
+
+ default:
+ columnMetadata.put(positionInSource, new ColumnMetadata(colName, jdbcType, precision, scale, dateTimeFormatter));
+ }
+
+ loggerExternal.exiting(loggerClassName, "addColumnMetadata");
}
- /*
- * Helper method to throw a SQLServerExeption with the invalidArgument message and given argument.
- */
- private void throwInvalidArgument(String argument) throws SQLServerException {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidArgument"));
- Object[] msgArgs = {argument};
- SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, false);
+ @Override
+ public void setTimestampWithTimezoneFormat(String dateTimeFormat) {
+ loggerExternal.entering(loggerClassName, "setTimestampWithTimezoneFormat", dateTimeFormat);
+
+ super.setTimestampWithTimezoneFormat(dateTimeFormat);
+
+ loggerExternal.exiting(loggerClassName, "setTimestampWithTimezoneFormat");
}
- /*
- * Method to throw a SQLServerExeption for duplicate column names
- */
- private void checkDuplicateColumnName(int positionInFile,
- String colName) throws SQLServerException {
-
- if (null != colName && colName.trim().length() != 0) {
- for (Entry entry : columnMetadata.entrySet()) {
- // duplicate check is not performed in case of same positionInFile value
- if (null != entry && entry.getKey() != positionInFile) {
- if (null != entry.getValue() && colName.trim().equalsIgnoreCase(entry.getValue().columnName)) {
- throw new SQLServerException(SQLServerException.getErrString("R_BulkCSVDataDuplicateColumn"), null);
- }
- }
+ @Override
+ public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
+ loggerExternal.entering(loggerClassName, "setTimestampWithTimezoneFormat", new Object[] {dateTimeFormatter});
- }
- }
+ super.setTimestampWithTimezoneFormat(dateTimeFormatter);
+
+ loggerExternal.exiting(loggerClassName, "setTimestampWithTimezoneFormat");
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(String timeFormat) {
+ loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat", timeFormat);
+
+ super.setTimeWithTimezoneFormat(timeFormat);
+
+ loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
+ loggerExternal.entering(loggerClassName, "setTimeWithTimezoneFormat", new Object[] {dateTimeFormatter});
+
+ super.setTimeWithTimezoneFormat(dateTimeFormatter);
+
+ loggerExternal.exiting(loggerClassName, "setTimeWithTimezoneFormat");
+ }
+ @Override
+ public boolean next() throws SQLServerException {
+ try {
+ currentLine = fileReader.readLine();
+ }
+ catch (IOException e) {
+ throw new SQLServerException(e.getMessage(), null, 0, e);
+ }
+ return (null != currentLine);
}
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCommon.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCommon.java
new file mode 100644
index 0000000000..dee5350cc7
--- /dev/null
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCommon.java
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.text.MessageFormat;
+import java.time.format.DateTimeFormatter;
+import java.util.Map;
+import java.util.Map.Entry;
+
+abstract class SQLServerBulkCommon implements ISQLServerBulkRecord {
+
+ /*
+ * Class to represent the column metadata
+ */
+ protected class ColumnMetadata {
+ String columnName;
+ int columnType;
+ int precision;
+ int scale;
+ DateTimeFormatter dateTimeFormatter = null;
+
+ ColumnMetadata(String name, int type, int precision, int scale,
+ DateTimeFormatter dateTimeFormatter) {
+ columnName = name;
+ columnType = type;
+ this.precision = precision;
+ this.scale = scale;
+ this.dateTimeFormatter = dateTimeFormatter;
+ }
+ }
+
+ /*
+ * Contains all the column names if firstLineIsColumnNames is true
+ */
+ protected String[] columnNames = null;
+
+ /*
+ * Metadata to represent the columns in the batch/file. Each column should
+ * be mapped to its corresponding position within the parameter (from
+ * position 1 and onwards)
+ */
+ protected Map columnMetadata;
+
+ /*
+ * Contains the format that java.sql.Types.TIMESTAMP_WITH_TIMEZONE data
+ * should be read in as.
+ */
+ protected DateTimeFormatter dateTimeFormatter = null;
+
+ /*
+ * Contains the format that java.sql.Types.TIME_WITH_TIMEZONE data should be
+ * read in as.
+ */
+ protected DateTimeFormatter timeFormatter = null;
+
+ @Override
+ public void addColumnMetadata(int positionInSource, String name,
+ int jdbcType, int precision, int scale,
+ DateTimeFormatter dateTimeFormatter) throws SQLServerException {
+ addColumnMetadataInternal(positionInSource, name, jdbcType, precision,
+ scale, dateTimeFormatter);
+ }
+
+ @Override
+ public void addColumnMetadata(int positionInSource, String name,
+ int jdbcType, int precision, int scale) throws SQLServerException {
+ addColumnMetadataInternal(positionInSource, name, jdbcType, precision,
+ scale, null);
+ }
+
+ /**
+ * Adds metadata for the given column in the batch/file.
+ *
+ * @param positionInSource
+ * Indicates which column the metadata is for. Columns start at
+ * 1.
+ * @param name
+ * Name for the column (optional if only using column ordinal in
+ * a mapping for SQLServerBulkCopy operation)
+ * @param jdbcType
+ * JDBC data type of the column
+ * @param precision
+ * Precision for the column (ignored for the appropriate data
+ * types)
+ * @param scale
+ * Scale for the column (ignored for the appropriate data types)
+ * @param dateTimeFormatter
+ * format to parse data that is sent
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ void addColumnMetadataInternal(int positionInSource, String name,
+ int jdbcType, int precision, int scale,
+ DateTimeFormatter dateTimeFormatter) throws SQLServerException {
+ }
+
+ @Override
+ public void setTimestampWithTimezoneFormat(String dateTimeFormat) {
+ this.dateTimeFormatter = DateTimeFormatter.ofPattern(dateTimeFormat);
+ }
+
+ @Override
+ public void setTimestampWithTimezoneFormat(
+ DateTimeFormatter dateTimeFormatter) {
+ this.dateTimeFormatter = dateTimeFormatter;
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(String timeFormat) {
+ this.timeFormatter = DateTimeFormatter.ofPattern(timeFormat);
+ }
+
+ @Override
+ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) {
+ this.timeFormatter = dateTimeFormatter;
+ }
+
+ /*
+ * Helper method to throw a SQLServerExeption with the invalidArgument
+ * message and given argument.
+ */
+ protected void throwInvalidArgument(String argument)
+ throws SQLServerException {
+ MessageFormat form = new MessageFormat(
+ SQLServerException.getErrString("R_invalidArgument"));
+ Object[] msgArgs = {argument};
+ SQLServerException.makeFromDriverError(null, null, form.format(msgArgs),
+ null, false);
+ }
+
+ /*
+ * Method to throw a SQLServerExeption for duplicate column names
+ */
+ protected void checkDuplicateColumnName(int positionInTable, String colName)
+ throws SQLServerException {
+
+ if (null != colName && colName.trim().length() != 0) {
+ for (Entry entry : columnMetadata
+ .entrySet()) {
+ // duplicate check is not performed in case of same
+ // positionInTable value
+ if (null != entry && entry.getKey() != positionInTable) {
+ if (null != entry.getValue() && colName.trim()
+ .equalsIgnoreCase(entry.getValue().columnName)) {
+ throw new SQLServerException(SQLServerException
+ .getErrString("R_BulkDataDuplicateColumn"),
+ null);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
index 50f711c291..9122c44fab 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
@@ -26,9 +26,12 @@
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.MessageFormat;
+import java.time.DateTimeException;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoField;
+import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -46,6 +49,8 @@
import javax.sql.RowSet;
+import microsoft.sql.DateTimeOffset;
+
/**
* Lets you efficiently bulk load a SQL Server table with data from another source.
*
@@ -55,8 +60,13 @@
* The SQLServerBulkCopy class can be used to write data only to SQL Server tables. However, the data source is not limited to SQL Server; any data
* source can be used, as long as the data can be read with a ResultSet or ISQLServerBulkRecord instance.
*/
-public class SQLServerBulkCopy implements java.lang.AutoCloseable {
- /*
+public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1989903904654306244L;
+
+ /*
* Class to represent the column mappings between the source and destination table
*/
private class ColumnMapping {
@@ -153,6 +163,11 @@ private class ColumnMapping {
/* The CekTable for the destination table. */
private CekTable destCekTable = null;
+ /* Statement level encryption setting needed for querying against encrypted columns. */
+ private SQLServerStatementColumnEncryptionSetting stmtColumnEncriptionSetting = SQLServerStatementColumnEncryptionSetting.UseConnectionSetting;
+
+ private ResultSet destinationTableMetadata;
+
/*
* Metadata for the destination table columns
*/
@@ -689,7 +704,7 @@ private void initializeDefaults() {
private void sendBulkLoadBCP() throws SQLServerException {
final class InsertBulk extends TDSCommand {
InsertBulk() {
- super("InsertBulk", 0);
+ super("InsertBulk", 0, 0);
int timeoutSeconds = copyOptions.getBulkCopyTimeout();
timeoutTimer = (timeoutSeconds > 0) ? (new BulkTimeoutTimer(timeoutSeconds, this)) : null;
}
@@ -1490,7 +1505,12 @@ private String createInsertBulkCommand(TDSWriter tdsWriter) throws SQLServerExce
if (null != destType && (destType.toLowerCase(Locale.ENGLISH).trim().startsWith("char") || destType.toLowerCase(Locale.ENGLISH).trim().startsWith("varchar")))
addCollate = " COLLATE " + columnCollation;
}
- bulkCmd.append("[" + colMapping.destinationColumnName + "] " + destType + addCollate + endColumn);
+ if (colMapping.destinationColumnName.contains("]")) {
+ String escapedColumnName = colMapping.destinationColumnName.replaceAll("]", "]]");
+ bulkCmd.append("[" + escapedColumnName + "] " + destType + addCollate + endColumn);
+ } else {
+ bulkCmd.append("[" + colMapping.destinationColumnName + "] " + destType + addCollate + endColumn);
+ }
}
if (true == copyOptions.isCheckConstraints()) {
@@ -1740,11 +1760,19 @@ private void getDestinationMetadata() throws SQLServerException {
SQLServerResultSet rs = null;
SQLServerResultSet rsMoreMetaData = null;
-
+ SQLServerStatement stmt = null;
+
try {
- // Get destination metadata
- rs = ((SQLServerStatement) connection.createStatement())
- .executeQueryInternal("SET FMTONLY ON SELECT * FROM " + destinationTableName + " SET FMTONLY OFF ");
+ if (null != destinationTableMetadata) {
+ rs = (SQLServerResultSet) destinationTableMetadata;
+ }
+ else {
+ stmt = (SQLServerStatement) connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+ connection.getHoldability(), stmtColumnEncriptionSetting);
+
+ // Get destination metadata
+ rs = stmt.executeQueryInternal("sp_executesql N'SET FMTONLY ON SELECT * FROM " + destinationTableName + " '");
+ }
destColumnCount = rs.getMetaData().getColumnCount();
destColumnMetadata = new HashMap<>();
@@ -1783,6 +1811,8 @@ private void getDestinationMetadata() throws SQLServerException {
finally {
if (null != rs)
rs.close();
+ if (null != stmt)
+ stmt.close();
if (null != rsMoreMetaData)
rsMoreMetaData.close();
}
@@ -3059,12 +3089,63 @@ protected Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed,
int srcJdbcType,
int srcColOrdinal,
DateTimeFormatter dateTimeFormatter) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- SQLServerBulkCopy42Helper.getTemporalObjectFromCSVWithFormatter(valueStrUntrimmed, srcJdbcType, srcColOrdinal, dateTimeFormatter, connection,
- this);
-
- return null;
+ try {
+ TemporalAccessor ta = dateTimeFormatter.parse(valueStrUntrimmed);
+
+ int taHour, taMin, taSec, taYear, taMonth, taDay, taNano, taOffsetSec;
+ taHour = taMin = taSec = taYear = taMonth = taDay = taNano = taOffsetSec = 0;
+ if (ta.isSupported(ChronoField.NANO_OF_SECOND))
+ taNano = ta.get(ChronoField.NANO_OF_SECOND);
+ if (ta.isSupported(ChronoField.OFFSET_SECONDS))
+ taOffsetSec = ta.get(ChronoField.OFFSET_SECONDS);
+ if (ta.isSupported(ChronoField.HOUR_OF_DAY))
+ taHour = ta.get(ChronoField.HOUR_OF_DAY);
+ if (ta.isSupported(ChronoField.MINUTE_OF_HOUR))
+ taMin = ta.get(ChronoField.MINUTE_OF_HOUR);
+ if (ta.isSupported(ChronoField.SECOND_OF_MINUTE))
+ taSec = ta.get(ChronoField.SECOND_OF_MINUTE);
+ if (ta.isSupported(ChronoField.DAY_OF_MONTH))
+ taDay = ta.get(ChronoField.DAY_OF_MONTH);
+ if (ta.isSupported(ChronoField.MONTH_OF_YEAR))
+ taMonth = ta.get(ChronoField.MONTH_OF_YEAR);
+ if (ta.isSupported(ChronoField.YEAR))
+ taYear = ta.get(ChronoField.YEAR);
+
+ Calendar cal = new GregorianCalendar(new SimpleTimeZone(taOffsetSec * 1000, ""));
+ cal.clear();
+ cal.set(Calendar.HOUR_OF_DAY, taHour);
+ cal.set(Calendar.MINUTE, taMin);
+ cal.set(Calendar.SECOND, taSec);
+ cal.set(Calendar.DATE, taDay);
+ cal.set(Calendar.MONTH, taMonth - 1);
+ cal.set(Calendar.YEAR, taYear);
+ int fractionalSecondsLength = Integer.toString(taNano).length();
+ for (int i = 0; i < (9 - fractionalSecondsLength); i++)
+ taNano *= 10;
+ Timestamp ts = new Timestamp(cal.getTimeInMillis());
+ ts.setNanos(taNano);
+
+ switch (srcJdbcType) {
+ case java.sql.Types.TIMESTAMP:
+ return ts;
+ case java.sql.Types.TIME:
+ // Time is returned as Timestamp to preserve nano seconds.
+ cal.set(connection.baseYear(), Calendar.JANUARY, 01);
+ ts = new java.sql.Timestamp(cal.getTimeInMillis());
+ ts.setNanos(taNano);
+ return new java.sql.Timestamp(ts.getTime());
+ case java.sql.Types.DATE:
+ return new java.sql.Date(ts.getTime());
+ case microsoft.sql.Types.DATETIMEOFFSET:
+ return DateTimeOffset.valueOf(ts, taOffsetSec / 60);
+ }
+ }
+ catch (DateTimeException | ArithmeticException e) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ParsingError"));
+ Object[] msgArgs = {JDBCType.of(srcJdbcType)};
+ throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
+ }
+ return valueStrUntrimmed;
}
private Object getTemporalObjectFromCSV(Object value,
@@ -3348,7 +3429,7 @@ private byte[] normalizedValue(JDBCType destJdbcType,
longValue = (long) (short) value;
break;
default:
- longValue = new Long((Integer) value);
+ longValue = Long.valueOf((Integer) value);
}
return ByteBuffer.allocate(Long.SIZE / Byte.SIZE).order(ByteOrder.LITTLE_ENDIAN).putLong(longValue).array();
@@ -3362,7 +3443,7 @@ private byte[] normalizedValue(JDBCType destJdbcType,
longValue = (long) (short) value;
break;
case INTEGER:
- longValue = new Long((Integer) value);
+ longValue = Long.valueOf((Integer) value);
break;
default:
longValue = (long) value;
@@ -3573,4 +3654,12 @@ private boolean writeBatchData(TDSWriter tdsWriter,
}
}
}
+
+ protected void setStmtColumnEncriptionSetting(SQLServerStatementColumnEncryptionSetting stmtColumnEncriptionSetting) {
+ this.stmtColumnEncriptionSetting = stmtColumnEncriptionSetting;
+ }
+
+ protected void setDestinationTableMetadata(SQLServerResultSet rs) {
+ destinationTableMetadata = rs;
+ }
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java
deleted file mode 100644
index ea9ff510f4..0000000000
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.Timestamp;
-import java.text.MessageFormat;
-import java.time.DateTimeException;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.ChronoField;
-import java.time.temporal.TemporalAccessor;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.SimpleTimeZone;
-
-import microsoft.sql.DateTimeOffset;
-
-/**
- *
- * This class is separated from SQLServerBulkCopy class to resolve run-time error of missing Java 8 types when running with Java 7
- *
- */
-class SQLServerBulkCopy42Helper {
- static Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed,
- int srcJdbcType,
- int srcColOrdinal,
- DateTimeFormatter dateTimeFormatter,
- SQLServerConnection connection,
- SQLServerBulkCopy sqlServerBC) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- try {
- TemporalAccessor ta = dateTimeFormatter.parse(valueStrUntrimmed);
-
- int taHour, taMin, taSec, taYear, taMonth, taDay, taNano, taOffsetSec;
- taHour = taMin = taSec = taYear = taMonth = taDay = taNano = taOffsetSec = 0;
- if (ta.isSupported(ChronoField.NANO_OF_SECOND))
- taNano = ta.get(ChronoField.NANO_OF_SECOND);
- if (ta.isSupported(ChronoField.OFFSET_SECONDS))
- taOffsetSec = ta.get(ChronoField.OFFSET_SECONDS);
- if (ta.isSupported(ChronoField.HOUR_OF_DAY))
- taHour = ta.get(ChronoField.HOUR_OF_DAY);
- if (ta.isSupported(ChronoField.MINUTE_OF_HOUR))
- taMin = ta.get(ChronoField.MINUTE_OF_HOUR);
- if (ta.isSupported(ChronoField.SECOND_OF_MINUTE))
- taSec = ta.get(ChronoField.SECOND_OF_MINUTE);
- if (ta.isSupported(ChronoField.DAY_OF_MONTH))
- taDay = ta.get(ChronoField.DAY_OF_MONTH);
- if (ta.isSupported(ChronoField.MONTH_OF_YEAR))
- taMonth = ta.get(ChronoField.MONTH_OF_YEAR);
- if (ta.isSupported(ChronoField.YEAR))
- taYear = ta.get(ChronoField.YEAR);
-
- Calendar cal = new GregorianCalendar(new SimpleTimeZone(taOffsetSec * 1000, ""));
- cal.clear();
- cal.set(Calendar.HOUR_OF_DAY, taHour);
- cal.set(Calendar.MINUTE, taMin);
- cal.set(Calendar.SECOND, taSec);
- cal.set(Calendar.DATE, taDay);
- cal.set(Calendar.MONTH, taMonth - 1);
- cal.set(Calendar.YEAR, taYear);
- int fractionalSecondsLength = Integer.toString(taNano).length();
- for (int i = 0; i < (9 - fractionalSecondsLength); i++)
- taNano *= 10;
- Timestamp ts = new Timestamp(cal.getTimeInMillis());
- ts.setNanos(taNano);
-
- switch (srcJdbcType) {
- case java.sql.Types.TIMESTAMP:
- return ts;
- case java.sql.Types.TIME:
- // Time is returned as Timestamp to preserve nano seconds.
- cal.set(connection.baseYear(), Calendar.JANUARY, 01);
- ts = new java.sql.Timestamp(cal.getTimeInMillis());
- ts.setNanos(taNano);
- return new java.sql.Timestamp(ts.getTime());
- case java.sql.Types.DATE:
- return new java.sql.Date(ts.getTime());
- case microsoft.sql.Types.DATETIMEOFFSET:
- return DateTimeOffset.valueOf(ts, taOffsetSec / 60);
- }
- }
- catch (DateTimeException | ArithmeticException e) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ParsingError"));
- Object[] msgArgs = {JDBCType.of(srcJdbcType)};
- throw new SQLServerException(sqlServerBC, form.format(msgArgs), null, 0, false);
- }
- // unreachable code. Need to do to compile from Eclipse.
- return valueStrUntrimmed;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
index c30eab2fae..57da43fff7 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
@@ -22,11 +22,10 @@
import java.sql.ResultSet;
import java.sql.RowId;
import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLType;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
-import java.sql.Types;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -43,7 +42,7 @@
public class SQLServerCallableStatement extends SQLServerPreparedStatement implements ISQLServerCallableStatement {
/** the call param names */
- private ArrayList paramNames;
+ private ArrayList parameterNames;
/** Number of registered OUT parameters */
int nOutParams = 0;
@@ -87,6 +86,7 @@ String getClassNameInternal() {
super(connection, sql, nRSType, nRSConcur, stmtColEncSetting);
}
+ @Override
public void registerOutParameter(int index,
int sqlType) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -343,7 +343,8 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
}
}
- /* L0 */ public void registerOutParameter(int index,
+ @Override
+ public void registerOutParameter(int index,
int sqlType,
String typeName) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -356,12 +357,12 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
- /* L0 */ public void registerOutParameter(int index,
+ @Override
+ public void registerOutParameter(int index,
int sqlType,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {index, sqlType, scale});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType, scale});
checkClosed();
@@ -371,13 +372,13 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
+ @Override
public void registerOutParameter(int index,
int sqlType,
int precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {index, sqlType, scale, precision});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType, scale, precision});
checkClosed();
@@ -453,6 +454,7 @@ private Object getSQLXMLInternal(int parameterIndex) throws SQLServerException {
return value;
}
+ @Override
public int getInt(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getInt", index);
checkClosed();
@@ -461,14 +463,16 @@ public int getInt(int index) throws SQLServerException {
return null != value ? value : 0;
}
- public int getInt(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getInt", sCol);
+ @Override
+ public int getInt(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getInt", parameterName);
checkClosed();
- Integer value = (Integer) getValue(findColumn(sCol), JDBCType.INTEGER);
+ Integer value = (Integer) getValue(findColumn(parameterName), JDBCType.INTEGER);
loggerExternal.exiting(getClassNameLogging(), "getInt", value);
return null != value ? value : 0;
}
+ @Override
public String getString(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getString", index);
checkClosed();
@@ -480,12 +484,13 @@ public String getString(int index) throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "getString", value);
return value;
}
-
- public String getString(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getString", sCol);
+
+ @Override
+ public String getString(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getString", parameterName);
checkClosed();
String value = null;
- Object objectValue = getValue(findColumn(sCol), JDBCType.CHAR);
+ Object objectValue = getValue(findColumn(parameterName), JDBCType.CHAR);
if (null != objectValue) {
value = objectValue.toString();
}
@@ -493,6 +498,7 @@ public String getString(String sCol) throws SQLServerException {
return value;
}
+ @Override
public final String getNString(int parameterIndex) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNString", parameterIndex);
checkClosed();
@@ -501,6 +507,7 @@ public final String getNString(int parameterIndex) throws SQLException {
return value;
}
+ @Override
public final String getNString(String parameterName) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNString", parameterName);
checkClosed();
@@ -510,6 +517,7 @@ public final String getNString(String parameterName) throws SQLException {
}
@Deprecated
+ @Override
public BigDecimal getBigDecimal(int parameterIndex,
int scale) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -523,8 +531,9 @@ public BigDecimal getBigDecimal(int parameterIndex,
}
@Deprecated
+ @Override
public BigDecimal getBigDecimal(String parameterName,
- int scale) throws SQLException {
+ int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getBigDecimal", new Object[] {parameterName, scale});
checkClosed();
@@ -535,6 +544,7 @@ public BigDecimal getBigDecimal(String parameterName,
return value;
}
+ @Override
public boolean getBoolean(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getBoolean", index);
checkClosed();
@@ -543,14 +553,16 @@ public boolean getBoolean(int index) throws SQLServerException {
return null != value ? value : false;
}
- public boolean getBoolean(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBoolean", sCol);
+ @Override
+ public boolean getBoolean(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBoolean", parameterName);
checkClosed();
- Boolean value = (Boolean) getValue(findColumn(sCol), JDBCType.BIT);
+ Boolean value = (Boolean) getValue(findColumn(parameterName), JDBCType.BIT);
loggerExternal.exiting(getClassNameLogging(), "getBoolean", value);
return null != value ? value : false;
}
+ @Override
public byte getByte(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getByte", index);
checkClosed();
@@ -560,15 +572,17 @@ public byte getByte(int index) throws SQLServerException {
return byteValue;
}
- public byte getByte(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getByte", sCol);
+ @Override
+ public byte getByte(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getByte", parameterName);
checkClosed();
- Short shortValue = (Short) getValue(findColumn(sCol), JDBCType.TINYINT);
+ Short shortValue = (Short) getValue(findColumn(parameterName), JDBCType.TINYINT);
byte byteValue = (null != shortValue) ? shortValue.byteValue() : 0;
loggerExternal.exiting(getClassNameLogging(), "getByte", byteValue);
return byteValue;
}
+ @Override
public byte[] getBytes(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getBytes", index);
checkClosed();
@@ -577,14 +591,16 @@ public byte[] getBytes(int index) throws SQLServerException {
return value;
}
- public byte[] getBytes(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBytes", sCol);
+ @Override
+ public byte[] getBytes(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBytes", parameterName);
checkClosed();
- byte[] value = (byte[]) getValue(findColumn(sCol), JDBCType.BINARY);
+ byte[] value = (byte[]) getValue(findColumn(parameterName), JDBCType.BINARY);
loggerExternal.exiting(getClassNameLogging(), "getBytes", value);
return value;
}
+ @Override
public Date getDate(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getDate", index);
checkClosed();
@@ -593,14 +609,16 @@ public Date getDate(int index) throws SQLServerException {
return value;
}
- public Date getDate(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getDate", sCol);
+ @Override
+ public Date getDate(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getDate", parameterName);
checkClosed();
- java.sql.Date value = (java.sql.Date) getValue(findColumn(sCol), JDBCType.DATE);
+ java.sql.Date value = (java.sql.Date) getValue(findColumn(parameterName), JDBCType.DATE);
loggerExternal.exiting(getClassNameLogging(), "getDate", value);
return value;
}
+ @Override
public Date getDate(int index,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -611,16 +629,18 @@ public Date getDate(int index,
return value;
}
- public Date getDate(String sCol,
+ @Override
+ public Date getDate(String parameterName,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "getDate", new Object[] {sCol, cal});
+ loggerExternal.entering(getClassNameLogging(), "getDate", new Object[] {parameterName, cal});
checkClosed();
- java.sql.Date value = (java.sql.Date) getValue(findColumn(sCol), JDBCType.DATE, cal);
+ java.sql.Date value = (java.sql.Date) getValue(findColumn(parameterName), JDBCType.DATE, cal);
loggerExternal.exiting(getClassNameLogging(), "getDate", value);
return value;
}
+ @Override
public double getDouble(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getDouble", index);
checkClosed();
@@ -629,14 +649,16 @@ public double getDouble(int index) throws SQLServerException {
return null != value ? value : 0;
}
- public double getDouble(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getDouble", sCol);
+ @Override
+ public double getDouble(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getDouble", parameterName);
checkClosed();
- Double value = (Double) getValue(findColumn(sCol), JDBCType.DOUBLE);
+ Double value = (Double) getValue(findColumn(parameterName), JDBCType.DOUBLE);
loggerExternal.exiting(getClassNameLogging(), "getDouble", value);
return null != value ? value : 0;
}
+ @Override
public float getFloat(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getFloat", index);
checkClosed();
@@ -645,15 +667,17 @@ public float getFloat(int index) throws SQLServerException {
return null != value ? value : 0;
}
- public float getFloat(String sCol) throws SQLServerException {
+ @Override
+ public float getFloat(String parameterName) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getFloat", sCol);
+ loggerExternal.entering(getClassNameLogging(), "getFloat", parameterName);
checkClosed();
- Float value = (Float) getValue(findColumn(sCol), JDBCType.REAL);
+ Float value = (Float) getValue(findColumn(parameterName), JDBCType.REAL);
loggerExternal.exiting(getClassNameLogging(), "getFloat", value);
return null != value ? value : 0;
}
+ @Override
public long getLong(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getLong", index);
@@ -663,14 +687,16 @@ public long getLong(int index) throws SQLServerException {
return null != value ? value : 0;
}
- public long getLong(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getLong", sCol);
+ @Override
+ public long getLong(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getLong", parameterName);
checkClosed();
- Long value = (Long) getValue(findColumn(sCol), JDBCType.BIGINT);
+ Long value = (Long) getValue(findColumn(parameterName), JDBCType.BIGINT);
loggerExternal.exiting(getClassNameLogging(), "getLong", value);
return null != value ? value : 0;
}
+ @Override
public Object getObject(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getObject", index);
@@ -681,6 +707,7 @@ public Object getObject(int index) throws SQLServerException {
return value;
}
+ @Override
public T getObject(int index,
Class type) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getObject", index);
@@ -763,26 +790,30 @@ else if (type == Double.class) {
return type.cast(returnValue);
}
- public Object getObject(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getObject", sCol);
+ @Override
+ public Object getObject(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getObject", parameterName);
checkClosed();
- int parameterIndex = findColumn(sCol);
- Object value = getValue(parameterIndex, getterGetParam(parameterIndex).getJdbcTypeSetByUser() != null
- ? getterGetParam(parameterIndex).getJdbcTypeSetByUser() : getterGetParam(parameterIndex).getJdbcType());
+ int parameterIndex = findColumn(parameterName);
+ Object value = getValue(parameterIndex,
+ getterGetParam(parameterIndex).getJdbcTypeSetByUser() != null ? getterGetParam(parameterIndex).getJdbcTypeSetByUser()
+ : getterGetParam(parameterIndex).getJdbcType());
loggerExternal.exiting(getClassNameLogging(), "getObject", value);
return value;
}
- public T getObject(String sCol,
+ @Override
+ public T getObject(String parameterName,
Class type) throws SQLException {
- loggerExternal.entering(getClassNameLogging(), "getObject", sCol);
+ loggerExternal.entering(getClassNameLogging(), "getObject", parameterName);
checkClosed();
- int parameterIndex = findColumn(sCol);
+ int parameterIndex = findColumn(parameterName);
T value = getObject(parameterIndex, type);
loggerExternal.exiting(getClassNameLogging(), "getObject", value);
return value;
}
+ @Override
public short getShort(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getShort", index);
@@ -792,14 +823,16 @@ public short getShort(int index) throws SQLServerException {
return null != value ? value : 0;
}
- public short getShort(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getShort", sCol);
+ @Override
+ public short getShort(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getShort", parameterName);
checkClosed();
- Short value = (Short) getValue(findColumn(sCol), JDBCType.SMALLINT);
+ Short value = (Short) getValue(findColumn(parameterName), JDBCType.SMALLINT);
loggerExternal.exiting(getClassNameLogging(), "getShort", value);
return null != value ? value : 0;
}
+ @Override
public Time getTime(int index) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getTime", index);
@@ -809,14 +842,16 @@ public Time getTime(int index) throws SQLServerException {
return value;
}
- public Time getTime(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getTime", sCol);
+ @Override
+ public Time getTime(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getTime", parameterName);
checkClosed();
- java.sql.Time value = (java.sql.Time) getValue(findColumn(sCol), JDBCType.TIME);
+ java.sql.Time value = (java.sql.Time) getValue(findColumn(parameterName), JDBCType.TIME);
loggerExternal.exiting(getClassNameLogging(), "getTime", value);
return value;
}
+ @Override
public Time getTime(int index,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -827,16 +862,18 @@ public Time getTime(int index,
return value;
}
- public Time getTime(String sCol,
+ @Override
+ public Time getTime(String parameterName,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "getTime", new Object[] {sCol, cal});
+ loggerExternal.entering(getClassNameLogging(), "getTime", new Object[] {parameterName, cal});
checkClosed();
- java.sql.Time value = (java.sql.Time) getValue(findColumn(sCol), JDBCType.TIME, cal);
+ java.sql.Time value = (java.sql.Time) getValue(findColumn(parameterName), JDBCType.TIME, cal);
loggerExternal.exiting(getClassNameLogging(), "getTime", value);
return value;
}
+ @Override
public Timestamp getTimestamp(int index) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getTimestamp", index);
@@ -846,14 +883,16 @@ public Timestamp getTimestamp(int index) throws SQLServerException {
return value;
}
- public Timestamp getTimestamp(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getTimestamp", sCol);
+ @Override
+ public Timestamp getTimestamp(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getTimestamp", parameterName);
checkClosed();
- java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(sCol), JDBCType.TIMESTAMP);
+ java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(parameterName), JDBCType.TIMESTAMP);
loggerExternal.exiting(getClassNameLogging(), "getTimestamp", value);
return value;
}
+ @Override
public Timestamp getTimestamp(int index,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -864,6 +903,7 @@ public Timestamp getTimestamp(int index,
return value;
}
+ @Override
public Timestamp getTimestamp(String name,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -874,16 +914,7 @@ public Timestamp getTimestamp(String name,
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language.
- *
- * @param index
- * the first column is 1, the second is 2, ...
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getDateTime(int index) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDateTime", index);
@@ -893,38 +924,16 @@ public Timestamp getDateTime(int index) throws SQLServerException {
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language.
- *
- * @param sCol
- * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the
- * column
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
- public Timestamp getDateTime(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getDateTime", sCol);
+ @Override
+ public Timestamp getDateTime(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getDateTime", parameterName);
checkClosed();
- java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(sCol), JDBCType.DATETIME);
+ java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(parameterName), JDBCType.DATETIME);
loggerExternal.exiting(getClassNameLogging(), "getDateTime", value);
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
- * not store timezone information.
- *
- * @param index
- * the first column is 1, the second is 2, ...
- * @param cal
- * the java.util.Calendar object to use in constructing the dateTime
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getDateTime(int index,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -935,19 +944,7 @@ public Timestamp getDateTime(int index,
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language. This method uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does
- * not store timezone information.
- *
- * @param name
- * the name of the column
- * @param cal
- * the java.util.Calendar object to use in constructing the dateTime
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getDateTime(String name,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -958,16 +955,7 @@ public Timestamp getDateTime(String name,
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language.
- *
- * @param index
- * the first column is 1, the second is 2, ...
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getSmallDateTime(int index) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", index);
@@ -977,36 +965,16 @@ public Timestamp getSmallDateTime(int index) throws SQLServerException {
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language.
- *
- * @param sCol
- * The name of a column.
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
- public Timestamp getSmallDateTime(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", sCol);
+ @Override
+ public Timestamp getSmallDateTime(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", parameterName);
checkClosed();
- java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(sCol), JDBCType.SMALLDATETIME);
+ java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(parameterName), JDBCType.SMALLDATETIME);
loggerExternal.exiting(getClassNameLogging(), "getSmallDateTime", value);
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming
- * language.
- *
- * @param index
- * the first column is 1, the second is 2, ...
- * @param cal
- * the java.util.Calendar object to use in constructing the smalldateTime
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getSmallDateTime(int index,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1017,16 +985,7 @@ public Timestamp getSmallDateTime(int index,
return value;
}
- /**
- *
- * @param name
- * The name of a column
- * @param cal
- * the java.util.Calendar object to use in constructing the smalldateTime
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public Timestamp getSmallDateTime(String name,
Calendar cal) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1037,7 +996,8 @@ public Timestamp getSmallDateTime(String name,
return value;
}
- public microsoft.sql.DateTimeOffset getDateTimeOffset(int index) throws SQLException {
+ @Override
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(int index) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDateTimeOffset", index);
checkClosed();
@@ -1052,8 +1012,9 @@ public microsoft.sql.DateTimeOffset getDateTimeOffset(int index) throws SQLExcep
return value;
}
- public microsoft.sql.DateTimeOffset getDateTimeOffset(String sCol) throws SQLException {
- loggerExternal.entering(getClassNameLogging(), "getDateTimeOffset", sCol);
+ @Override
+ public microsoft.sql.DateTimeOffset getDateTimeOffset(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getDateTimeOffset", parameterName);
checkClosed();
// DateTimeOffset is not supported with SQL Server versions earlier than Katmai
@@ -1061,12 +1022,13 @@ public microsoft.sql.DateTimeOffset getDateTimeOffset(String sCol) throws SQLExc
throw new SQLServerException(SQLServerException.getErrString("R_notSupported"), SQLState.DATA_EXCEPTION_NOT_SPECIFIC, DriverError.NOT_SET,
null);
- microsoft.sql.DateTimeOffset value = (microsoft.sql.DateTimeOffset) getValue(findColumn(sCol), JDBCType.DATETIMEOFFSET);
+ microsoft.sql.DateTimeOffset value = (microsoft.sql.DateTimeOffset) getValue(findColumn(parameterName), JDBCType.DATETIMEOFFSET);
loggerExternal.exiting(getClassNameLogging(), "getDateTimeOffset", value);
return value;
}
- /* L0 */ public boolean wasNull() throws SQLServerException {
+ @Override
+ public boolean wasNull() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "wasNull");
checkClosed();
boolean bWasNull = false;
@@ -1077,213 +1039,124 @@ public microsoft.sql.DateTimeOffset getDateTimeOffset(String sCol) throws SQLExc
return bWasNull;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters. The
- * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARCHAR values.
- * The JDBC driver will do any necessary conversion from the database format into ASCII.
- *
- *
- * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
- * implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether
- * there is data available or not.
- *
- * @param paramIndex
- * the first column is 1, the second is 2, ...
- * @return a Java input stream that delivers the database column value as a stream of one-byte ASCII characters; if the value is SQL
- * NULL, the value returned is null
- * @throws SQLServerException
- * if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
- */
- public final java.io.InputStream getAsciiStream(int paramIndex) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getAsciiStream", paramIndex);
+ @Override
+ public final java.io.InputStream getAsciiStream(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getAsciiStream", parameterIndex);
checkClosed();
- InputStream value = (InputStream) getStream(paramIndex, StreamType.ASCII);
+ InputStream value = (InputStream) getStream(parameterIndex, StreamType.ASCII);
loggerExternal.exiting(getClassNameLogging(), "getAsciiStream", value);
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters. The
- * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARCHAR values.
- * The JDBC driver will do any necessary conversion from the database format into ASCII.
- *
- *
- * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
- * implicitly closes the stream. Also, a stream may return 0 when the method available is called whether there is data
- * available or not.
- *
- * @param paramName
- * the name of the parameter
- * @return a Java input stream that delivers the database column value as a stream of one-byte ASCII characters. If the value is SQL
- * NULL, the value returned is null.
- * @throws SQLServerException
- * if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
- */
- public final java.io.InputStream getAsciiStream(String paramName) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getAsciiStream", paramName);
+ @Override
+ public final java.io.InputStream getAsciiStream(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getAsciiStream", parameterName);
checkClosed();
- InputStream value = (InputStream) getStream(findColumn(paramName), StreamType.ASCII);
+ InputStream value = (InputStream) getStream(findColumn(parameterName), StreamType.ASCII);
loggerExternal.exiting(getClassNameLogging(), "getAsciiStream", value);
return value;
}
- public BigDecimal getBigDecimal(int index) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBigDecimal", index);
+ @Override
+ public BigDecimal getBigDecimal(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBigDecimal", parameterIndex);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(index, JDBCType.DECIMAL);
+ BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.DECIMAL);
loggerExternal.exiting(getClassNameLogging(), "getBigDecimal", value);
return value;
}
- public BigDecimal getBigDecimal(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBigDecimal", sCol);
+ @Override
+ public BigDecimal getBigDecimal(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBigDecimal", parameterName);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(findColumn(sCol), JDBCType.DECIMAL);
+ BigDecimal value = (BigDecimal) getValue(findColumn(parameterName), JDBCType.DECIMAL);
loggerExternal.exiting(getClassNameLogging(), "getBigDecimal", value);
return value;
}
- /**
- * Retrieves the value of the column specified as a java.math.BigDecimal object.
- *
- * @param index
- * The zero-based ordinal of a column.
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
- public BigDecimal getMoney(int index) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getMoney", index);
+ @Override
+ public BigDecimal getMoney(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getMoney", parameterIndex);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(index, JDBCType.MONEY);
+ BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.MONEY);
loggerExternal.exiting(getClassNameLogging(), "getMoney", value);
return value;
}
- /**
- * Retrieves the value of the column specified as a java.math.BigDecimal object.
- *
- * @param sCol
- * The name of a column.
- * @return the column value; if the value is SQL NULL, the value returned is null.
- * @throws SQLServerException
- * when an error occurs
- */
- public BigDecimal getMoney(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getMoney", sCol);
+ @Override
+ public BigDecimal getMoney(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getMoney", parameterName);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(findColumn(sCol), JDBCType.MONEY);
+ BigDecimal value = (BigDecimal) getValue(findColumn(parameterName), JDBCType.MONEY);
loggerExternal.exiting(getClassNameLogging(), "getMoney", value);
return value;
}
- /**
- * Retrieves the value of the column specified as a java.math.BigDecimal object.
- *
- * @param index
- * The zero-based ordinal of a column.
- * @return the column value; if the value is SQL NULL, the value returned is null
- * @throws SQLServerException
- * when an error occurs
- */
- public BigDecimal getSmallMoney(int index) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getSmallMoney", index);
+ @Override
+ public BigDecimal getSmallMoney(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getSmallMoney", parameterIndex);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(index, JDBCType.SMALLMONEY);
+ BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.SMALLMONEY);
loggerExternal.exiting(getClassNameLogging(), "getSmallMoney", value);
return value;
}
- /**
- * Retrieves the value of the column specified as a java.math.BigDecimal object.
- *
- * @param sCol
- * The name of a column.
- * @return the column value; if the value is SQL NULL, the value returned is null.
- * @throws SQLServerException
- * when an error occurs
- */
- public BigDecimal getSmallMoney(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getSmallMoney", sCol);
+ @Override
+ public BigDecimal getSmallMoney(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getSmallMoney", parameterName);
checkClosed();
- BigDecimal value = (BigDecimal) getValue(findColumn(sCol), JDBCType.SMALLMONEY);
+ BigDecimal value = (BigDecimal) getValue(findColumn(parameterName), JDBCType.SMALLMONEY);
loggerExternal.exiting(getClassNameLogging(), "getSmallMoney", value);
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted bytes. The
- * value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARBINARY values.
- *
- *
- * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
- * implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether
- * there is data available or not.
- *
- * @param paramIndex
- * the first column is 1, the second is 2, ...
- * @return a Java input stream that delivers the database column value as a stream of uninterpreted bytes; if the value is SQL NULL,
- * the value returned is null
- * @throws SQLServerException
- * if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
- */
- public final java.io.InputStream getBinaryStream(int paramIndex) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBinaryStream", paramIndex);
+ @Override
+ public final java.io.InputStream getBinaryStream(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBinaryStream", parameterIndex);
checkClosed();
- InputStream value = (InputStream) getStream(paramIndex, StreamType.BINARY);
+ InputStream value = (InputStream) getStream(parameterIndex, StreamType.BINARY);
loggerExternal.exiting(getClassNameLogging(), "getBinaryStream", value);
return value;
}
- /**
- * Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted
- * bytes. The value can then be read in chunks from the stream. This method is particularly suitable for retrieving large
- * LONGVARBINARY values.
- *
- *
- * Note: All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method
- * implicitly closes the stream. Also, a stream may return 0 when the method available is called whether there is data
- * available or not.
- *
- * @param paramName
- * the name of the parameter
- * @return a Java input stream that delivers the database column value as a stream of uninterpreted bytes; if the value is SQL NULL,
- * the result is null
- * @throws SQLServerException
- * if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
- */
- public final java.io.InputStream getBinaryStream(String paramName) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBinaryStream", paramName);
+ @Override
+ public final java.io.InputStream getBinaryStream(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBinaryStream", parameterName);
checkClosed();
- InputStream value = (InputStream) getStream(findColumn(paramName), StreamType.BINARY);
+ InputStream value = (InputStream) getStream(findColumn(parameterName), StreamType.BINARY);
loggerExternal.exiting(getClassNameLogging(), "getBinaryStream", value);
return value;
}
- public Blob getBlob(int index) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBlob", index);
+ @Override
+ public Blob getBlob(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBlob", parameterIndex);
checkClosed();
- Blob value = (Blob) getValue(index, JDBCType.BLOB);
+ Blob value = (Blob) getValue(parameterIndex, JDBCType.BLOB);
loggerExternal.exiting(getClassNameLogging(), "getBlob", value);
return value;
}
- public Blob getBlob(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getBlob", sCol);
+ @Override
+ public Blob getBlob(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getBlob", parameterName);
checkClosed();
- Blob value = (Blob) getValue(findColumn(sCol), JDBCType.BLOB);
+ Blob value = (Blob) getValue(findColumn(parameterName), JDBCType.BLOB);
loggerExternal.exiting(getClassNameLogging(), "getBlob", value);
return value;
}
- public final java.io.Reader getCharacterStream(int paramIndex) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getCharacterStream", paramIndex);
+ @Override
+ public final java.io.Reader getCharacterStream(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getCharacterStream", parameterIndex);
checkClosed();
- Reader reader = (Reader) getStream(paramIndex, StreamType.CHARACTER);
+ Reader reader = (Reader) getStream(parameterIndex, StreamType.CHARACTER);
loggerExternal.exiting(getClassNameLogging(), "getCharacterStream", reader);
return reader;
}
+ @Override
public final java.io.Reader getCharacterStream(String parameterName) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getCharacterStream", parameterName);
checkClosed();
@@ -1292,6 +1165,7 @@ public final java.io.Reader getCharacterStream(String parameterName) throws SQLE
return reader;
}
+ @Override
public final java.io.Reader getNCharacterStream(int parameterIndex) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNCharacterStream", parameterIndex);
checkClosed();
@@ -1300,6 +1174,7 @@ public final java.io.Reader getNCharacterStream(int parameterIndex) throws SQLEx
return reader;
}
+ @Override
public final java.io.Reader getNCharacterStream(String parameterName) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNCharacterStream", parameterName);
checkClosed();
@@ -1322,22 +1197,25 @@ void closeActiveStream() throws SQLServerException {
}
}
- public Clob getClob(int index) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getClob", index);
+ @Override
+ public Clob getClob(int parameterIndex) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getClob", parameterIndex);
checkClosed();
- Clob clob = (Clob) getValue(index, JDBCType.CLOB);
+ Clob clob = (Clob) getValue(parameterIndex, JDBCType.CLOB);
loggerExternal.exiting(getClassNameLogging(), "getClob", clob);
return clob;
}
- public Clob getClob(String sCol) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "getClob", sCol);
+ @Override
+ public Clob getClob(String parameterName) throws SQLServerException {
+ loggerExternal.entering(getClassNameLogging(), "getClob", parameterName);
checkClosed();
- Clob clob = (Clob) getValue(findColumn(sCol), JDBCType.CLOB);
+ Clob clob = (Clob) getValue(findColumn(parameterName), JDBCType.CLOB);
loggerExternal.exiting(getClassNameLogging(), "getClob", clob);
return clob;
}
+ @Override
public NClob getNClob(int parameterIndex) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNClob", parameterIndex);
checkClosed();
@@ -1346,6 +1224,7 @@ public NClob getNClob(int parameterIndex) throws SQLException {
return nClob;
}
+ @Override
public NClob getNClob(String parameterName) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNClob", parameterName);
checkClosed();
@@ -1354,36 +1233,42 @@ public NClob getNClob(String parameterName) throws SQLException {
return nClob;
}
- /* L0 */ public Object getObject(int index,
- java.util.Map> map) throws SQLServerException {
- NotImplemented();
+ @Override
+ public Object getObject(int parameterIndex,
+ java.util.Map> map) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
return null;
}
- /* L3 */ public Object getObject(String sCol,
- java.util.Map> m) throws SQLServerException {
+ @Override
+ public Object getObject(String parameterName,
+ java.util.Map> m) throws SQLException {
checkClosed();
- return getObject(findColumn(sCol), m);
+ return getObject(findColumn(parameterName), m);
}
- /* L0 */ public Ref getRef(int i) throws SQLServerException {
- NotImplemented();
+ @Override
+ public Ref getRef(int parameterIndex) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
return null;
}
- /* L3 */ public Ref getRef(String sCol) throws SQLServerException {
+ @Override
+ public Ref getRef(String parameterName) throws SQLException {
checkClosed();
- return getRef(findColumn(sCol));
+ return getRef(findColumn(parameterName));
}
- /* L0 */ public java.sql.Array getArray(int i) throws SQLServerException {
- NotImplemented();
+ @Override
+ public java.sql.Array getArray(int parameterIndex) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
return null;
}
- /* L3 */ public java.sql.Array getArray(String sCol) throws SQLServerException {
+ @Override
+ public java.sql.Array getArray(String parameterName) throws SQLException {
checkClosed();
- return getArray(findColumn(sCol));
+ return getArray(findColumn(parameterName));
}
/* JDBC 3.0 */
@@ -1397,14 +1282,13 @@ public NClob getNClob(String parameterName) throws SQLException {
* when an error occurs
* @return the index
*/
- /* L3 */ private int findColumn(String columnName) throws SQLServerException {
- if (paramNames == null) {
- SQLServerStatement s = null;
- try {
+ private int findColumn(String columnName) throws SQLServerException {
+ if (parameterNames == null) {
+ try (SQLServerStatement s = (SQLServerStatement) connection.createStatement()) {
// Note we are concatenating the information from the passed in sql, not any arguments provided by the user
// if the user can execute the sql, any fragments of it is potentially executed via the meta data call through injection
// is not a security issue.
- s = (SQLServerStatement) connection.createStatement();
+
ThreePartName threePartName = ThreePartName.parse(procedureName);
StringBuilder metaQuery = new StringBuilder("exec sp_sproc_columns ");
if (null != threePartName.getDatabasePart()) {
@@ -1424,7 +1308,7 @@ public NClob getNClob(String parameterName) throws SQLException {
metaQuery.append(" , @ODBCVer=3");
}
else {
- // This should rarely happen, this will only happen if we cant find the stored procedure name
+ // This should rarely happen, this will only happen if we can't find the stored procedure name
// invalidly formatted call syntax.
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_parameterNotDefinedForProcedure"));
Object[] msgArgs = {columnName, ""};
@@ -1432,36 +1316,34 @@ public NClob getNClob(String parameterName) throws SQLException {
}
ResultSet rs = s.executeQueryInternal(metaQuery.toString());
- paramNames = new ArrayList<>();
+ parameterNames = new ArrayList<>();
while (rs.next()) {
- String sCol = rs.getString(4);
- paramNames.add(sCol.trim());
+ String parameterName = rs.getString(4);
+ parameterNames.add(parameterName.trim());
}
}
catch (SQLException e) {
SQLServerException.makeFromDriverError(connection, this, e.toString(), null, false);
}
- finally {
- if (null != s)
- s.close();
- }
+
}
int l = 0;
- if (paramNames != null)
- l = paramNames.size();
- if (l == 0)//Server didn't return anything, user might not have access
- return 1;//attempting to look up the first column will return no access exception
+ if (parameterNames != null)
+ l = parameterNames.size();
+ if (l == 0)// Server didn't return anything, user might not have access
+ return 1;// attempting to look up the first column will return no access exception
- // handle `@name` as well as `name`, since `@name` is what's returned
+ // handle `@name` as well as `name`, since `@name` is what's returned
// by DatabaseMetaData#getProcedureColumns
String columnNameWithoutAtSign = null;
if (columnName.startsWith("@")) {
columnNameWithoutAtSign = columnName.substring(1, columnName.length());
- } else {
+ }
+ else {
columnNameWithoutAtSign = columnName;
}
-
+
// In order to be as accurate as possible when locating parameter name
// indexes, as well as be deterministic when running on various client
// locales, we search for parameter names using the following scheme:
@@ -1474,7 +1356,7 @@ public NClob getNClob(String parameterName) throws SQLException {
// Search using case-sensitive, non-locale specific (binary) compare.
// If the user supplies a true match for the parameter name, we will find it here.
for (i = 0; i < l; i++) {
- String sParam = paramNames.get(i);
+ String sParam = parameterNames.get(i);
sParam = sParam.substring(1, sParam.length());
if (sParam.equals(columnNameWithoutAtSign)) {
matchPos = i;
@@ -1486,7 +1368,7 @@ public NClob getNClob(String parameterName) throws SQLException {
// Check for case-insensitive match using a non-locale aware method.
// Use VM supplied String.equalsIgnoreCase to do the "case-insensitive search".
for (i = 0; i < l; i++) {
- String sParam = paramNames.get(i);
+ String sParam = parameterNames.get(i);
sParam = sParam.substring(1, sParam.length());
if (sParam.equalsIgnoreCase(columnNameWithoutAtSign)) {
matchPos = i;
@@ -1500,6 +1382,7 @@ public NClob getNClob(String parameterName) throws SQLException {
Object[] msgArgs = {columnName, procedureName};
SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), "07009", false);
}
+
// @RETURN_VALUE is always in the list. If the user uses return value ?=call(@p1) syntax then
// @p1 is index 2 otherwise its index 1.
if (bReturnValueSyntax) // 3.2717
@@ -1508,130 +1391,76 @@ public NClob getNClob(String parameterName) throws SQLException {
return matchPos;
}
- public void setTimestamp(String sCol,
- java.sql.Timestamp x,
- Calendar c) throws SQLServerException {
+ @Override
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
+ Calendar calendar) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTimeStamp", new Object[] {sCol, x, c});
+ loggerExternal.entering(getClassNameLogging(), "setTimeStamp", new Object[] {parameterName, value, calendar});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIMESTAMP, x, JavaType.TIMESTAMP, c, false);
+ setValue(findColumn(parameterName), JDBCType.TIMESTAMP, value, JavaType.TIMESTAMP, calendar, false);
loggerExternal.exiting(getClassNameLogging(), "setTimeStamp");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @param c
- * a java.util.Calendar
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTimestamp
- */
- public void setTimestamp(String sCol,
- java.sql.Timestamp x,
- Calendar c,
+ @Override
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
+ Calendar calendar,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTimeStamp", new Object[] {sCol, x, c, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setTimeStamp", new Object[] {parameterName, value, calendar, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIMESTAMP, x, JavaType.TIMESTAMP, c, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.TIMESTAMP, value, JavaType.TIMESTAMP, calendar, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setTimeStamp");
}
- public void setTime(String sCol,
- java.sql.Time x,
- Calendar c) throws SQLServerException {
+ @Override
+ public void setTime(String parameterName,
+ java.sql.Time value,
+ Calendar calendar) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {sCol, x, c});
+ loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {parameterName, value, calendar});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIME, x, JavaType.TIME, c, false);
+ setValue(findColumn(parameterName), JDBCType.TIME, value, JavaType.TIME, calendar, false);
loggerExternal.exiting(getClassNameLogging(), "setTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Time value, using the given Calendar object. The driver uses the
- * Calendar object to construct an SQL TIME value, which the driver then sends to the database. With a a
- * Calendar object, the driver can calculate the time taking into account a custom timezone. If no Calendar object is
- * specified, the driver uses the default timezone, which is that of the virtual machine running the application.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @param c
- * the Calendar object the driver will use to construct the time
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTime
- */
- public void setTime(String sCol,
- java.sql.Time x,
- Calendar c,
+ @Override
+ public void setTime(String parameterName,
+ java.sql.Time value,
+ Calendar calendar,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {sCol, x, c, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {parameterName, value, calendar, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIME, x, JavaType.TIME, c, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.TIME, value, JavaType.TIME, calendar, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setTime");
}
- public void setDate(String sCol,
- java.sql.Date x,
- Calendar c) throws SQLServerException {
+ @Override
+ public void setDate(String parameterName,
+ java.sql.Date value,
+ Calendar calendar) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {sCol, x, c});
+ loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {parameterName, value, calendar});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATE, x, JavaType.DATE, c, false);
+ setValue(findColumn(parameterName), JDBCType.DATE, value, JavaType.DATE, calendar, false);
loggerExternal.exiting(getClassNameLogging(), "setDate");
}
- /**
- * Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the
- * Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a a
- * Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is
- * specified, the driver uses the default timezone, which is that of the virtual machine running the application.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @param c
- * the Calendar object the driver will use to construct the date
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getDate
- */
- public void setDate(String sCol,
- java.sql.Date x,
- Calendar c,
+ @Override
+ public void setDate(String parameterName,
+ java.sql.Date value,
+ Calendar calendar,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {sCol, x, c, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {parameterName, value, calendar, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATE, x, JavaType.DATE, c, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.DATE, value, JavaType.DATE, calendar, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setDate");
}
+ @Override
public final void setCharacterStream(String parameterName,
Reader reader) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1641,6 +1470,7 @@ public final void setCharacterStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setCharacterStream");
}
+ @Override
public final void setCharacterStream(String parameterName,
Reader value,
int length) throws SQLException {
@@ -1651,6 +1481,7 @@ public final void setCharacterStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setCharacterStream");
}
+ @Override
public final void setCharacterStream(String parameterName,
Reader reader,
long length) throws SQLException {
@@ -1662,6 +1493,7 @@ public final void setCharacterStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setCharacterStream");
}
+ @Override
public final void setNCharacterStream(String parameterName,
Reader value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1671,6 +1503,7 @@ public final void setNCharacterStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNCharacterStream");
}
+ @Override
public final void setNCharacterStream(String parameterName,
Reader value,
long length) throws SQLException {
@@ -1681,15 +1514,17 @@ public final void setNCharacterStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNCharacterStream");
}
+ @Override
public final void setClob(String parameterName,
- Clob x) throws SQLException {
+ Clob value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setClob", new Object[] {parameterName, x});
+ loggerExternal.entering(getClassNameLogging(), "setClob", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(parameterName), JDBCType.CLOB, x, JavaType.CLOB, false);
+ setValue(findColumn(parameterName), JDBCType.CLOB, value, JavaType.CLOB, false);
loggerExternal.exiting(getClassNameLogging(), "setClob");
}
+ @Override
public final void setClob(String parameterName,
Reader reader) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1699,6 +1534,7 @@ public final void setClob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setClob");
}
+ @Override
public final void setClob(String parameterName,
Reader value,
long length) throws SQLException {
@@ -1709,6 +1545,7 @@ public final void setClob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setClob");
}
+ @Override
public final void setNClob(String parameterName,
NClob value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1718,6 +1555,7 @@ public final void setNClob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNClob");
}
+ @Override
public final void setNClob(String parameterName,
Reader reader) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1727,6 +1565,7 @@ public final void setNClob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNClob");
}
+ @Override
public final void setNClob(String parameterName,
Reader reader,
long length) throws SQLException {
@@ -1737,6 +1576,7 @@ public final void setNClob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNClob");
}
+ @Override
public final void setNString(String parameterName,
String value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1746,26 +1586,10 @@ public final void setNString(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNString");
}
- /**
- * Sets the designated parameter to the given String object. The driver converts this to a SQL NCHAR or
- * NVARCHAR or LONGNVARCHAR
- *
- * @param parameterName
- * the name of the parameter to be set
- * @param value
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLException
- * if parameterName does not correspond to a named parameter; if the driver does not support national character sets; if the driver
- * can detect that a data conversion error could occur; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
+ @Override
public final void setNString(String parameterName,
String value,
- boolean forceEncrypt) throws SQLException {
+ boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "setNString", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
@@ -1773,131 +1597,77 @@ public final void setNString(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setNString");
}
- public void setObject(String sCol,
- Object o) throws SQLServerException {
+ @Override
+ public void setObject(String parameterName,
+ Object value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, o});
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value});
checkClosed();
- setObjectNoType(findColumn(sCol), o, false);
+ setObjectNoType(findColumn(parameterName), value, false);
loggerExternal.exiting(getClassNameLogging(), "setObject");
}
- public void setObject(String sCol,
- Object o,
- int n) throws SQLServerException {
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ int sqlType) throws SQLServerException {
String tvpName = null;
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, o, n});
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, sqlType});
checkClosed();
- if (microsoft.sql.Types.STRUCTURED == n) {
- tvpName = getTVPNameIfNull(findColumn(sCol), null);
- setObject(setterGetParam(findColumn(sCol)), o, JavaType.TVP, JDBCType.TVP, null, null, false, findColumn(sCol), tvpName);
+ if (microsoft.sql.Types.STRUCTURED == sqlType) {
+ tvpName = getTVPNameIfNull(findColumn(parameterName), null);
+ setObject(setterGetParam(findColumn(parameterName)), value, JavaType.TVP, JDBCType.TVP, null, null, false, findColumn(parameterName),
+ tvpName);
}
else
- setObject(setterGetParam(findColumn(sCol)), o, JavaType.of(o), JDBCType.of(n), null, null, false, findColumn(sCol), tvpName);
+ setObject(setterGetParam(findColumn(parameterName)), value, JavaType.of(value), JDBCType.of(sqlType), null, null, false,
+ findColumn(parameterName), tvpName);
loggerExternal.exiting(getClassNameLogging(), "setObject");
}
- public void setObject(String sCol,
- Object o,
- int n,
- int m) throws SQLServerException {
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ int sqlType,
+ int decimals) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, o, n, m});
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, sqlType, decimals});
checkClosed();
-
- setObject(setterGetParam(findColumn(sCol)), o, JavaType.of(o), JDBCType.of(n), m, null, false, findColumn(sCol), null);
-
+ setObject(setterGetParam(findColumn(parameterName)), value, JavaType.of(value), JDBCType.of(sqlType), decimals, null, false,
+ findColumn(parameterName), null);
loggerExternal.exiting(getClassNameLogging(), "setObject");
}
- /**
- * Sets the value of the designated parameter with the given object.
- *
- *
- * The given Java object will be converted to the given targetSqlType before being sent to the database.
- *
- * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
- * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
- * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
- * Array, the driver should pass it to the database as a value of the corresponding SQL type.
- *
- * Note that this method may be used to pass datatabase- specific abstract data types.
- *
- * @param sCol
- * the name of the parameter
- * @param o
- * the object containing the input parameter value
- * @param n
- * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
- * @param m
- * for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other
- * types, this value will be ignored.
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see Types
- * @see #getObject
- */
- public void setObject(String sCol,
- Object o,
- int n,
- int m,
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ int sqlType,
+ int decimals,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, o, n, m, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, sqlType, decimals, forceEncrypt});
checkClosed();
// scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
// this is the number of digits after the decimal point.
// For all other types, this value will be ignored.
- setObject(setterGetParam(findColumn(sCol)), o, JavaType.of(o), JDBCType.of(n),
- (java.sql.Types.NUMERIC == n || java.sql.Types.DECIMAL == n) ? m : null, null, forceEncrypt, findColumn(sCol), null);
+ setObject(setterGetParam(findColumn(parameterName)), value, JavaType.of(value), JDBCType.of(sqlType),
+ (java.sql.Types.NUMERIC == sqlType || java.sql.Types.DECIMAL == sqlType) ? decimals : null, null, forceEncrypt,
+ findColumn(parameterName), null);
loggerExternal.exiting(getClassNameLogging(), "setObject");
}
- /**
- * Sets the value of the designated parameter with the given object.
- *
- *
- * The given Java object will be converted to the given targetSqlType before being sent to the database.
- *
- * If the object has a custom mapping (is of a class implementing the interface SQLData), the JDBC driver should call the method
- * SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing
- * Ref, Blob, Clob, NClob, Struct, java.net.URL, or
- * Array, the driver should pass it to the database as a value of the corresponding SQL type.
- *
- * Note that this method may be used to pass datatabase- specific abstract data types.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the object containing the input parameter value
- * @param targetSqlType
- * the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
- * @param precision
- * the precision of the column.
- * @param scale
- * the scale of the column.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see Types
- * @see #getObject
- */
- public final void setObject(String sCol,
- Object x,
+ @Override
+ public final void setObject(String parameterName,
+ Object value,
int targetSqlType,
Integer precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, x, targetSqlType, precision, scale});
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, targetSqlType, precision, scale});
checkClosed();
// scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
@@ -1905,23 +1675,25 @@ public final void setObject(String sCol,
// InputStream and Reader, this is the length of the data in the stream or reader.
// For all other types, this value will be ignored.
- setObject(setterGetParam(findColumn(sCol)), x, JavaType.of(x),
- JDBCType.of(targetSqlType), (java.sql.Types.NUMERIC == targetSqlType || java.sql.Types.DECIMAL == targetSqlType
- || InputStream.class.isInstance(x) || Reader.class.isInstance(x)) ? scale : null,
- precision, false, findColumn(sCol), null);
+ setObject(setterGetParam(findColumn(parameterName)), value, JavaType.of(value), JDBCType.of(targetSqlType),
+ (java.sql.Types.NUMERIC == targetSqlType || java.sql.Types.DECIMAL == targetSqlType || InputStream.class.isInstance(value)
+ || Reader.class.isInstance(value)) ? scale : null,
+ precision, false, findColumn(parameterName), null);
loggerExternal.exiting(getClassNameLogging(), "setObject");
}
+ @Override
public final void setAsciiStream(String parameterName,
- InputStream x) throws SQLException {
+ InputStream value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setAsciiStream", new Object[] {parameterName, x});
+ loggerExternal.entering(getClassNameLogging(), "setAsciiStream", new Object[] {parameterName, value});
checkClosed();
- setStream(findColumn(parameterName), StreamType.ASCII, x, JavaType.INPUTSTREAM, DataTypes.UNKNOWN_STREAM_LENGTH);
+ setStream(findColumn(parameterName), StreamType.ASCII, value, JavaType.INPUTSTREAM, DataTypes.UNKNOWN_STREAM_LENGTH);
loggerExternal.exiting(getClassNameLogging(), "setAsciiStream");
}
+ @Override
public final void setAsciiStream(String parameterName,
InputStream value,
int length) throws SQLException {
@@ -1932,26 +1704,29 @@ public final void setAsciiStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setAsciiStream");
}
+ @Override
public final void setAsciiStream(String parameterName,
- InputStream x,
+ InputStream value,
long length) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setAsciiStream", new Object[] {parameterName, x, length});
+ loggerExternal.entering(getClassNameLogging(), "setAsciiStream", new Object[] {parameterName, value, length});
checkClosed();
- setStream(findColumn(parameterName), StreamType.ASCII, x, JavaType.INPUTSTREAM, length);
+ setStream(findColumn(parameterName), StreamType.ASCII, value, JavaType.INPUTSTREAM, length);
loggerExternal.exiting(getClassNameLogging(), "setAsciiStream");
}
+ @Override
public final void setBinaryStream(String parameterName,
- InputStream x) throws SQLException {
+ InputStream value) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBinaryStream", new Object[] {parameterName, x});
+ loggerExternal.entering(getClassNameLogging(), "setBinaryStream", new Object[] {parameterName, value});
checkClosed();
- setStream(findColumn(parameterName), StreamType.BINARY, x, JavaType.INPUTSTREAM, DataTypes.UNKNOWN_STREAM_LENGTH);
+ setStream(findColumn(parameterName), StreamType.BINARY, value, JavaType.INPUTSTREAM, DataTypes.UNKNOWN_STREAM_LENGTH);
loggerExternal.exiting(getClassNameLogging(), "setBinaryStream");
}
+ @Override
public final void setBinaryStream(String parameterName,
InputStream value,
int length) throws SQLException {
@@ -1962,16 +1737,18 @@ public final void setBinaryStream(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setBinaryStream");
}
+ @Override
public final void setBinaryStream(String parameterName,
- InputStream x,
+ InputStream value,
long length) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBinaryStream", new Object[] {parameterName, x, length});
+ loggerExternal.entering(getClassNameLogging(), "setBinaryStream", new Object[] {parameterName, value, length});
checkClosed();
- setStream(findColumn(parameterName), StreamType.BINARY, x, JavaType.INPUTSTREAM, length);
+ setStream(findColumn(parameterName), StreamType.BINARY, value, JavaType.INPUTSTREAM, length);
loggerExternal.exiting(getClassNameLogging(), "setBinaryStream");
}
+ @Override
public final void setBlob(String parameterName,
Blob inputStream) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -1981,9 +1758,9 @@ public final void setBlob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setBlob");
}
+ @Override
public final void setBlob(String parameterName,
InputStream value) throws SQLException {
-
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "setBlob", new Object[] {parameterName, value});
checkClosed();
@@ -1991,6 +1768,7 @@ public final void setBlob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setBlob");
}
+ @Override
public final void setBlob(String parameterName,
InputStream inputStream,
long length) throws SQLException {
@@ -2001,928 +1779,525 @@ public final void setBlob(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setBlob");
}
- public void setTimestamp(String sCol,
- java.sql.Timestamp t) throws SQLServerException {
+ @Override
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIMESTAMP, t, JavaType.TIMESTAMP, false);
+ setValue(findColumn(parameterName), JDBCType.TIMESTAMP, value, JavaType.TIMESTAMP, false);
loggerExternal.exiting(getClassNameLogging(), "setTimestamp");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * the parameter value
- * @param scale
- * the scale of the parameter
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTimestamp
- */
- public void setTimestamp(String sCol,
- java.sql.Timestamp t,
+ @Override
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIMESTAMP, t, JavaType.TIMESTAMP, null, scale, false);
+ setValue(findColumn(parameterName), JDBCType.TIMESTAMP, value, JavaType.TIMESTAMP, null, scale, false);
loggerExternal.exiting(getClassNameLogging(), "setTimestamp");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * the parameter value
- * @param scale
- * the scale of the parameter
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTimestamp
- */
- public void setTimestamp(String sCol,
- java.sql.Timestamp t,
+ @Override
+ public void setTimestamp(String parameterName,
+ java.sql.Timestamp value,
int scale,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {sCol, t, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setTimestamp", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIMESTAMP, t, JavaType.TIMESTAMP, null, scale, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.TIMESTAMP, value, JavaType.TIMESTAMP, null, scale, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setTimestamp");
}
- public void setDateTimeOffset(String sCol,
- microsoft.sql.DateTimeOffset t) throws SQLException {
+ @Override
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATETIMEOFFSET, t, JavaType.DATETIMEOFFSET, false);
+ setValue(findColumn(parameterName), JDBCType.DATETIMEOFFSET, value, JavaType.DATETIMEOFFSET, false);
loggerExternal.exiting(getClassNameLogging(), "setDateTimeOffset");
}
- /**
- * Sets parameter parameterName to DateTimeOffset x
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * DateTimeOffset value
- * @param scale
- * the scale of the parameter
- * @throws SQLException
- * if an error occurs
- */
- public void setDateTimeOffset(String sCol,
- microsoft.sql.DateTimeOffset t,
- int scale) throws SQLException {
+ @Override
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value,
+ int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATETIMEOFFSET, t, JavaType.DATETIMEOFFSET, null, scale, false);
+ setValue(findColumn(parameterName), JDBCType.DATETIMEOFFSET, value, JavaType.DATETIMEOFFSET, null, scale, false);
loggerExternal.exiting(getClassNameLogging(), "setDateTimeOffset");
}
- /**
- * Sets parameter parameterName to DateTimeOffset x
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * DateTimeOffset value
- * @param scale
- * the scale of the parameter
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLException
- * if an error occurs
- */
- public void setDateTimeOffset(String sCol,
- microsoft.sql.DateTimeOffset t,
+ @Override
+ public void setDateTimeOffset(String parameterName,
+ microsoft.sql.DateTimeOffset value,
int scale,
- boolean forceEncrypt) throws SQLException {
+ boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {sCol, t, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setDateTimeOffset", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATETIMEOFFSET, t, JavaType.DATETIMEOFFSET, null, scale, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.DATETIMEOFFSET, value, JavaType.DATETIMEOFFSET, null, scale, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setDateTimeOffset");
}
- public void setDate(String sCol,
- java.sql.Date d) throws SQLServerException {
+ @Override
+ public void setDate(String parameterName,
+ java.sql.Date value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {sCol, d});
+ loggerExternal.entering(getClassNameLogging(), "setDate", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATE, d, JavaType.DATE, false);
+ setValue(findColumn(parameterName), JDBCType.DATE, value, JavaType.DATE, false);
loggerExternal.exiting(getClassNameLogging(), "setDate");
}
- public void setTime(String sCol,
- java.sql.Time t) throws SQLServerException {
+ @Override
+ public void setTime(String parameterName,
+ java.sql.Time value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIME, t, JavaType.TIME, false);
+ setValue(findColumn(parameterName), JDBCType.TIME, value, JavaType.TIME, false);
loggerExternal.exiting(getClassNameLogging(), "setTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * the parameter value
- * @param scale
- * the scale of the column
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTime
- */
- public void setTime(String sCol,
- java.sql.Time t,
+ @Override
+ public void setTime(String parameterName,
+ java.sql.Time value,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {sCol, t});
+ loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIME, t, JavaType.TIME, null, scale, false);
+ setValue(findColumn(parameterName), JDBCType.TIME, value, JavaType.TIME, null, scale, false);
loggerExternal.exiting(getClassNameLogging(), "setTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Time value. The driver converts this to an SQL TIME value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param t
- * the parameter value
- * @param scale
- * the scale of the column
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- * @see #getTime
- */
- public void setTime(String sCol,
- java.sql.Time t,
+ @Override
+ public void setTime(String parameterName,
+ java.sql.Time value,
int scale,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {sCol, t, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setTime", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TIME, t, JavaType.TIME, null, scale, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.TIME, value, JavaType.TIME, null, scale, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL DATETIME
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setDateTime(String sCol,
- java.sql.Timestamp x) throws SQLServerException {
+ @Override
+ public void setDateTime(String parameterName,
+ java.sql.Timestamp value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDateTime", new Object[] {sCol, x});
+ loggerExternal.entering(getClassNameLogging(), "setDateTime", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATETIME, x, JavaType.TIMESTAMP, false);
+ setValue(findColumn(parameterName), JDBCType.DATETIME, value, JavaType.TIMESTAMP, false);
loggerExternal.exiting(getClassNameLogging(), "setDateTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL DATETIME
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setDateTime(String sCol,
- java.sql.Timestamp x,
+ @Override
+ public void setDateTime(String parameterName,
+ java.sql.Timestamp value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDateTime", new Object[] {sCol, x, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setDateTime", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DATETIME, x, JavaType.TIMESTAMP, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.DATETIME, value, JavaType.TIMESTAMP, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setDateTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL SMALLDATETIME
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setSmallDateTime(String sCol,
- java.sql.Timestamp x) throws SQLServerException {
+ @Override
+ public void setSmallDateTime(String parameterName,
+ java.sql.Timestamp value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setSmallDateTime", new Object[] {sCol, x});
+ loggerExternal.entering(getClassNameLogging(), "setSmallDateTime", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLDATETIME, x, JavaType.TIMESTAMP, false);
+ setValue(findColumn(parameterName), JDBCType.SMALLDATETIME, value, JavaType.TIMESTAMP, false);
loggerExternal.exiting(getClassNameLogging(), "setSmallDateTime");
}
- /**
- * Sets the designated parameter to the given java.sql.Timestamp value. The driver converts this to an SQL SMALLDATETIME
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param x
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setSmallDateTime(String sCol,
- java.sql.Timestamp x,
+ @Override
+ public void setSmallDateTime(String parameterName,
+ java.sql.Timestamp value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setSmallDateTime", new Object[] {sCol, x, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setSmallDateTime", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLDATETIME, x, JavaType.TIMESTAMP, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.SMALLDATETIME, value, JavaType.TIMESTAMP, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setSmallDateTime");
}
- /**
- * Sets the designated parameter to the given String value. The driver converts this to an SQL uniqueIdentifier value
- * when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param guid
- * the parameter value
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setUniqueIdentifier(String sCol,
+ @Override
+ public void setUniqueIdentifier(String parameterName,
String guid) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setUniqueIdentifier", new Object[] {sCol, guid});
+ loggerExternal.entering(getClassNameLogging(), "setUniqueIdentifier", new Object[] {parameterName, guid});
checkClosed();
- setValue(findColumn(sCol), JDBCType.GUID, guid, JavaType.STRING, false);
+ setValue(findColumn(parameterName), JDBCType.GUID, guid, JavaType.STRING, false);
loggerExternal.exiting(getClassNameLogging(), "setUniqueIdentifier");
}
- /**
- * Sets the designated parameter to the given String value. The driver converts this to an SQL uniqueIdentifier value
- * when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param guid
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setUniqueIdentifier(String sCol,
+ @Override
+ public void setUniqueIdentifier(String parameterName,
String guid,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setUniqueIdentifier", new Object[] {sCol, guid, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setUniqueIdentifier", new Object[] {parameterName, guid, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.GUID, guid, JavaType.STRING, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.GUID, guid, JavaType.STRING, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setUniqueIdentifier");
}
- public void setBytes(String sCol,
- byte[] b) throws SQLServerException {
+ @Override
+ public void setBytes(String parameterName,
+ byte[] value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBytes", new Object[] {sCol, b});
+ loggerExternal.entering(getClassNameLogging(), "setBytes", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BINARY, b, JavaType.BYTEARRAY, false);
+ setValue(findColumn(parameterName), JDBCType.BINARY, value, JavaType.BYTEARRAY, false);
loggerExternal.exiting(getClassNameLogging(), "setBytes");
}
- /**
- * Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or
- * LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it
- * to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param b
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setBytes(String sCol,
- byte[] b,
+ @Override
+ public void setBytes(String parameterName,
+ byte[] value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBytes", new Object[] {sCol, b, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setBytes", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BINARY, b, JavaType.BYTEARRAY, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.BINARY, value, JavaType.BYTEARRAY, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setBytes");
}
- public void setByte(String sCol,
- byte b) throws SQLServerException {
+ @Override
+ public void setByte(String parameterName,
+ byte value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setByte", new Object[] {sCol, b});
+ loggerExternal.entering(getClassNameLogging(), "setByte", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TINYINT, b, JavaType.BYTE, false);
+ setValue(findColumn(parameterName), JDBCType.TINYINT, value, JavaType.BYTE, false);
loggerExternal.exiting(getClassNameLogging(), "setByte");
}
- /**
- * Sets the designated parameter to the given Java byte value. The driver converts this to an SQL TINYINT value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param b
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setByte(String sCol,
- byte b,
+ @Override
+ public void setByte(String parameterName,
+ byte value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setByte", new Object[] {sCol, b, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setByte", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TINYINT, b, JavaType.BYTE, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.TINYINT, value, JavaType.BYTE, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setByte");
}
- public void setString(String sCol,
- String s) throws SQLServerException {
+ @Override
+ public void setString(String parameterName,
+ String value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setString", new Object[] {sCol, s});
+ loggerExternal.entering(getClassNameLogging(), "setString", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.VARCHAR, s, JavaType.STRING, false);
+ setValue(findColumn(parameterName), JDBCType.VARCHAR, value, JavaType.STRING, false);
loggerExternal.exiting(getClassNameLogging(), "setString");
}
- /**
- * Sets the designated parameter to the given Java String value. The driver converts this to an SQL VARCHAR or
- * LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends
- * it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param s
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setString(String sCol,
- String s,
+ @Override
+ public void setString(String parameterName,
+ String value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setString", new Object[] {sCol, s, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setString", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.VARCHAR, s, JavaType.STRING, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.VARCHAR, value, JavaType.STRING, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setString");
}
- /**
- * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL Money
- * value.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setMoney(String sCol,
- BigDecimal bd) throws SQLServerException {
+ @Override
+ public void setMoney(String parameterName,
+ BigDecimal value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setMoney", new Object[] {sCol, bd});
+ loggerExternal.entering(getClassNameLogging(), "setMoney", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.MONEY, bd, JavaType.BIGDECIMAL, false);
+ setValue(findColumn(parameterName), JDBCType.MONEY, value, JavaType.BIGDECIMAL, false);
loggerExternal.exiting(getClassNameLogging(), "setMoney");
}
- /**
- * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL Money
- * value.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setMoney(String sCol,
- BigDecimal bd,
+ @Override
+ public void setMoney(String parameterName,
+ BigDecimal value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setMoney", new Object[] {sCol, bd, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setMoney", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.MONEY, bd, JavaType.BIGDECIMAL, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.MONEY, value, JavaType.BIGDECIMAL, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setMoney");
}
- /**
- * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL
- * smallMoney value.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setSmallMoney(String sCol,
- BigDecimal bd) throws SQLServerException {
+ @Override
+ public void setSmallMoney(String parameterName,
+ BigDecimal value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setSmallMoney", new Object[] {sCol, bd});
+ loggerExternal.entering(getClassNameLogging(), "setSmallMoney", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLMONEY, bd, JavaType.BIGDECIMAL, false);
+ setValue(findColumn(parameterName), JDBCType.SMALLMONEY, value, JavaType.BIGDECIMAL, false);
loggerExternal.exiting(getClassNameLogging(), "setSmallMoney");
}
- /**
- * Sets the designated parameter to the given Java java.math.BigDecimal value. The driver converts this to an SQL
- * smallMoney value.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setSmallMoney(String sCol,
- BigDecimal bd,
+ @Override
+ public void setSmallMoney(String parameterName,
+ BigDecimal value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setSmallMoney", new Object[] {sCol, bd, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setSmallMoney", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLMONEY, bd, JavaType.BIGDECIMAL, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.SMALLMONEY, value, JavaType.BIGDECIMAL, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setSmallMoney");
}
- public void setBigDecimal(String sCol,
- BigDecimal bd) throws SQLServerException {
+ @Override
+ public void setBigDecimal(String parameterName,
+ BigDecimal value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {sCol, bd});
+ loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DECIMAL, bd, JavaType.BIGDECIMAL, false);
+ setValue(findColumn(parameterName), JDBCType.DECIMAL, value, JavaType.BIGDECIMAL, false);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
- /**
- * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @param precision
- * the precision of the column
- * @param scale
- * the scale of the column
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setBigDecimal(String sCol,
- BigDecimal bd,
+ @Override
+ public void setBigDecimal(String parameterName,
+ BigDecimal value,
int precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {sCol, bd, precision, scale});
+ loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {parameterName, value, precision, scale});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DECIMAL, bd, JavaType.BIGDECIMAL, precision, scale, false);
+ setValue(findColumn(parameterName), JDBCType.DECIMAL, value, JavaType.BIGDECIMAL, precision, scale, false);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
- /**
- * Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC
- * value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param bd
- * the parameter value
- * @param precision
- * the precision of the column
- * @param scale
- * the scale of the column
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setBigDecimal(String sCol,
- BigDecimal bd,
+ @Override
+ public void setBigDecimal(String parameterName,
+ BigDecimal value,
int precision,
int scale,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {sCol, bd, precision, scale, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setBigDecimal", new Object[] {parameterName, value, precision, scale, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DECIMAL, bd, JavaType.BIGDECIMAL, precision, scale, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.DECIMAL, value, JavaType.BIGDECIMAL, precision, scale, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setBigDecimal");
}
- public void setDouble(String sCol,
- double d) throws SQLServerException {
+ @Override
+ public void setDouble(String parameterName,
+ double value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDouble", new Object[] {sCol, d});
+ loggerExternal.entering(getClassNameLogging(), "setDouble", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DOUBLE, d, JavaType.DOUBLE, false);
+ setValue(findColumn(parameterName), JDBCType.DOUBLE, value, JavaType.DOUBLE, false);
loggerExternal.exiting(getClassNameLogging(), "setDouble");
}
- /**
- * Sets the designated parameter to the given Java double value. The driver converts this to an SQL DOUBLE value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param d
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setDouble(String sCol,
- double d,
+ @Override
+ public void setDouble(String parameterName,
+ double value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setDouble", new Object[] {sCol, d, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setDouble", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.DOUBLE, d, JavaType.DOUBLE, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.DOUBLE, value, JavaType.DOUBLE, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setDouble");
}
- public void setFloat(String sCol,
- float f) throws SQLServerException {
+ @Override
+ public void setFloat(String parameterName,
+ float value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setFloat", new Object[] {sCol, f});
+ loggerExternal.entering(getClassNameLogging(), "setFloat", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.REAL, f, JavaType.FLOAT, false);
+ setValue(findColumn(parameterName), JDBCType.REAL, value, JavaType.FLOAT, false);
loggerExternal.exiting(getClassNameLogging(), "setFloat");
}
- /**
- * Sets the designated parameter to the given Java float value. The driver converts this to an SQL FLOAT value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param f
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setFloat(String sCol,
- float f,
+ @Override
+ public void setFloat(String parameterName,
+ float value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setFloat", new Object[] {sCol, f, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setFloat", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.REAL, f, JavaType.FLOAT, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.REAL, value, JavaType.FLOAT, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setFloat");
}
- public void setInt(String sCol,
- int i) throws SQLServerException {
+ @Override
+ public void setInt(String parameterName,
+ int value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setInt", new Object[] {sCol, i});
+ loggerExternal.entering(getClassNameLogging(), "setInt", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.INTEGER, i, JavaType.INTEGER, false);
+ setValue(findColumn(parameterName), JDBCType.INTEGER, value, JavaType.INTEGER, false);
loggerExternal.exiting(getClassNameLogging(), "setInt");
}
- /**
- * Sets the designated parameter to the given Java int value. The driver converts this to an SQL INTEGER value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param i
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setInt(String sCol,
- int i,
+ @Override
+ public void setInt(String parameterName,
+ int value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setInt", new Object[] {sCol, i, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setInt", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.INTEGER, i, JavaType.INTEGER, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.INTEGER, value, JavaType.INTEGER, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setInt");
}
- public void setLong(String sCol,
- long l) throws SQLServerException {
+ @Override
+ public void setLong(String parameterName,
+ long value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setLong", new Object[] {sCol, l});
+ loggerExternal.entering(getClassNameLogging(), "setLong", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BIGINT, l, JavaType.LONG, false);
+ setValue(findColumn(parameterName), JDBCType.BIGINT, value, JavaType.LONG, false);
loggerExternal.exiting(getClassNameLogging(), "setLong");
}
- /**
- * Sets the designated parameter to the given Java long value. The driver converts this to an SQL BIGINT value when it
- * sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param l
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setLong(String sCol,
- long l,
+ @Override
+ public void setLong(String parameterName,
+ long value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setLong", new Object[] {sCol, l, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setLong", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BIGINT, l, JavaType.LONG, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.BIGINT, value, JavaType.LONG, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setLong");
}
- public void setShort(String sCol,
- short s) throws SQLServerException {
+ @Override
+ public void setShort(String parameterName,
+ short value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setShort", new Object[] {sCol, s});
+ loggerExternal.entering(getClassNameLogging(), "setShort", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLINT, s, JavaType.SHORT, false);
+ setValue(findColumn(parameterName), JDBCType.SMALLINT, value, JavaType.SHORT, false);
loggerExternal.exiting(getClassNameLogging(), "setShort");
}
- /**
- * Sets the designated parameter to the given Java short value. The driver converts this to an SQL SMALLINT value when
- * it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param s
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setShort(String sCol,
- short s,
+ @Override
+ public void setShort(String parameterName,
+ short value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setShort", new Object[] {sCol, s, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setShort", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.SMALLINT, s, JavaType.SHORT, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.SMALLINT, value, JavaType.SHORT, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setShort");
}
- public void setBoolean(String sCol,
- boolean b) throws SQLServerException {
+ @Override
+ public void setBoolean(String parameterName,
+ boolean value) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBoolean", new Object[] {sCol, b});
+ loggerExternal.entering(getClassNameLogging(), "setBoolean", new Object[] {parameterName, value});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BIT, b, JavaType.BOOLEAN, false);
+ setValue(findColumn(parameterName), JDBCType.BIT, value, JavaType.BOOLEAN, false);
loggerExternal.exiting(getClassNameLogging(), "setBoolean");
}
- /**
- * Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT or
- * BOOLEAN value when it sends it to the database.
- *
- * @param sCol
- * the name of the parameter
- * @param b
- * the parameter value
- * @param forceEncrypt
- * If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always
- * Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force
- * encryption on parameters.
- * @throws SQLServerException
- * if parameterName does not correspond to a named parameter; if a database access error occurs or this method is called on a closed
- * CallableStatement
- */
- public void setBoolean(String sCol,
- boolean b,
+ @Override
+ public void setBoolean(String parameterName,
+ boolean value,
boolean forceEncrypt) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setBoolean", new Object[] {sCol, b, forceEncrypt});
+ loggerExternal.entering(getClassNameLogging(), "setBoolean", new Object[] {parameterName, value, forceEncrypt});
checkClosed();
- setValue(findColumn(sCol), JDBCType.BIT, b, JavaType.BOOLEAN, forceEncrypt);
+ setValue(findColumn(parameterName), JDBCType.BIT, value, JavaType.BOOLEAN, forceEncrypt);
loggerExternal.exiting(getClassNameLogging(), "setBoolean");
}
- public void setNull(String sCol,
+ @Override
+ public void setNull(String parameterName,
int nType) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setNull", new Object[] {sCol, nType});
+ loggerExternal.entering(getClassNameLogging(), "setNull", new Object[] {parameterName, nType});
checkClosed();
- setObject(setterGetParam(findColumn(sCol)), null, JavaType.OBJECT, JDBCType.of(nType), null, null, false, findColumn(sCol), null);
+ setObject(setterGetParam(findColumn(parameterName)), null, JavaType.OBJECT, JDBCType.of(nType), null, null, false, findColumn(parameterName),
+ null);
loggerExternal.exiting(getClassNameLogging(), "setNull");
}
- public void setNull(String sCol,
+ @Override
+ public void setNull(String parameterName,
int nType,
String sTypeName) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setNull", new Object[] {sCol, nType, sTypeName});
+ loggerExternal.entering(getClassNameLogging(), "setNull", new Object[] {parameterName, nType, sTypeName});
checkClosed();
- setObject(setterGetParam(findColumn(sCol)), null, JavaType.OBJECT, JDBCType.of(nType), null, null, false, findColumn(sCol), sTypeName);
+ setObject(setterGetParam(findColumn(parameterName)), null, JavaType.OBJECT, JDBCType.of(nType), null, null, false, findColumn(parameterName),
+ sTypeName);
loggerExternal.exiting(getClassNameLogging(), "setNull");
}
- public void setURL(String sCol,
- URL u) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "setURL", sCol);
+ @Override
+ public void setURL(String parameterName,
+ URL url) throws SQLException {
+ loggerExternal.entering(getClassNameLogging(), "setURL", parameterName);
checkClosed();
- setURL(findColumn(sCol), u);
+ setURL(findColumn(parameterName), url);
loggerExternal.exiting(getClassNameLogging(), "setURL");
}
- /**
- * Populates a table valued parameter passed to a stored procedure with a data table.
- *
- * @param sCol
- * the name of the parameter
- * @param tvpName
- * the name of the type TVP
- * @param tvpDataTable
- * the data table object
- * @throws SQLServerException
- * when an error occurs
- */
- public final void setStructured(String sCol,
+ @Override
+ public final void setStructured(String parameterName,
String tvpName,
SQLServerDataTable tvpDataTable) throws SQLServerException {
- tvpName = getTVPNameIfNull(findColumn(sCol), tvpName);
+ tvpName = getTVPNameIfNull(findColumn(parameterName), tvpName);
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {sCol, tvpName, tvpDataTable});
+ loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {parameterName, tvpName, tvpDataTable});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TVP, tvpDataTable, JavaType.TVP, tvpName);
+ setValue(findColumn(parameterName), JDBCType.TVP, tvpDataTable, JavaType.TVP, tvpName);
loggerExternal.exiting(getClassNameLogging(), "setStructured");
}
- /**
- * Populates a table valued parameter passed to a stored procedure with a ResultSet retrieved from another table
- *
- * @param sCol
- * the name of the parameter
- * @param tvpName
- * the name of the type TVP
- * @param tvpResultSet
- * the source result set object
- * @throws SQLServerException
- * when an error occurs
- */
- public final void setStructured(String sCol,
+ @Override
+ public final void setStructured(String parameterName,
String tvpName,
ResultSet tvpResultSet) throws SQLServerException {
- tvpName = getTVPNameIfNull(findColumn(sCol), tvpName);
+ tvpName = getTVPNameIfNull(findColumn(parameterName), tvpName);
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {sCol, tvpName, tvpResultSet});
+ loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {parameterName, tvpName, tvpResultSet});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TVP, tvpResultSet, JavaType.TVP, tvpName);
+ setValue(findColumn(parameterName), JDBCType.TVP, tvpResultSet, JavaType.TVP, tvpName);
loggerExternal.exiting(getClassNameLogging(), "setStructured");
}
- /**
- * Populates a table valued parameter passed to a stored procedure with an ISQLServerDataRecord object.
- *
- * @param sCol
- * the name of the parameter
- * @param tvpName
- * the name of the type TVP
- * @param tvpDataRecord
- * ISQLServerDataRecord is used for streaming data and the user decides how to use it. tvpDataRecord is an ISQLServerDataRecord
- * object.the source result set object
- * @throws SQLServerException
- * when an error occurs
- */
- public final void setStructured(String sCol,
+ @Override
+ public final void setStructured(String parameterName,
String tvpName,
ISQLServerDataRecord tvpDataRecord) throws SQLServerException {
- tvpName = getTVPNameIfNull(findColumn(sCol), tvpName);
+ tvpName = getTVPNameIfNull(findColumn(parameterName), tvpName);
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {sCol, tvpName, tvpDataRecord});
+ loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[] {parameterName, tvpName, tvpDataRecord});
checkClosed();
- setValue(findColumn(sCol), JDBCType.TVP, tvpDataRecord, JavaType.TVP, tvpName);
+ setValue(findColumn(parameterName), JDBCType.TVP, tvpDataRecord, JavaType.TVP, tvpName);
loggerExternal.exiting(getClassNameLogging(), "setStructured");
}
- public URL getURL(int n) throws SQLServerException {
- NotImplemented();
+ @Override
+ public URL getURL(int parameterIndex) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
return null;
}
- public URL getURL(String s) throws SQLServerException {
- NotImplemented();
+ @Override
+ public URL getURL(String parameterName) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
return null;
}
+ @Override
public final void setSQLXML(String parameterName,
SQLXML xmlObject) throws SQLException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -2932,6 +2307,7 @@ public final void setSQLXML(String parameterName,
loggerExternal.exiting(getClassNameLogging(), "setSQLXML");
}
+ @Override
public final SQLXML getSQLXML(int parameterIndex) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getSQLXML", parameterIndex);
checkClosed();
@@ -2940,6 +2316,7 @@ public final SQLXML getSQLXML(int parameterIndex) throws SQLException {
return value;
}
+ @Override
public final SQLXML getSQLXML(String parameterName) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getSQLXML", parameterName);
checkClosed();
@@ -2948,65 +2325,211 @@ public final SQLXML getSQLXML(String parameterName) throws SQLException {
return value;
}
+ @Override
public final void setRowId(String parameterName,
- RowId x) throws SQLException {
-
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ RowId value) throws SQLException {
+ SQLServerException.throwNotSupportedException(connection, this);
}
+ @Override
public final RowId getRowId(int parameterIndex) throws SQLException {
-
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwNotSupportedException(connection, this);
+ return null;
}
+ @Override
public final RowId getRowId(String parameterName) throws SQLException {
-
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwNotSupportedException(connection, this);
+ return null;
}
- public void registerOutParameter(String s,
- int n,
- String s1) throws SQLServerException {
+ @Override
+ public void registerOutParameter(String parameterName,
+ int sqlType,
+ String typeName) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {s, n, s1});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, typeName});
checkClosed();
- registerOutParameter(findColumn(s), n, s1);
+ registerOutParameter(findColumn(parameterName), sqlType, typeName);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
+ @Override
public void registerOutParameter(String parameterName,
int sqlType,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {parameterName, sqlType, scale});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
checkClosed();
registerOutParameter(findColumn(parameterName), sqlType, scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
+ @Override
public void registerOutParameter(String parameterName,
int sqlType,
int precision,
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
- new Object[] {parameterName, sqlType, scale});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
checkClosed();
registerOutParameter(findColumn(parameterName), sqlType, precision, scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
- public void registerOutParameter(String s,
- int n) throws SQLServerException {
+ @Override
+ public void registerOutParameter(String parameterName,
+ int sqlType) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {s, n});
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType});
checkClosed();
- registerOutParameter(findColumn(s), n);
+ registerOutParameter(findColumn(parameterName), sqlType);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(int paramterIndex,
+ SQLType sqlType) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {paramterIndex, sqlType});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber());
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(int paramterIndex,
+ SQLType sqlType,
+ String typeName) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {paramterIndex, sqlType, typeName});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), typeName);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(int paramterIndex,
+ SQLType sqlType,
+ int scale) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {paramterIndex, sqlType, scale});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), scale);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(int paramterIndex,
+ 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});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(paramterIndex, sqlType.getVendorTypeNumber(), precision, scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ SQLType jdbcType) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, jdbcType});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ setObject(parameterName, value, jdbcType.getVendorTypeNumber());
+ loggerExternal.exiting(getClassNameLogging(), "setObject");
+ }
+
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ SQLType jdbcType,
+ int scale) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, jdbcType, scale});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ setObject(parameterName, value, jdbcType.getVendorTypeNumber(), scale);
+ loggerExternal.exiting(getClassNameLogging(), "setObject");
+ }
+
+ @Override
+ public void setObject(String parameterName,
+ Object value,
+ SQLType jdbcType,
+ int scale,
+ boolean forceEncrypt) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {parameterName, value, jdbcType, scale, forceEncrypt});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ setObject(parameterName, value, jdbcType.getVendorTypeNumber(), scale, forceEncrypt);
+ loggerExternal.exiting(getClassNameLogging(), "setObject");
+ }
+
+ @Override
+ public void registerOutParameter(String parameterName,
+ SQLType sqlType,
+ String typeName) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, typeName});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), typeName);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(String parameterName,
+ SQLType sqlType,
+ int scale) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), scale);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(String parameterName,
+ SQLType sqlType,
+ int precision,
+ int scale) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), precision, scale);
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
+
+ @Override
+ public void registerOutParameter(String parameterName,
+ SQLType sqlType) throws SQLServerException {
+
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType});
+
+ // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
+ registerOutParameter(parameterName, sqlType.getVendorTypeNumber());
+ loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
+ }
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java
deleted file mode 100644
index cf5e1f2460..0000000000
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.SQLType;
-
-/**
- *
- * This class is separated from SQLServerCallableStatement class in order to resolve compiling error of missing Java 8 Types when running with Java 7.
- *
- * This class will be initialized instead of SQLServerCallableStatement when Java 8 and JDBC 4.2 are used.
- *
- * It shares the same PreparedStatement implementation with SQLServerPreparedStatement42.
- *
- */
-public class SQLServerCallableStatement42 extends SQLServerCallableStatement implements ISQLServerCallableStatement42 {
-
- SQLServerCallableStatement42(SQLServerConnection connection,
- String sql,
- int nRSType,
- int nRSConcur,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- super(connection, sql, nRSType, nRSConcur, stmtColEncSetting);
- }
-
- public void registerOutParameter(int index,
- SQLType sqlType) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(index, sqlType.getVendorTypeNumber());
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(int index,
- SQLType sqlType,
- String typeName) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType, typeName});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(index, sqlType.getVendorTypeNumber(), typeName);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(int index,
- SQLType sqlType,
- int scale) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType, scale});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(index, sqlType.getVendorTypeNumber(), scale);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(int index,
- SQLType sqlType,
- int precision,
- int scale) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType, scale});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(index, sqlType.getVendorTypeNumber(), precision, scale);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, obj, jdbcType});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- setObject(sCol, obj, jdbcType.getVendorTypeNumber());
-
- loggerExternal.exiting(getClassNameLogging(), "setObject");
- }
-
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType,
- int scale) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, obj, jdbcType, scale});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- setObject(sCol, obj, jdbcType.getVendorTypeNumber(), scale);
-
- loggerExternal.exiting(getClassNameLogging(), "setObject");
- }
-
- public void setObject(String sCol,
- Object obj,
- SQLType jdbcType,
- int scale,
- boolean forceEncrypt) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "setObject", new Object[] {sCol, obj, jdbcType, scale, forceEncrypt});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- setObject(sCol, obj, jdbcType.getVendorTypeNumber(), scale, forceEncrypt);
-
- loggerExternal.exiting(getClassNameLogging(), "setObject");
- }
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- String typeName) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, typeName});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), typeName);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- int scale) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), scale);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType,
- int precision,
- int scale) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType, scale});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), precision, scale);
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public void registerOutParameter(String parameterName,
- SQLType sqlType) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC42();
-
- if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {parameterName, sqlType});
-
- // getVendorTypeNumber() returns the same constant integer values as in java.sql.Types
- registerOutParameter(parameterName, sqlType.getVendorTypeNumber());
-
- loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
- }
-
- public final void setObject(int index,
- Object obj,
- SQLType jdbcType) throws SQLServerException {
- SQLServerPreparedStatement42Helper.setObject(this, index, obj, jdbcType);
- }
-
- public final void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- int scaleOrLength) throws SQLServerException {
- SQLServerPreparedStatement42Helper.setObject(this, parameterIndex, x, targetSqlType, scaleOrLength);
- }
-
- public final void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- Integer precision,
- Integer scale) throws SQLServerException {
- SQLServerPreparedStatement42Helper.setObject(this, parameterIndex, x, targetSqlType, precision, scale);
- }
-
- public final void setObject(int parameterIndex,
- Object x,
- SQLType targetSqlType,
- Integer precision,
- Integer scale,
- boolean forceEncrypt) throws SQLServerException {
- SQLServerPreparedStatement42Helper.setObject(this, parameterIndex, x, targetSqlType, precision, scale, forceEncrypt);
- }
-
-}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
index ebf23c1f56..31b8d08376 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
@@ -8,17 +8,21 @@
package com.microsoft.sqlserver.jdbc;
+import static java.nio.charset.StandardCharsets.UTF_16LE;
import static java.nio.charset.StandardCharsets.US_ASCII;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
+import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
@@ -33,9 +37,13 @@
*/
public class SQLServerClob extends SQLServerClobBase implements Clob {
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
private static final long serialVersionUID = 2872035282200133865L;
-
- // Loggers should be class static to avoid lock contention with multiple threads
+
+ // Loggers should be class static to avoid lock contention with multiple
+ // threads
private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerClob");
/**
@@ -65,12 +73,94 @@ public SQLServerClob(SQLServerConnection connection,
super(null, stream, typeInfo.getSQLCollation(), logger, typeInfo);
}
+ @Override
+ public void free() throws SQLException {
+ super.free();
+ }
+
+ @Override
+ public InputStream getAsciiStream() throws SQLException {
+ return super.getAsciiStream();
+ }
+
+ @Override
+ public Reader getCharacterStream() throws SQLException {
+ return super.getCharacterStream();
+ }
+
+ @Override
+ public Reader getCharacterStream(long pos,
+ long length) throws SQLException {
+ return super.getCharacterStream(pos, length);
+ }
+
+ @Override
+ public String getSubString(long pos,
+ int length) throws SQLException {
+ return super.getSubString(pos, length);
+ }
+
+ @Override
+ public long length() throws SQLException {
+ return super.length();
+ }
+
+ @Override
+ void fillFromStream() throws SQLException {
+ super.fillFromStream();
+ }
+
+ @Override
+ public long position(Clob searchstr,
+ long start) throws SQLException {
+ return super.position(searchstr, start);
+ }
+
+ @Override
+ public long position(String searchstr,
+ long start) throws SQLException {
+ return super.position(searchstr, start);
+ }
+
+ @Override
+ public void truncate(long len) throws SQLException {
+ super.truncate(len);
+ }
+
+ @Override
+ public OutputStream setAsciiStream(long pos) throws SQLException {
+ return super.setAsciiStream(pos);
+ }
+
+ @Override
+ public Writer setCharacterStream(long pos) throws SQLException {
+ return super.setCharacterStream(pos);
+ }
+
+ @Override
+ public int setString(long pos,
+ String s) throws SQLException {
+ return super.setString(pos, s);
+ }
+
+ @Override
+ public int setString(long pos,
+ String str,
+ int offset,
+ int len) throws SQLException {
+ return super.setString(pos, str, offset, len);
+ }
+
+ @Override
final JDBCType getJdbcType() {
return JDBCType.CLOB;
}
}
-abstract class SQLServerClobBase implements Serializable {
+abstract class SQLServerClobBase extends SQLServerLob implements Serializable {
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
private static final long serialVersionUID = 8691072211054430124L;
// The value of the CLOB that this Clob object represents.
@@ -80,27 +170,31 @@ abstract class SQLServerClobBase implements Serializable {
private final SQLCollation sqlCollation;
private boolean isClosed = false;
-
+
private final TypeInfo typeInfo;
// Active streams which must be closed when the Clob/NClob is closed
//
- // Initial size of the array is based on an assumption that a Clob/NClob object is
- // typically used either for input or output, and then only once. The array size
+ // Initial size of the array is based on an assumption that a Clob/NClob
+ // object is
+ // typically used either for input or output, and then only once. The array
+ // size
// grows automatically if multiple streams are used.
private ArrayList activeStreams = new ArrayList<>(1);
transient SQLServerConnection con;
-
+
private final Logger logger;
-
+
final private String traceID = getClass().getName().substring(1 + getClass().getName().lastIndexOf('.')) + ":" + nextInstanceID();
final public String toString() {
return traceID;
}
- static private final AtomicInteger baseID = new AtomicInteger(0); // Unique id generator for each instance (used for logging).
+ // Unique id generator for each instance (used for logging).
+ static private final AtomicInteger baseID = new AtomicInteger(0);
+
// Returns unique id for each instance.
private static int nextInstanceID() {
@@ -160,7 +254,8 @@ private String getDisplayClassName() {
*/
public void free() throws SQLException {
if (!isClosed) {
- // Close active streams, ignoring any errors, since nothing can be done with them after that point anyway.
+ // Close active streams, ignoring any errors, since nothing can be
+ // done with them after that point anyway.
if (null != activeStreams) {
for (Closeable stream : activeStreams) {
try {
@@ -203,24 +298,9 @@ public InputStream getAsciiStream() throws SQLException {
if (null != sqlCollation && !sqlCollation.supportsAsciiConversion())
DataTypes.throwConversionError(getDisplayClassName(), "AsciiStream");
- // Need to use a BufferedInputStream since the stream returned by this method is assumed to support mark/reset
- InputStream getterStream;
- if (null == value && !activeStreams.isEmpty()) {
- InputStream inputStream = (InputStream) activeStreams.get(0);
- try {
- inputStream.reset();
- getterStream = new BufferedInputStream(
- new ReaderInputStream(new InputStreamReader(inputStream), US_ASCII, inputStream.available()));
- }
- catch (IOException e) {
- throw new SQLServerException(e.getMessage(), null, 0, e);
- }
- }
- else {
- getStringFromStream();
- getterStream = new BufferedInputStream(new ReaderInputStream(new StringReader(value), US_ASCII, value.length()));
-
- }
+ getStringFromStream();
+ InputStream getterStream = new BufferedInputStream(new ReaderInputStream(new StringReader(value), US_ASCII, value.length()));
+ activeStreams.add(getterStream);
return getterStream;
}
@@ -234,9 +314,15 @@ public InputStream getAsciiStream() throws SQLException {
public Reader getCharacterStream() throws SQLException {
checkClosed();
- getStringFromStream();
- Reader getterStream = new StringReader(value);
- activeStreams.add(getterStream);
+ Reader getterStream = null;
+ if (null == value && !activeStreams.isEmpty()) {
+ InputStream inputStream = (InputStream) activeStreams.get(0);
+ getterStream = new BufferedReader(new InputStreamReader(inputStream, UTF_16LE));
+ }
+ else {
+ getterStream = new StringReader(value);
+ activeStreams.add(getterStream);
+ }
return getterStream;
}
@@ -253,8 +339,8 @@ public Reader getCharacterStream() throws SQLException {
*/
public Reader getCharacterStream(long pos,
long length) throws SQLException {
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwFeatureNotSupportedException();
+ return null;
}
/**
@@ -293,12 +379,14 @@ public String getSubString(long pos,
if (pos > value.length())
pos = value.length();
- // Bound the requested length to no larger than the remainder of the value beyond pos so that the
+ // Bound the requested length to no larger than the remainder of the
+ // value beyond pos so that the
// endIndex computed for the substring call below is within bounds.
if (length > value.length() - pos)
length = (int) (value.length() - pos);
- // Note String.substring uses beginIndex and endIndex (not pos and length), so calculate endIndex.
+ // Note String.substring uses beginIndex and endIndex (not pos and
+ // length), so calculate endIndex.
return value.substring((int) pos, (int) pos + length);
}
@@ -312,12 +400,26 @@ public String getSubString(long pos,
public long length() throws SQLException {
checkClosed();
- getStringFromStream();
+ if (value == null && activeStreams.get(0) instanceof PLPInputStream) {
+ return (long) ((PLPInputStream) activeStreams.get(0)).payloadLength / 2;
+ }
return value.length();
}
-
+
+ /**
+ * Function for the result set to maintain clobs it has created
+ *
+ * @throws SQLException
+ */
+ void fillFromStream() throws SQLException {
+ if (!isClosed) {
+ getStringFromStream();
+ }
+ }
+
/**
* Converts the stream to String
+ *
* @throws SQLServerException
*/
private void getStringFromStream() throws SQLServerException {
@@ -384,7 +486,8 @@ public long position(String searchstr,
SQLServerException.makeFromDriverError(con, null, form.format(msgArgs), null, true);
}
- // Back compat: Handle null search string as not found rather than throw an exception.
+ // Back compat: Handle null search string as not found rather than throw
+ // an exception.
// JDBC spec doesn't describe the behavior for a null search string.
if (null == searchstr)
return -1;
@@ -527,7 +630,8 @@ public int setString(long pos,
}
// Note position for Clob.setString is 1 based not zero based.
- // Position must be in range of existing Clob data or exactly 1 character
+ // Position must be in range of existing Clob data or exactly 1
+ // character
// past the end of data to request "append" mode.
if (pos < 1 || pos > value.length() + 1) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPositionIndex"));
@@ -540,7 +644,8 @@ public int setString(long pos,
// Overwrite past end of value case.
if (len >= value.length() - pos) {
- // Make sure the new value length wouldn't exceed the maximum allowed
+ // Make sure the new value length wouldn't exceed the maximum
+ // allowed
DataTypes.getCheckedLength(con, getJdbcType(), pos + len, false);
assert pos + len <= Integer.MAX_VALUE;
@@ -576,11 +681,14 @@ public int setString(long pos,
}
}
-// SQLServerClobWriter is a simple java.io.Writer interface implementing class that
-// forwards all calls to SQLServerClob.setString. This class is returned to caller by
+// SQLServerClobWriter is a simple java.io.Writer interface implementing class
+// that
+// forwards all calls to SQLServerClob.setString. This class is returned to
+// caller by
// SQLServerClob class when setCharacterStream is called.
//
-// SQLServerClobWriter starts writing at postion streamPos and continues to write
+// SQLServerClobWriter starts writing at postion streamPos and continues to
+// write
// in a forward only manner. There is no reset with java.io.Writer.
//
final class SQLServerClobWriter extends java.io.Writer {
@@ -650,11 +758,14 @@ private void checkClosed() throws IOException {
}
}
-// SQLServerClobAsciiOutputStream is a simple java.io.OutputStream interface implementing class that
-// forwards all calls to SQLServerClob.setString. This class is returned to caller by
+// SQLServerClobAsciiOutputStream is a simple java.io.OutputStream interface
+// implementing class that
+// forwards all calls to SQLServerClob.setString. This class is returned to
+// caller by
// SQLServerClob class when setAsciiStream is called.
//
-// SQLServerClobAsciiOutputStream starts writing at character postion streamPos and continues to write
+// SQLServerClobAsciiOutputStream starts writing at character postion streamPos
+// and continues to write
// in a forward only manner. Reset/mark are not supported.
//
final class SQLServerClobAsciiOutputStream extends java.io.OutputStream {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
index c6e168a855..201f13c7be 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
@@ -18,19 +18,26 @@
import java.security.NoSuchAlgorithmException;
import java.text.MessageFormat;
import java.util.Locale;
+import java.util.concurrent.ExecutorService;
+import com.microsoft.azure.AzureResponseBuilder;
import com.microsoft.azure.keyvault.KeyVaultClient;
import com.microsoft.azure.keyvault.models.KeyBundle;
import com.microsoft.azure.keyvault.models.KeyOperationResult;
import com.microsoft.azure.keyvault.models.KeyVerifyResult;
import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm;
import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm;
+import com.microsoft.azure.serializer.AzureJacksonAdapter;
+import com.microsoft.rest.RestClient;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
/**
* Provides implementation similar to certificate store provider. A CEK encrypted with certificate store provider should be decryptable by this
* provider and vice versa.
*
- * Envolope Format for the encrypted column encryption key version + keyPathLength + ciphertextLength + keyPath + ciphertext + signature version: A
+ * Envelope Format for the encrypted column encryption key version + keyPathLength + ciphertextLength + keyPath + ciphertext + signature version: A
* single byte indicating the format version. keyPathLength: Length of the keyPath. ciphertextLength: ciphertext length keyPath: keyPath used to
* encrypt the column encryption key. This is only used for troubleshooting purposes and is not verified during decryption. ciphertext: Encrypted
* column encryption key signature: Signature of the entire byte array. Signature is validated before decrypting the column encryption key.
@@ -42,6 +49,8 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
*/
String name = "AZURE_KEY_VAULT";
+ private final String baseUrl = "https://{vaultBaseUrl}";
+
private final String azureKeyVaultDomainName = "vault.azure.net";
private final String rsaEncryptionAlgorithmWithOAEPForAKV = "RSA-OAEP";
@@ -53,7 +62,7 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
private KeyVaultClient keyVaultClient;
- private KeyVaultCredential credential;
+ private KeyVaultCredential credentials;
public void setName(String name) {
this.name = name;
@@ -64,20 +73,60 @@ public String getName() {
}
/**
- * Constructor that authenticates to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key
+ * Constructor that takes a callback function to authenticate to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key
+ * Vault.
+ *
+ * This constructor is present to maintain backwards compatibility with 6.0 version of the driver. Deprecated for removal in next stable release.
+ *
+ * @param authenticationCallback
+ * - Callback function used for authenticating to AAD.
+ * @param executorService
+ * - The ExecutorService, previously used to create the keyVaultClient, but not in use anymore. - This parameter can be passed as 'null'
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ @Deprecated
+ public SQLServerColumnEncryptionAzureKeyVaultProvider(SQLServerKeyVaultAuthenticationCallback authenticationCallback,
+ ExecutorService executorService) throws SQLServerException {
+ this(authenticationCallback);
+ }
+
+ /**
+ * Constructor that takes a callback function to authenticate to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key
* Vault.
*
+ * @param authenticationCallback
+ * - Callback function used for authenticating to AAD.
+ * @throws SQLServerException
+ * when an error occurs
+ */
+ public SQLServerColumnEncryptionAzureKeyVaultProvider(SQLServerKeyVaultAuthenticationCallback authenticationCallback) throws SQLServerException {
+ if (null == authenticationCallback) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_NullValue"));
+ Object[] msgArgs1 = {"SQLServerKeyVaultAuthenticationCallback"};
+ throw new SQLServerException(form.format(msgArgs1), null);
+ }
+ credentials = new KeyVaultCredential(authenticationCallback);
+ RestClient restClient = new RestClient.Builder(new OkHttpClient.Builder(), new Retrofit.Builder()).withBaseUrl(baseUrl)
+ .withCredentials(credentials).withSerializerAdapter(new AzureJacksonAdapter())
+ .withResponseBuilderFactory(new AzureResponseBuilder.Factory()).build();
+ keyVaultClient = new KeyVaultClient(restClient);
+ }
+
+ /**
+ * Constructor that authenticates to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault.
+ *
* @param clientId
* Identifier of the client requesting the token.
* @param clientKey
* Key of the client requesting the token.
* @throws SQLServerException
- * when an error occurs
+ * when an error occurs
*/
public SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId,
String clientKey) throws SQLServerException {
- credential = new KeyVaultCredential(clientId, clientKey);
- keyVaultClient = new KeyVaultClient(credential);
+ credentials = new KeyVaultCredential(clientId, clientKey);
+ keyVaultClient = new KeyVaultClient(credentials);
}
/**
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
index 432aa9e32b..0c4b2bef9c 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
@@ -11,34 +11,28 @@
import static java.nio.charset.StandardCharsets.UTF_16LE;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
-import java.net.IDN;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
-import java.sql.Blob;
import java.sql.CallableStatement;
-import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
-import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLPermission;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
-import java.sql.Struct;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -53,8 +47,6 @@
import javax.sql.XAConnection;
import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
-
import mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.Builder;
import mssql.googlecode.concurrentlinkedhashmap.EvictionListener;
@@ -81,23 +73,33 @@
* details.
*/
-// Note all the public functions in this class also need to be defined in SQLServerConnectionPoolProxy.
-public class SQLServerConnection implements ISQLServerConnection {
+// NOTE: All the public functions in this class also need to be defined in SQLServerConnectionPoolProxy
+// Declare all new custom (non-static) Public APIs in ISQLServerConnection interface such that they can also be implemented by
+// SQLServerConnectionPoolProxy
+public class SQLServerConnection implements ISQLServerConnection, java.io.Serializable {
- long timerExpire;
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
+ private static final long serialVersionUID = 1965647556064751510L;
+
+ long timerExpire;
boolean attemptRefreshTokenLocked = false;
- // Threasholds related to when prepared statement handles are cleaned-up. 1 == immediately.
+ // Thresholds related to when prepared statement handles are cleaned-up. 1 == immediately.
/**
- * The default for the prepared statement clean-up action threshold (i.e. when sp_unprepare is called).
- */
+ * The default for the prepared statement clean-up action threshold (i.e. when sp_unprepare is called).
+ */
static final int DEFAULT_SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD = 10; // Used to set the initial default, can be changed later.
private int serverPreparedStatementDiscardThreshold = -1; // Current limit for this particular connection.
/**
- * The default for if prepared statements should execute sp_executesql before following the prepare, unprepare pattern.
- */
- static final boolean DEFAULT_ENABLE_PREPARE_ON_FIRST_PREPARED_STATEMENT_CALL = false; // Used to set the initial default, can be changed later. false == use sp_executesql -> sp_prepexec -> sp_execute -> batched -> sp_unprepare pattern, true == skip sp_executesql part of pattern.
+ * The default for if prepared statements should execute sp_executesql before following the prepare, unprepare pattern.
+ */
+ static final boolean DEFAULT_ENABLE_PREPARE_ON_FIRST_PREPARED_STATEMENT_CALL = false; // Used to set the initial default, can be changed later.
+ // false == use sp_executesql -> sp_prepexec -> sp_execute
+ // -> batched -> sp_unprepare pattern, true == skip
+ // sp_executesql part of pattern.
private Boolean enablePrepareOnFirstPreparedStatementCall = null; // Current limit for this particular connection.
// Handle the actual queue of discarded prepared statements.
@@ -106,7 +108,6 @@ public class SQLServerConnection implements ISQLServerConnection {
private boolean fedAuthRequiredByUser = false;
private boolean fedAuthRequiredPreLoginResponse = false;
- private boolean federatedAuthenticationAcknowledged = false;
private boolean federatedAuthenticationRequested = false;
private boolean federatedAuthenticationInfoRequested = false; // Keep this distinct from _federatedAuthenticationRequested, since some fedauth
// library types may not need more info
@@ -117,24 +118,32 @@ public class SQLServerConnection implements ISQLServerConnection {
private SqlFedAuthToken fedAuthToken = null;
- static class Sha1HashKey {
+ private String originalHostNameInCertificate = null;
+
+ private Boolean isAzureDW = null;
+
+ static class Sha1HashKey implements java.io.Serializable {
+
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
+ private static final long serialVersionUID = 166788428640603097L;
private byte[] bytes;
Sha1HashKey(String sql,
- String parametersDefinition,
- String dbName) {
- this(String.format("%s%s%s", sql, parametersDefinition, dbName));
+ String parametersDefinition) {
+ this(String.format("%s%s", sql, parametersDefinition));
}
Sha1HashKey(String s) {
- bytes = getSha1Digest().digest(s.getBytes());
+ bytes = getSha1Digest().digest(s.getBytes());
}
public boolean equals(Object obj) {
if (!(obj instanceof Sha1HashKey))
return false;
- return java.util.Arrays.equals(bytes, ((Sha1HashKey)obj).bytes);
+ return java.util.Arrays.equals(bytes, ((Sha1HashKey) obj).bytes);
}
public int hashCode() {
@@ -155,16 +164,19 @@ private java.security.MessageDigest getSha1Digest() {
/**
* Used to keep track of an individual prepared statement handle.
*/
- class PreparedStatementHandle {
+ class PreparedStatementHandle {
private int handle = 0;
private final AtomicInteger handleRefCount = new AtomicInteger();
private boolean isDirectSql;
- private volatile boolean evictedFromCache;
- private volatile boolean explicitlyDiscarded;
+ private volatile boolean evictedFromCache;
+ private volatile boolean explicitlyDiscarded;
private Sha1HashKey key;
- PreparedStatementHandle(Sha1HashKey key, int handle, boolean isDirectSql, boolean isEvictedFromCache) {
- this.key = key;
+ PreparedStatementHandle(Sha1HashKey key,
+ int handle,
+ boolean isDirectSql,
+ boolean isEvictedFromCache) {
+ this.key = key;
this.handle = handle;
this.isDirectSql = isDirectSql;
this.setIsEvictedFromCache(isEvictedFromCache);
@@ -183,9 +195,9 @@ private void setIsEvictedFromCache(boolean isEvictedFromCache) {
/** Specify that this statement has been explicitly discarded from being used by the cache. */
void setIsExplicitlyDiscarded() {
- this.explicitlyDiscarded = true;
-
- evictCachedPreparedStatementHandle(this);
+ this.explicitlyDiscarded = true;
+
+ evictCachedPreparedStatementHandle(this);
}
/** Has the statement been explicitly discarded. */
@@ -207,12 +219,11 @@ boolean isDirectSql() {
return isDirectSql;
}
- /** Make sure handle cannot be re-used.
+ /**
+ * Make sure handle cannot be re-used.
*
- * @return
- * false: Handle could not be discarded, it is in use.
- * true: Handle was successfully put on path for discarding.
- */
+ * @return false: Handle could not be discarded, it is in use. true: Handle was successfully put on path for discarding.
+ */
private boolean tryDiscardHandle() {
return handleRefCount.compareAndSet(0, -999);
}
@@ -222,12 +233,12 @@ private boolean isDiscarded() {
return 0 > handleRefCount.intValue();
}
- /** Adds a new reference to this handle, i.e. re-using it.
+ /**
+ * Adds a new reference to this handle, i.e. re-using it.
*
- * @return
- * false: Reference could not be added, statement has been discarded or does not have a handle associated with it.
- * true: Reference was successfully added.
- */
+ * @return false: Reference could not be added, statement has been discarded or does not have a handle associated with it. true: Reference was
+ * successfully added.
+ */
boolean tryAddReference() {
if (isDiscarded() || isExplicitlyDiscarded())
return false;
@@ -237,7 +248,7 @@ boolean tryAddReference() {
}
}
- /** Remove a reference from this handle*/
+ /** Remove a reference from this handle */
void removeReference() {
handleRefCount.decrementAndGet();
}
@@ -250,34 +261,33 @@ void removeReference() {
static private ConcurrentLinkedHashMap parsedSQLCache;
static {
- parsedSQLCache = new Builder()
- .maximumWeightedCapacity(PARSED_SQL_CACHE_SIZE)
- .build();
+ parsedSQLCache = new Builder().maximumWeightedCapacity(PARSED_SQL_CACHE_SIZE).build();
}
/** Get prepared statement cache entry if exists, if not parse and create a new one */
- static ParsedSQLCacheItem getCachedParsedSQL(Sha1HashKey key) {
+ static ParsedSQLCacheItem getCachedParsedSQL(Sha1HashKey key) {
return parsedSQLCache.get(key);
}
/** Parse and create a information about parsed SQL text */
- static ParsedSQLCacheItem parseAndCacheSQL(Sha1HashKey key, String sql) throws SQLServerException {
+ static ParsedSQLCacheItem parseAndCacheSQL(Sha1HashKey key,
+ String sql) throws SQLServerException {
JDBCSyntaxTranslator translator = new JDBCSyntaxTranslator();
String parsedSql = translator.translate(sql);
- String procName = translator.getProcedureName(); // may return null
+ String procName = translator.getProcedureName(); // may return null
boolean returnValueSyntax = translator.hasReturnValueSyntax();
int paramCount = countParams(parsedSql);
- ParsedSQLCacheItem cacheItem = new ParsedSQLCacheItem (parsedSql, paramCount, procName, returnValueSyntax);
+ ParsedSQLCacheItem cacheItem = new ParsedSQLCacheItem(parsedSql, paramCount, procName, returnValueSyntax);
parsedSQLCache.putIfAbsent(key, cacheItem);
return cacheItem;
}
-
+
/** Default size for prepared statement caches */
- static final int DEFAULT_STATEMENT_POOLING_CACHE_SIZE = 0;
-
- /** Size of the prepared statement handle cache */
+ static final int DEFAULT_STATEMENT_POOLING_CACHE_SIZE = 0;
+
+ /** Size of the prepared statement handle cache */
private int statementPoolingCacheSize = DEFAULT_STATEMENT_POOLING_CACHE_SIZE;
/** Cache of prepared statement handles */
@@ -289,23 +299,23 @@ static ParsedSQLCacheItem parseAndCacheSQL(Sha1HashKey key, String sql) throws
*/
private boolean disableStatementPooling = true;
- /**
- * Find statement parameters.
- *
- * @param sql
- * SQL text to parse for number of parameters to intialize.
- */
- private static int countParams(String sql) {
- int nParams = 0;
-
- // Figure out the expected number of parameters by counting the
- // parameter placeholders in the SQL string.
- int offset = -1;
- while ((offset = ParameterUtils.scanSQLForChar('?', sql, ++offset)) < sql.length())
- ++nParams;
-
- return nParams;
- }
+ /**
+ * Find statement parameters.
+ *
+ * @param sql
+ * SQL text to parse for number of parameters to intialize.
+ */
+ private static int countParams(String sql) {
+ int nParams = 0;
+
+ // Figure out the expected number of parameters by counting the
+ // parameter placeholders in the SQL string.
+ int offset = -1;
+ while ((offset = ParameterUtils.scanSQLForChar('?', sql, ++offset)) < sql.length())
+ ++nParams;
+
+ return nParams;
+ }
SqlFedAuthToken getAuthenticationResult() {
return fedAuthToken;
@@ -360,8 +370,6 @@ public String toString() {
}
}
-
-
class ActiveDirectoryAuthentication {
static final String JDBC_FEDAUTH_CLIENT_ID = "7f98cb04-cd1e-40df-9140-3bf7e2cea4db";
static final String ADAL_GET_ACCESS_TOKEN_FUNCTION_NAME = "ADALGetAccessToken";
@@ -389,7 +397,6 @@ private enum State {
* Connection state variables. NB If new state is added then logical connections derived from a physical connection must inherit the same state.
* If state variables are added they must be added also in connection cloning method clone()
*/
-
private final static int INTERMITTENT_TLS_MAX_RETRY = 5;
// Indicates if we received a routing ENVCHANGE in the current connection attempt
@@ -404,24 +411,19 @@ ServerPortPlaceHolder getRoutingInfo() {
// Permission targets
private static final String callAbortPerm = "callAbort";
-
+
private static final String SET_NETWORK_TIMEOUT_PERM = "setNetworkTimeout";
- private boolean sendStringParametersAsUnicode = SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue(); // see
- // connection
- // properties
- // doc
- // (default
- // is
- // false).
+ // see connection properties doc (default is false).
+ private boolean sendStringParametersAsUnicode = SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue();
private String hostName = null;
-
+
boolean sendStringParametersAsUnicode() {
return sendStringParametersAsUnicode;
}
- private boolean lastUpdateCount; // see connection properties doc
+ private boolean lastUpdateCount; // see connection properties doc
final boolean useLastUpdateCount() {
return lastUpdateCount;
@@ -453,8 +455,8 @@ final ApplicationIntent getApplicationIntent() {
return applicationIntent;
}
- private int nLockTimeout; // see connection properties doc
- private String selectMethod; // see connection properties doc 4.0 new property
+ private int nLockTimeout; // see connection properties doc
+ private String selectMethod; // see connection properties doc 4.0 new property
final String getSelectMethod() {
return selectMethod;
@@ -472,21 +474,52 @@ final int getQueryTimeoutSeconds() {
return queryTimeoutSeconds;
}
+ /**
+ * timeout value for canceling the query timeout
+ */
+ private int cancelQueryTimeoutSeconds;
+
+ /**
+ * Retrieves the cancelTimeout in seconds
+ *
+ * @return
+ */
+ final int getCancelQueryTimeoutSeconds() {
+ return cancelQueryTimeoutSeconds;
+ }
+
private int socketTimeoutMilliseconds;
final int getSocketTimeoutMilliseconds() {
return socketTimeoutMilliseconds;
}
+ /**
+ * boolean value for deciding if the driver should use bulk copy API for batch inserts
+ */
+ private boolean useBulkCopyForBatchInsert;
+
+ /**
+ * Retrieves the useBulkCopyForBatchInsert value.
+ * @return flag for using Bulk Copy API for batch insert operations.
+ */
+ public boolean getUseBulkCopyForBatchInsert() {
+ return useBulkCopyForBatchInsert;
+ }
+
+ /**
+ * Specifies the flag for using Bulk Copy API for batch insert operations.
+ * @param useBulkCopyForBatchInsert boolean value for useBulkCopyForBatchInsert.
+ */
+ public void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert) {
+ this.useBulkCopyForBatchInsert = useBulkCopyForBatchInsert;
+ }
+
boolean userSetTNIR = true;
private boolean sendTimeAsDatetime = SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.getDefaultValue();
- /**
- * Checks the sendTimeAsDatetime property.
- *
- * @return boolean value of sendTimeAsDatetime
- */
+ @Override
public synchronized final boolean getSendTimeAsDatetime() {
return !isKatmaiOrLater() || sendTimeAsDatetime;
}
@@ -546,6 +579,12 @@ boolean getServerSupportsColumnEncryption() {
return serverSupportsColumnEncryption;
}
+ private boolean serverSupportsDataClassification = false;
+
+ boolean getServerSupportsDataClassification() {
+ return serverSupportsDataClassification;
+ }
+
static boolean isWindows;
static Map globalSystemColumnEncryptionKeyStoreProviders = new HashMap<>();
static {
@@ -740,7 +779,8 @@ static synchronized List getColumnEncryptionTrustedMasterKeyPaths(String
Properties activeConnectionProperties; // the active set of connection properties
private boolean integratedSecurity = SQLServerDriverBooleanProperty.INTEGRATED_SECURITY.getDefaultValue();
private AuthenticationScheme intAuthScheme = AuthenticationScheme.nativeAuthentication;
- private GSSCredential ImpersonatedUserCred ;
+ private GSSCredential ImpersonatedUserCred;
+ private Boolean isUserCreatedCredential;
// This is the current connect place holder this should point one of the primary or failover place holder
ServerPortPlaceHolder currentConnectPlaceHolder = null;
@@ -888,12 +928,7 @@ int getServerMajorVersion() {
private UUID clientConnectionId = null;
- /**
- * Retrieves the clientConnectionID.
- *
- * @throws SQLServerException
- * when an error occurs
- */
+ @Override
public UUID getClientConnectionId() throws SQLServerException {
// If the connection is closed, we do not allow external application to get
// ClientConnectionId.
@@ -920,15 +955,6 @@ final boolean attachConnId() {
connectionlogger.fine(toString() + " created by (" + parentInfo + ")");
initResettableValues();
- // JDBC 3 driver only works with 1.5 JRE
- if (3 == DriverJDBCVersion.major && !"1.5".equals(Util.SYSTEM_SPEC_VERSION)) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unsupportedJREVersion"));
- Object[] msgArgs = {Util.SYSTEM_SPEC_VERSION};
- String message = form.format(msgArgs);
- connectionlogger.severe(message);
- throw new UnsupportedOperationException(message);
- }
-
// Caching turned on?
if (!this.getDisableStatementPooling() && 0 < this.getStatementPoolingCacheSize()) {
prepareCache();
@@ -966,7 +992,7 @@ final void resetPooledConnection() {
*
* @return the next conn id
*/
- /* L0 */ private static int nextConnectionID() {
+ private static int nextConnectionID() {
return baseConnectionID.incrementAndGet(); // 4.04 Ensure thread safe id allocation
}
@@ -981,6 +1007,7 @@ String getClassNameLogging() {
/**
* This is a helper function to provide an ID string suitable for tracing.
*/
+ @Override
public String toString() {
if (null != clientConnectionId)
return traceID + " ClientConnectionId: " + clientConnectionId.toString();
@@ -988,21 +1015,12 @@ public String toString() {
return traceID;
}
- /**
- * Throw a not implemeneted exception.
- *
- * @throws SQLServerException
- */
- /* L0 */ void NotImplemented() throws SQLServerException {
- SQLServerException.makeFromDriverError(this, this, SQLServerException.getErrString("R_notSupported"), null, false);
- }
-
/**
* Check if the connection is closed Create a new connection if it's a fedauth connection and the access token is going to expire.
*
* @throws SQLServerException
*/
- /* L0 */ void checkClosed() throws SQLServerException {
+ void checkClosed() throws SQLServerException {
if (isSessionUnAvailable()) {
SQLServerException.makeFromDriverError(null, null, SQLServerException.getErrString("R_connectionIsClosed"), null, false);
}
@@ -1027,7 +1045,7 @@ public String toString() {
* @exception SQLServerException
* thrown if value is not recognized.
*/
- /* L0 */ private boolean booleanPropertyOn(String propName,
+ private boolean booleanPropertyOn(String propName,
String propValue) throws SQLServerException {
// Null means take the default of false.
if (null == propValue)
@@ -1122,8 +1140,8 @@ else if (elapsedSeconds >= loginTimeoutSeconds) {
else {
// Retry the connection.
if (connectionlogger.isLoggable(Level.FINE)) {
- connectionlogger
- .fine("Connection failed during SSL handshake. Retrying due to an intermittent TLS 1.2 failure issue. Retry attempt = "
+ connectionlogger.fine(
+ "Connection failed during SSL handshake. Retrying due to an intermittent TLS 1.2 failure issue. Retry attempt = "
+ retryAttempt + ".");
}
}
@@ -1187,6 +1205,22 @@ Connection connectInternal(Properties propsIn,
pooledConnectionParent = pooledConnection;
+ String hostNameInCertificate = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString());
+
+ // hostNameInCertificate property can change when redirection is involved, so maintain this value
+ // for every instance of SQLServerConnection.
+ if (null == originalHostNameInCertificate && null != hostNameInCertificate && !hostNameInCertificate.isEmpty()) {
+ originalHostNameInCertificate = activeConnectionProperties
+ .getProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString());
+ }
+
+ if (null != originalHostNameInCertificate && !originalHostNameInCertificate.isEmpty()) {
+ // if hostNameInCertificate has a legitimate value (and not empty or null),
+ // reset hostNameInCertificate to the original value every time we connect (or re-connect).
+ activeConnectionProperties.setProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(),
+ originalHostNameInCertificate);
+ }
+
String sPropKey;
String sPropValue;
@@ -1266,7 +1300,7 @@ Connection connectInternal(Properties propsIn,
if (true == serverNameAsACE) {
try {
- sPropValue = IDN.toASCII(sPropValue);
+ sPropValue = java.net.IDN.toASCII(sPropValue);
}
catch (IllegalArgumentException ex) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidConnectionSetting"));
@@ -1371,7 +1405,8 @@ Connection connectInternal(Properties propsIn,
trustServerCertificate = booleanPropertyOn(sPropKey, sPropValue);
trustManagerClass = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.TRUST_MANAGER_CLASS.toString());
- trustManagerConstructorArg = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.TRUST_MANAGER_CONSTRUCTOR_ARG.toString());
+ trustManagerConstructorArg = activeConnectionProperties
+ .getProperty(SQLServerDriverStringProperty.TRUST_MANAGER_CONSTRUCTOR_ARG.toString());
sPropKey = SQLServerDriverStringProperty.SELECT_METHOD.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
@@ -1434,7 +1469,7 @@ Connection connectInternal(Properties propsIn,
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (null != sPropValue) {
setDisableStatementPooling(booleanPropertyOn(sPropKey, sPropValue));
- }
+ }
sPropKey = SQLServerDriverBooleanProperty.INTEGRATED_SECURITY.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
@@ -1451,12 +1486,14 @@ Connection connectInternal(Properties propsIn,
}
}
- if(intAuthScheme == AuthenticationScheme.javaKerberos){
+ if (intAuthScheme == AuthenticationScheme.javaKerberos) {
sPropKey = SQLServerDriverObjectProperty.GSS_CREDENTIAL.toString();
- if(activeConnectionProperties.containsKey(sPropKey))
+ if (activeConnectionProperties.containsKey(sPropKey)) {
ImpersonatedUserCred = (GSSCredential) activeConnectionProperties.get(sPropKey);
+ isUserCreatedCredential = true;
+ }
}
-
+
sPropKey = SQLServerDriverStringProperty.AUTHENTICATION.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (sPropValue == null) {
@@ -1688,7 +1725,32 @@ else if (0 == requestedPacketSize)
SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
}
}
-
+
+ sPropKey = SQLServerDriverIntProperty.CANCEL_QUERY_TIMEOUT.toString();
+ int cancelQueryTimeout = SQLServerDriverIntProperty.CANCEL_QUERY_TIMEOUT.getDefaultValue();
+
+ if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
+ try {
+ int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
+ if (n >= cancelQueryTimeout) {
+ // use cancelQueryTimeout only if queryTimeout is set.
+ if (queryTimeoutSeconds > defaultQueryTimeout) {
+ cancelQueryTimeoutSeconds = n;
+ }
+ }
+ else {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidCancelQueryTimeout"));
+ Object[] msgArgs = {activeConnectionProperties.getProperty(sPropKey)};
+ SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
+ }
+ }
+ catch (NumberFormatException e) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidCancelQueryTimeout"));
+ Object[] msgArgs = {activeConnectionProperties.getProperty(sPropKey)};
+ SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
+ }
+ }
+
sPropKey = SQLServerDriverIntProperty.SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
@@ -1707,7 +1769,13 @@ else if (0 == requestedPacketSize)
if (null != sPropValue) {
setEnablePrepareOnFirstPreparedStatementCall(booleanPropertyOn(sPropKey, sPropValue));
}
-
+
+ sPropKey = SQLServerDriverBooleanProperty.USE_BULK_COPY_FOR_BATCH_INSERT.toString();
+ sPropValue = activeConnectionProperties.getProperty(sPropKey);
+ if (null != sPropValue) {
+ useBulkCopyForBatchInsert = booleanPropertyOn(sPropKey, sPropValue);
+ }
+
sPropKey = SQLServerDriverStringProperty.SSL_PROTOCOL.toString();
sPropValue = activeConnectionProperties.getProperty(sPropKey);
if (null == sPropValue) {
@@ -1717,7 +1785,7 @@ else if (0 == requestedPacketSize)
else {
activeConnectionProperties.setProperty(sPropKey, SSLProtocol.valueOfString(sPropValue).toString());
}
-
+
FailoverInfo fo = null;
String databaseNameProperty = SQLServerDriverStringProperty.DATABASE_NAME.toString();
String serverNameProperty = SQLServerDriverStringProperty.SERVER_NAME.toString();
@@ -2228,14 +2296,14 @@ private void connectHelper(ServerPortPlaceHolder serverInfo,
connectionlogger.fine(toString() + " Connecting with server: " + serverInfo.getServerName() + " port: " + serverInfo.getPortNumber()
+ " Timeout slice: " + timeOutsliceInMillis + " Timeout Full: " + timeOutFullInSeconds);
}
-
+
// Before opening the TDSChannel, calculate local hostname
// as the InetAddress.getLocalHost() takes more than usual time in certain OS and JVM combination, it avoids connection loss
hostName = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.WORKSTATION_ID.toString());
if (StringUtils.isEmpty(hostName)) {
hostName = Util.lookupHostName();
}
-
+
// if the timeout is infinite slices are infinite too.
tdsChannel = new TDSChannel(this);
if (0 == timeOutFullInSeconds)
@@ -2764,7 +2832,7 @@ final boolean doExecute() throws SQLServerException {
*
* @return the syntax string
*/
- /* L0 */ private String sqlStatementToInitialize() {
+ private String sqlStatementToInitialize() {
String s = null;
if (nLockTimeout > -1)
s = " set lock_timeout " + nLockTimeout;
@@ -2778,7 +2846,7 @@ final boolean doExecute() throws SQLServerException {
* the new catalog
* @return the required syntax
*/
- /* L0 */ void setCatalogName(String sDB) {
+ void setCatalogName(String sDB) {
if (sDB != null) {
if (sDB.length() > 0) {
sCatalog = sDB;
@@ -2791,7 +2859,7 @@ final boolean doExecute() throws SQLServerException {
*
* @return the required syntax
*/
- /* L0 */ String sqlStatementToSetTransactionIsolationLevel() throws SQLServerException {
+ String sqlStatementToSetTransactionIsolationLevel() throws SQLServerException {
String sql = "set transaction isolation level ";
switch (transactionIsolationLevel) {
@@ -2833,34 +2901,39 @@ static String sqlStatementToSetCommit(boolean autoCommit) {
return (true == autoCommit) ? "set implicit_transactions off " : "set implicit_transactions on ";
}
- /* L0 */ public Statement createStatement() throws SQLServerException {
+ @Override
+ public Statement createStatement() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "createStatement");
Statement st = createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
loggerExternal.exiting(getClassNameLogging(), "createStatement", st);
return st;
}
- /* L0 */ public PreparedStatement prepareStatement(String sql) throws SQLServerException {
+ @Override
+ public PreparedStatement prepareStatement(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "prepareStatement", sql);
PreparedStatement pst = prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
loggerExternal.exiting(getClassNameLogging(), "prepareStatement", pst);
return pst;
}
- /* L0 */ public CallableStatement prepareCall(String sql) throws SQLServerException {
+ @Override
+ public CallableStatement prepareCall(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "prepareCall", sql);
CallableStatement st = prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
loggerExternal.exiting(getClassNameLogging(), "prepareCall", st);
return st;
}
- /* L0 */ public String nativeSQL(String sql) throws SQLServerException {
+ @Override
+ public String nativeSQL(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "nativeSQL", sql);
checkClosed();
loggerExternal.exiting(getClassNameLogging(), "nativeSQL", sql);
return sql;
}
+ @Override
public void setAutoCommit(boolean newAutoCommitMode) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER)) {
loggerExternal.entering(getClassNameLogging(), "setAutoCommit", newAutoCommitMode);
@@ -2888,7 +2961,8 @@ public void setAutoCommit(boolean newAutoCommitMode) throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "setAutoCommit");
}
- /* L0 */ public boolean getAutoCommit() throws SQLServerException {
+ @Override
+ public boolean getAutoCommit() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getAutoCommit");
checkClosed();
boolean res = !inXATransaction && databaseAutoCommitMode;
@@ -2897,16 +2971,11 @@ public void setAutoCommit(boolean newAutoCommitMode) throws SQLServerException {
return res;
}
- /* LO */ final byte[] getTransactionDescriptor() {
+ final byte[] getTransactionDescriptor() {
return transactionDescriptor;
}
- /**
- * Commit a transcation. Per our transaction spec, see also SDT#410729, a commit in autocommit mode = true is a NO-OP.
- *
- * @throws SQLServerException
- * if no transaction exists.
- */
+ @Override
public void commit() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "commit");
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
@@ -2919,12 +2988,7 @@ public void commit() throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "commit");
}
- /**
- * Rollback a transcation.
- *
- * @throws SQLServerException
- * if no transaction exists or if the connection is in auto-commit mode.
- */
+ @Override
public void rollback() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "rollback");
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
@@ -2940,6 +3004,7 @@ public void rollback() throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "rollback");
}
+ @Override
public void abort(Executor executor) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "abort", executor);
@@ -2969,17 +3034,13 @@ public void abort(Executor executor) throws SQLException {
setState(State.Closed);
- executor.execute(new Runnable() {
- public void run() {
- if (null != tdsChannel) {
- tdsChannel.close();
- }
- }
- });
+ if (null != tdsChannel)
+ executor.execute(() -> tdsChannel.close());
loggerExternal.exiting(getClassNameLogging(), "abort");
}
+ @Override
public void close() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "close");
@@ -3004,7 +3065,7 @@ public void close() throws SQLServerException {
// Clean-up queue etc. related to batching of prepared statement discard actions (sp_unprepare).
cleanupPreparedStatementDiscardActions();
-
+
ActivityCorrelator.cleanupActivityId();
loggerExternal.exiting(getClassNameLogging(), "close");
@@ -3034,13 +3095,15 @@ final void poolCloseEventNotify() throws SQLServerException {
}
- /* L0 */ public boolean isClosed() throws SQLServerException {
+ @Override
+ public boolean isClosed() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "isClosed");
loggerExternal.exiting(getClassNameLogging(), "isClosed", isSessionUnAvailable());
return isSessionUnAvailable();
}
- /* L0 */ public DatabaseMetaData getMetaData() throws SQLServerException {
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getMetaData");
checkClosed();
if (databaseMetaData == null) {
@@ -3050,7 +3113,8 @@ final void poolCloseEventNotify() throws SQLServerException {
return databaseMetaData;
}
- /* L0 */ public void setReadOnly(boolean readOnly) throws SQLServerException {
+ @Override
+ public void setReadOnly(boolean readOnly) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.entering(getClassNameLogging(), "setReadOnly", readOnly);
checkClosed();
@@ -3058,7 +3122,8 @@ final void poolCloseEventNotify() throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "setReadOnly");
}
- /* L0 */ public boolean isReadOnly() throws SQLServerException {
+ @Override
+ public boolean isReadOnly() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "isReadOnly");
checkClosed();
if (loggerExternal.isLoggable(Level.FINER))
@@ -3066,7 +3131,8 @@ final void poolCloseEventNotify() throws SQLServerException {
return false;
}
- /* L0 */ public void setCatalog(String catalog) throws SQLServerException {
+ @Override
+ public void setCatalog(String catalog) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "setCatalog", catalog);
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
@@ -3079,7 +3145,8 @@ final void poolCloseEventNotify() throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "setCatalog");
}
- /* L0 */ public String getCatalog() throws SQLServerException {
+ @Override
+ public String getCatalog() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getCatalog");
checkClosed();
loggerExternal.exiting(getClassNameLogging(), "getCatalog", sCatalog);
@@ -3090,7 +3157,8 @@ String getSCatalog() throws SQLServerException {
return sCatalog;
}
- /* L0 */ public void setTransactionIsolation(int level) throws SQLServerException {
+ @Override
+ public void setTransactionIsolation(int level) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER)) {
loggerExternal.entering(getClassNameLogging(), "setTransactionIsolation", level);
if (Util.IsActivityTraceOn()) {
@@ -3108,7 +3176,8 @@ String getSCatalog() throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "setTransactionIsolation");
}
- /* L0 */ public int getTransactionIsolation() throws SQLServerException {
+ @Override
+ public int getTransactionIsolation() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getTransactionIsolation");
checkClosed();
if (loggerExternal.isLoggable(Level.FINER))
@@ -3120,7 +3189,8 @@ String getSCatalog() throws SQLServerException {
Object warningSynchronization = new Object();
// Think about returning a copy when we implement additional warnings.
- /* L0 */ public SQLWarning getWarnings() throws SQLServerException {
+ @Override
+ public SQLWarning getWarnings() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getWarnings");
checkClosed();
// check null warn wont crash
@@ -3142,7 +3212,8 @@ private void addWarning(String warningString) {
}
}
- /* L2 */ public void clearWarnings() throws SQLServerException {
+ @Override
+ public void clearWarnings() throws SQLServerException {
synchronized (warningSynchronization) {
loggerExternal.entering(getClassNameLogging(), "clearWarnings");
checkClosed();
@@ -3152,38 +3223,35 @@ private void addWarning(String warningString) {
}
// --------------------------JDBC 2.0-----------------------------
+ @Override
public Statement createStatement(int resultSetType,
int resultSetConcurrency) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "createStatement",
- new Object[] {resultSetType, resultSetConcurrency});
+ loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[] {resultSetType, resultSetConcurrency});
checkClosed();
Statement st = new SQLServerStatement(this, resultSetType, resultSetConcurrency,
SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
+ }
loggerExternal.exiting(getClassNameLogging(), "createStatement", st);
return st;
}
+ @Override
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "prepareStatement",
- new Object[] {sql, resultSetType, resultSetConcurrency});
+ loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {sql, resultSetType, resultSetConcurrency});
checkClosed();
- PreparedStatement st;
-
- // Make sure SQLServerPreparedStatement42 is used for 4.2 and above.
- if (Util.use42Wrapper() || Util.use43Wrapper()) {
- st = new SQLServerPreparedStatement42(this, sql, resultSetType, resultSetConcurrency,
- SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
- }
- else {
- st = new SQLServerPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
- SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
- }
+ PreparedStatement st = new SQLServerPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
+ SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
+ }
loggerExternal.exiting(getClassNameLogging(), "prepareStatement", st);
return st;
}
@@ -3197,45 +3265,37 @@ private PreparedStatement prepareStatement(String sql,
new Object[] {sql, resultSetType, resultSetConcurrency, stmtColEncSetting});
checkClosed();
- PreparedStatement st;
+ PreparedStatement st = new SQLServerPreparedStatement(this, sql, resultSetType, resultSetConcurrency, stmtColEncSetting);
- // Make sure SQLServerPreparedStatement42 is used for 4.2 and above.
- if (Util.use42Wrapper() || Util.use43Wrapper()) {
- st = new SQLServerPreparedStatement42(this, sql, resultSetType, resultSetConcurrency, stmtColEncSetting);
- }
- else {
- st = new SQLServerPreparedStatement(this, sql, resultSetType, resultSetConcurrency, stmtColEncSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
}
loggerExternal.exiting(getClassNameLogging(), "prepareStatement", st);
return st;
}
+ @Override
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER))
- loggerExternal.entering(getClassNameLogging(), "prepareCall",
- new Object[] {sql, resultSetType, resultSetConcurrency});
+ loggerExternal.entering(getClassNameLogging(), "prepareCall", new Object[] {sql, resultSetType, resultSetConcurrency});
checkClosed();
- CallableStatement st;
+ CallableStatement st = new SQLServerCallableStatement(this, sql, resultSetType, resultSetConcurrency,
+ SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
- // Make sure SQLServerCallableStatement42 is used for 4.2 and above.
- if (Util.use42Wrapper() || Util.use43Wrapper()) {
- st = new SQLServerCallableStatement42(this, sql, resultSetType, resultSetConcurrency,
- SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
- }
- else {
- st = new SQLServerCallableStatement(this, sql, resultSetType, resultSetConcurrency,
- SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
}
loggerExternal.exiting(getClassNameLogging(), "prepareCall", st);
return st;
}
- /* L2 */ public void setTypeMap(java.util.Map> map) throws SQLServerException {
+ @Override
+ public void setTypeMap(java.util.Map> map) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "setTypeMap", map);
checkClosed();
if (map != null && (map instanceof java.util.HashMap)) {
@@ -3246,9 +3306,10 @@ public CallableStatement prepareCall(String sql,
}
}
- NotImplemented();
+ SQLServerException.throwNotSupportedException(this, null);
}
+ @Override
public java.util.Map> getTypeMap() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getTypeMap");
checkClosed();
@@ -3266,9 +3327,9 @@ int writeAEFeatureRequest(boolean write,
int len = 6; // (1byte = featureID, 4bytes = featureData length, 1 bytes = Version)
if (write) {
- tdsWriter.writeByte((byte) TDS.TDS_FEATURE_EXT_AE); // FEATUREEXT_TCE
+ tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_AE); // FEATUREEXT_TCE
tdsWriter.writeInt(1);
- tdsWriter.writeByte((byte) TDS.MAX_SUPPORTED_TCE_VERSION);
+ tdsWriter.writeByte(TDS.MAX_SUPPORTED_TCE_VERSION);
}
return len;
}
@@ -3279,7 +3340,6 @@ int writeFedAuthFeatureRequest(boolean write,
* if false just calculates the
* length
*/
-
assert (fedAuthFeatureExtensionData.libraryType == TDS.TDS_FEDAUTH_LIBRARY_ADAL
|| fedAuthFeatureExtensionData.libraryType == TDS.TDS_FEDAUTH_LIBRARY_SECURITYTOKEN);
@@ -3363,6 +3423,28 @@ int writeFedAuthFeatureRequest(boolean write,
}
return totalLen;
}
+
+ int writeDataClassificationFeatureRequest(boolean write /* if false just calculates the length */,
+ TDSWriter tdsWriter) throws SQLServerException {
+ int len = 6; // 1byte = featureID, 4bytes = featureData length, 1 bytes = Version
+ if (write) {
+ // Write Feature ID, length of the version# field and Sensitivity Classification Version#
+ tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_DATACLASSIFICATION);
+ tdsWriter.writeInt(1);
+ tdsWriter.writeByte(TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION);
+ }
+ return len; // size of data written
+ }
+
+ int writeUTF8SupportFeatureRequest(boolean write,
+ TDSWriter tdsWriter /* if false just calculates the length */) throws SQLServerException {
+ int len = 5; // 1byte = featureID, 4bytes = featureData length
+ if (write) {
+ tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_UTF8SUPPORT);
+ tdsWriter.writeInt(0);
+ }
+ return len;
+ }
private final class LogonCommand extends UninterruptableTDSCommand {
LogonCommand() {
@@ -3375,14 +3457,15 @@ final boolean doExecute() throws SQLServerException {
}
}
- /* L0 */ private void logon(LogonCommand command) throws SQLServerException {
+ private void logon(LogonCommand command) throws SQLServerException {
SSPIAuthentication authentication = null;
if (integratedSecurity && AuthenticationScheme.nativeAuthentication == intAuthScheme)
authentication = new AuthenticationJNI(this, currentConnectPlaceHolder.getServerName(), currentConnectPlaceHolder.getPortNumber());
if (integratedSecurity && AuthenticationScheme.javaKerberos == intAuthScheme) {
- if (null != ImpersonatedUserCred)
+ if (null != ImpersonatedUserCred) {
authentication = new KerbAuthentication(this, currentConnectPlaceHolder.getServerName(), currentConnectPlaceHolder.getPortNumber(),
- ImpersonatedUserCred);
+ ImpersonatedUserCred, isUserCreatedCredential);
+ }
else
authentication = new KerbAuthentication(this, currentConnectPlaceHolder.getServerName(), currentConnectPlaceHolder.getPortNumber());
}
@@ -3404,7 +3487,6 @@ final boolean doExecute() throws SQLServerException {
// No need any further info from the server for token based authentication. So set _federatedAuthenticationRequested to true
federatedAuthenticationRequested = true;
}
-
try {
sendLogon(command, authentication, fedAuthFeatureExtensionData);
@@ -3421,18 +3503,12 @@ final boolean doExecute() throws SQLServerException {
}
finally {
if (integratedSecurity) {
- if (null != authentication)
+ if (null != authentication) {
authentication.ReleaseClientContext();
- authentication = null;
-
+ authentication = null;
+ }
if (null != ImpersonatedUserCred) {
- try {
- ImpersonatedUserCred.dispose();
- }
- catch (GSSException e) {
- if (connectionlogger.isLoggable(Level.FINER))
- connectionlogger.finer(toString() + " Release of the credentials failed GSSException: " + e);
- }
+ ImpersonatedUserCred = null;
}
}
}
@@ -3451,6 +3527,7 @@ final boolean doExecute() throws SQLServerException {
private static final int ENVCHANGE_DTC_ENLIST = 11;
private static final int ENVCHANGE_DTC_DEFECT = 12;
private static final int ENVCHANGE_CHANGE_MIRROR = 13;
+ @SuppressWarnings("unused")
private static final int ENVCHANGE_UNUSED_14 = 14;
private static final int ENVCHANGE_DTC_PROMOTE = 15;
private static final int ENVCHANGE_DTC_MGR_ADDR = 16;
@@ -3485,7 +3562,7 @@ final void processEnvChange(TDSReader tdsReader) throws SQLServerException {
try {
databaseCollation = new SQLCollation(tdsReader);
}
- catch (UnsupportedEncodingException e) {
+ catch (java.io.UnsupportedEncodingException e) {
terminate(SQLServerException.DRIVER_ERROR_INVALID_TDS, e.getMessage(), e);
}
@@ -3613,8 +3690,11 @@ final void processEnvChange(TDSReader tdsReader) throws SQLServerException {
// Check if the hostNameInCertificate needs to be updated to handle the rerouted subdomain in Azure
String currentHostName = activeConnectionProperties.getProperty("hostNameInCertificate");
- if (null != currentHostName && currentHostName.startsWith("*")
- && (null != routingServerName) /* skip the check for hostNameInCertificate if routingServerName is null */
+ if (null != currentHostName && currentHostName.startsWith("*") && (null != routingServerName) /*
+ * skip the check for
+ * hostNameInCertificate if
+ * routingServerName is null
+ */
&& routingServerName.indexOf('.') != -1) {
char[] currentHostNameCharArray = currentHostName.toCharArray();
char[] routingServerNameCharArray = routingServerName.toCharArray();
@@ -3850,7 +3930,7 @@ private SqlFedAuthToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throws SQLSe
// No:of milliseconds to sleep for the inital back off.
int sleepInterval = 100;
-
+
while (true) {
if (authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDirectoryPassword.toString())) {
fedAuthToken = SQLServerADAL4JUtils.getSqlFedAuthToken(fedAuthInfo, user, password, authenticationString);
@@ -3859,7 +3939,7 @@ private SqlFedAuthToken getFedAuthToken(SqlFedAuthInfo fedAuthInfo) throws SQLSe
break;
}
else if (authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDirectoryIntegrated.toString())) {
-
+
// If operating system is windows and sqljdbc_auth is loaded then choose the DLL authentication.
if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows") && AuthenticationJNI.isDllLoaded()) {
try {
@@ -3996,7 +4076,7 @@ final void processFeatureExtAck(TDSReader tdsReader) throws SQLServerException {
while (featureId != TDS.FEATURE_EXT_TERMINATOR);
}
- private void onFeatureExtAck(int featureId,
+ private void onFeatureExtAck(byte featureId,
byte[] data) throws SQLServerException {
if (null != routingInfo) {
return;
@@ -4042,8 +4122,6 @@ private void onFeatureExtAck(int featureId,
Object[] msgArgs = {fedAuthFeatureExtensionData.libraryType};
throw new SQLServerException(form.format(msgArgs), null);
}
- federatedAuthenticationAcknowledged = true;
-
break;
}
case TDS.TDS_FEATURE_EXT_AE: {
@@ -4066,11 +4144,46 @@ private void onFeatureExtAck(int featureId,
throw new SQLServerException(SQLServerException.getErrString("R_InvalidAEVersionNumber"), null);
}
- assert supportedTceVersion == TDS.MAX_SUPPORTED_TCE_VERSION; // Client support TCE version 1
serverSupportsColumnEncryption = true;
break;
}
+ case TDS.TDS_FEATURE_EXT_DATACLASSIFICATION: {
+ if (connectionlogger.isLoggable(Level.FINER)) {
+ connectionlogger.fine(toString() + " Received feature extension acknowledgement for Data Classification.");
+ }
+
+ if (2 != data.length) {
+ if (connectionlogger.isLoggable(Level.SEVERE)) {
+ connectionlogger.severe(toString() + " Unknown token for Data Classification.");
+ }
+ throw new SQLServerException(SQLServerException.getErrString("R_UnknownDataClsTokenNumber"), null);
+ }
+
+ byte supportedDataClassificationVersion = data[0];
+ if ((0 == supportedDataClassificationVersion)
+ || (supportedDataClassificationVersion > TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) {
+ if (connectionlogger.isLoggable(Level.SEVERE)) {
+ connectionlogger.severe(toString() + " Invalid version number for Data Classification");
+ }
+ throw new SQLServerException(SQLServerException.getErrString("R_InvalidDataClsVersionNumber"), null);
+ }
+
+ byte enabled = data[1];
+ serverSupportsDataClassification = (enabled == 0) ? false : true;
+ }
+ case TDS.TDS_FEATURE_EXT_UTF8SUPPORT: {
+ if (connectionlogger.isLoggable(Level.FINER)) {
+ connectionlogger.fine(toString() + " Received feature extension acknowledgement for UTF8 support.");
+ }
+ if (1 > data.length) {
+ if (connectionlogger.isLoggable(Level.SEVERE)) {
+ connectionlogger.severe(toString() + " Unknown value for UTF8 support.");
+ }
+ throw new SQLServerException(SQLServerException.getErrString("R_unknownUTF8SupportValue"), null);
+ }
+ break;
+ }
default: {
// Unknown feature ack
if (connectionlogger.isLoggable(Level.SEVERE)) {
@@ -4156,7 +4269,7 @@ final void JTAEnlistConnection(byte cookie[]) throws SQLServerException {
* @throws SQLServerException
* @return the encoded data
*/
- /* L0 */ private byte[] toUCS16(String s) throws SQLServerException {
+ private byte[] toUCS16(String s) throws SQLServerException {
if (s == null)
return new byte[0];
int l = s.length();
@@ -4178,7 +4291,7 @@ final void JTAEnlistConnection(byte cookie[]) throws SQLServerException {
* the password
* @return the encryption
*/
- /* L0 */ private byte[] encryptPassword(String pwd) {
+ private byte[] encryptPassword(String pwd) {
// Changed to handle non ascii passwords
if (pwd == null)
pwd = "";
@@ -4357,7 +4470,12 @@ else if (serverMajorVersion >= 9) // Yukon (9.0) --> TDS 7.2 // Prelogin disconn
len2 = len2 + writeFedAuthFeatureRequest(false, tdsWriter, fedAuthFeatureExtensionData);
}
- len2 = len2 + 1; // add 1 to length becaue of FeatureEx terminator
+ // Data Classification is always enabled (by default)
+ len2 += writeDataClassificationFeatureRequest(false, tdsWriter);
+
+ len2 = len2 + writeUTF8SupportFeatureRequest(false, tdsWriter);
+
+ len2 = len2 + 1; // add 1 to length because of FeatureEx terminator
// Length of entire Login 7 packet
tdsWriter.writeInt(len2);
@@ -4384,8 +4502,9 @@ else if (serverMajorVersion >= 9) // Yukon (9.0) --> TDS 7.2 // Prelogin disconn
TDS.LOGIN_OPTION2_INTEGRATED_SECURITY_ON : TDS.LOGIN_OPTION2_INTEGRATED_SECURITY_OFF)));
// TypeFlags
- tdsWriter.writeByte((byte) (TDS.LOGIN_SQLTYPE_DEFAULT | (applicationIntent != null && applicationIntent.equals(ApplicationIntent.READ_ONLY)
- ? TDS.LOGIN_READ_ONLY_INTENT : TDS.LOGIN_READ_WRITE_INTENT)));
+ tdsWriter.writeByte((byte) (TDS.LOGIN_SQLTYPE_DEFAULT
+ | (applicationIntent != null && applicationIntent.equals(ApplicationIntent.READ_ONLY) ? TDS.LOGIN_READ_ONLY_INTENT
+ : TDS.LOGIN_READ_WRITE_INTENT)));
// OptionFlags3
byte colEncSetting;
@@ -4538,6 +4657,9 @@ else if (serverMajorVersion >= 9) // Yukon (9.0) --> TDS 7.2 // Prelogin disconn
writeFedAuthFeatureRequest(true, tdsWriter, fedAuthFeatureExtensionData);
}
+ writeDataClassificationFeatureRequest(true, tdsWriter);
+ writeUTF8SupportFeatureRequest(true, tdsWriter);
+
tdsWriter.writeByte((byte) TDS.FEATURE_EXT_TERMINATOR);
tdsWriter.setDataLoggable(true);
@@ -4576,123 +4698,92 @@ private void checkMatchesCurrentHoldability(int resultSetHoldability) throws SQL
}
}
+ @Override
public Statement createStatement(int nType,
int nConcur,
int resultSetHoldability) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "createStatement",
- new Object[] {nType, nConcur, resultSetHoldability});
+ loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[] {nType, nConcur, resultSetHoldability});
Statement st = createStatement(nType, nConcur, resultSetHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
loggerExternal.exiting(getClassNameLogging(), "createStatement", st);
return st;
}
+ @Override
public Statement createStatement(int nType,
int nConcur,
int resultSetHoldability,
SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "createStatement",
- new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetting});
+ loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetting});
checkClosed();
checkValidHoldability(resultSetHoldability);
checkMatchesCurrentHoldability(resultSetHoldability);
Statement st = new SQLServerStatement(this, nType, nConcur, stmtColEncSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
+ }
loggerExternal.exiting(getClassNameLogging(), "createStatement", st);
return st;
}
- /* L3 */ public PreparedStatement prepareStatement(java.lang.String sql,
+ @Override
+ public PreparedStatement prepareStatement(java.lang.String sql,
int nType,
int nConcur,
int resultSetHoldability) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "prepareStatement",
- new Object[] {nType, nConcur, resultSetHoldability});
+ loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {nType, nConcur, resultSetHoldability});
PreparedStatement st = prepareStatement(sql, nType, nConcur, resultSetHoldability,
SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
loggerExternal.exiting(getClassNameLogging(), "prepareStatement", st);
return st;
}
- /**
- * Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and
- * holdability.
- *
- * This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and
- * holdability to be overridden.
- *
- * @param sql
- * a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
- * @param nType
- * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
- * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
- * @param nConcur
- * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
- * ResultSet.CONCUR_UPDATABLE
- * @param resultSetHoldability
- * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
- * ResultSet.CLOSE_CURSORS_AT_COMMIT
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will generate ResultSet
- * objects with the given type, concurrency, and holdability
- * @throws SQLServerException
- * if a database access error occurs, this method is called on a closed connection or the given parameters are not
- * ResultSet constants indicating type, concurrency, and holdability
- */
+ @Override
public PreparedStatement prepareStatement(java.lang.String sql,
int nType,
int nConcur,
int resultSetHoldability,
SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "prepareStatement",
- new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetting});
+ loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetting});
checkClosed();
checkValidHoldability(resultSetHoldability);
checkMatchesCurrentHoldability(resultSetHoldability);
- PreparedStatement st;
+ PreparedStatement st = new SQLServerPreparedStatement(this, sql, nType, nConcur, stmtColEncSetting);
- // Make sure SQLServerPreparedStatement42 is used for 4.2 and above.
- if (Util.use42Wrapper() || Util.use43Wrapper()) {
- st = new SQLServerPreparedStatement42(this, sql, nType, nConcur, stmtColEncSetting);
- }
- else {
- st = new SQLServerPreparedStatement(this, sql, nType, nConcur, stmtColEncSetting);
+ if (requestStarted) {
+ addOpenStatement(st);
}
loggerExternal.exiting(getClassNameLogging(), "prepareStatement", st);
return st;
}
- /* L3 */ public CallableStatement prepareCall(String sql,
+ @Override
+ public CallableStatement prepareCall(String sql,
int nType,
int nConcur,
int resultSetHoldability) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "prepareStatement",
- new Object[] {nType, nConcur, resultSetHoldability});
+ loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {nType, nConcur, resultSetHoldability});
CallableStatement st = prepareCall(sql, nType, nConcur, resultSetHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
loggerExternal.exiting(getClassNameLogging(), "prepareCall", st);
return st;
}
+ @Override
public CallableStatement prepareCall(String sql,
int nType,
int nConcur,
int resultSetHoldability,
SQLServerStatementColumnEncryptionSetting stmtColEncSetiing) throws SQLServerException {
- loggerExternal.entering(getClassNameLogging(), "prepareStatement",
- new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetiing});
+ loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetiing});
checkClosed();
checkValidHoldability(resultSetHoldability);
checkMatchesCurrentHoldability(resultSetHoldability);
- CallableStatement st;
+ CallableStatement st = new SQLServerCallableStatement(this, sql, nType, nConcur, stmtColEncSetiing);
- // Make sure SQLServerCallableStatement42 is used for 4.2 and above
- if (Util.use42Wrapper() || Util.use43Wrapper()) {
- st = new SQLServerCallableStatement42(this, sql, nType, nConcur, stmtColEncSetiing);
- }
- else {
- st = new SQLServerCallableStatement(this, sql, nType, nConcur, stmtColEncSetiing);
+ if (requestStarted) {
+ addOpenStatement(st);
}
loggerExternal.exiting(getClassNameLogging(), "prepareCall", st);
@@ -4701,7 +4792,8 @@ public CallableStatement prepareCall(String sql,
/* JDBC 3.0 Auto generated keys */
- /* L3 */ public PreparedStatement prepareStatement(String sql,
+ @Override
+ public PreparedStatement prepareStatement(String sql,
int flag) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {sql, flag});
@@ -4712,33 +4804,7 @@ public CallableStatement prepareCall(String sql,
return ps;
}
- /**
- * Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the
- * driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an
- * INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param flag
- * a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or
- * Statement.NO_GENERATED_KEYS
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning
- * auto-generated keys
- * @throws SQLServerException
- * if a database access error occurs, this method is called on a closed connection or the given parameter is not a
- * Statement constant indicating whether auto-generated keys should be returned
- */
+ @Override
public PreparedStatement prepareStatement(String sql,
int flag,
SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
@@ -4751,7 +4817,8 @@ public PreparedStatement prepareStatement(String sql,
return ps;
}
- /* L3 */ public PreparedStatement prepareStatement(String sql,
+ @Override
+ public PreparedStatement prepareStatement(String sql,
int[] columnIndexes) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {sql, columnIndexes});
SQLServerPreparedStatement ps = (SQLServerPreparedStatement) prepareStatement(sql, columnIndexes,
@@ -4761,35 +4828,7 @@ public PreparedStatement prepareStatement(String sql,
return ps;
}
- /**
- * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
- * contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will
- * ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list
- * of such statements is vendor-specific).
- *
- * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param columnIndexes
- * an array of column indexes indicating the columns that should be returned from the inserted row or rows
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
- * keys designated by the given array of column indexes
- * @throws SQLServerException
- * if a database access error occurs or this method is called on a closed connection
- */
+ @Override
public PreparedStatement prepareStatement(String sql,
int[] columnIndexes,
SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
@@ -4806,7 +4845,8 @@ public PreparedStatement prepareStatement(String sql,
return ps;
}
- /* L3 */ public PreparedStatement prepareStatement(String sql,
+ @Override
+ public PreparedStatement prepareStatement(String sql,
String[] columnNames) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[] {sql, columnNames});
@@ -4817,35 +4857,7 @@ public PreparedStatement prepareStatement(String sql,
return ps;
}
- /**
- * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
- * contains the names of the columns in the target table that contain the auto-generated keys that should be returned. The driver will ignore the
- * array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such
- * statements is vendor-specific).
- *
- * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param columnNames
- * an array of column names indicating the columns that should be returned from the inserted row or rows
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
- * keys designated by the given array of column names
- * @throws SQLServerException
- * if a database access error occurs or this method is called on a closed connection
- */
+ @Override
public PreparedStatement prepareStatement(String sql,
String[] columnNames,
SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
@@ -4863,9 +4875,10 @@ public PreparedStatement prepareStatement(String sql,
/* JDBC 3.0 Savepoints */
- public void releaseSavepoint(Savepoint savepoint) throws SQLServerException {
+ @Override
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "releaseSavepoint", savepoint);
- NotImplemented();
+ SQLServerException.throwNotSupportedException(this, null);
}
final private Savepoint setNamedSavepoint(String sName) throws SQLServerException {
@@ -4888,7 +4901,8 @@ final private Savepoint setNamedSavepoint(String sName) throws SQLServerExceptio
return s;
}
- /* L3 */ public Savepoint setSavepoint(String sName) throws SQLServerException {
+ @Override
+ public Savepoint setSavepoint(String sName) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "setSavepoint", sName);
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
@@ -4899,7 +4913,8 @@ final private Savepoint setNamedSavepoint(String sName) throws SQLServerExceptio
return pt;
}
- /* L3 */ public Savepoint setSavepoint() throws SQLServerException {
+ @Override
+ public Savepoint setSavepoint() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "setSavepoint");
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
@@ -4910,7 +4925,8 @@ final private Savepoint setNamedSavepoint(String sName) throws SQLServerExceptio
return pt;
}
- /* L3 */ public void rollback(Savepoint s) throws SQLServerException {
+ @Override
+ public void rollback(Savepoint s) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "rollback", s);
if (loggerExternal.isLoggable(Level.FINER) && Util.IsActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
@@ -4923,13 +4939,15 @@ final private Savepoint setNamedSavepoint(String sName) throws SQLServerExceptio
loggerExternal.exiting(getClassNameLogging(), "rollback");
}
- /* L3 */ public int getHoldability() throws SQLServerException {
+ @Override
+ public int getHoldability() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getHoldability");
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.exiting(getClassNameLogging(), "getHoldability", holdability);
return holdability;
}
+ @Override
public void setHoldability(int holdability) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "setHoldability", holdability);
@@ -4952,6 +4970,7 @@ public void setHoldability(int holdability) throws SQLServerException {
loggerExternal.exiting(getClassNameLogging(), "setHoldability");
}
+ @Override
public int getNetworkTimeout() throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getNetworkTimeout");
@@ -4969,6 +4988,7 @@ public int getNetworkTimeout() throws SQLException {
return timeout;
}
+ @Override
public void setNetworkTimeout(Executor executor,
int timeout) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "setNetworkTimeout", timeout);
@@ -4980,7 +5000,7 @@ public void setNetworkTimeout(Executor executor,
}
checkClosed();
-
+
// check for setNetworkTimeout permission
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
@@ -5005,6 +5025,7 @@ public void setNetworkTimeout(Executor executor,
loggerExternal.exiting(getClassNameLogging(), "setNetworkTimeout");
}
+ @Override
public String getSchema() throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getSchema");
@@ -5044,6 +5065,7 @@ public String getSchema() throws SQLException {
return null;
}
+ @Override
public void setSchema(String schema) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "setSchema", schema);
checkClosed();
@@ -5052,61 +5074,58 @@ public void setSchema(String schema) throws SQLException {
loggerExternal.exiting(getClassNameLogging(), "setSchema");
}
- /**
- * Modifies the setting of the sendTimeAsDatetime connection property. When true, java.sql.Time values will be sent to the server as SQL
- * Serverdatetime values. When false, java.sql.Time values will be sent to the server as SQL Servertime values. sendTimeAsDatetime can also be
- * modified programmatically with SQLServerDataSource.setSendTimeAsDatetime. The default value for this property may change in a future release.
- *
- * @param sendTimeAsDateTimeValue
- * enables/disables setting the sendTimeAsDatetime connection property. For more information about how the Microsoft JDBC Driver for
- * SQL Server configures java.sql.Time values before sending them to the server, see
- * Configuring How java.sql.Time Values are Sent to the
- * Server.
- */
- public synchronized void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) {
+ @Override
+ public void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) {
sendTimeAsDatetime = sendTimeAsDateTimeValue;
}
+ @Override
public java.sql.Array createArrayOf(String typeName,
Object[] elements) throws SQLException {
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwNotSupportedException(this, null);
+ return null;
}
- public Blob createBlob() throws SQLException {
+ @Override
+ public java.sql.Blob createBlob() throws SQLException {
checkClosed();
return new SQLServerBlob(this);
}
- public Clob createClob() throws SQLException {
+ @Override
+ public java.sql.Clob createClob() throws SQLException {
checkClosed();
return new SQLServerClob(this);
}
- public NClob createNClob() throws SQLException {
+ @Override
+ public java.sql.NClob createNClob() throws SQLException {
checkClosed();
return new SQLServerNClob(this);
}
+ @Override
public SQLXML createSQLXML() throws SQLException {
loggerExternal.entering(getClassNameLogging(), "createSQLXML");
- SQLXML sqlxml = new SQLServerSQLXML(this);
+ SQLXML sqlxml = new SQLServerSQLXML(this);
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.exiting(getClassNameLogging(), "createSQLXML", sqlxml);
return sqlxml;
}
- public Struct createStruct(String typeName,
+ @Override
+ public java.sql.Struct createStruct(String typeName,
Object[] attributes) throws SQLException {
- // Not implemented
- throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));
+ SQLServerException.throwNotSupportedException(this, null);
+ return null;
}
String getTrustedServerNameAE() throws SQLServerException {
return trustedServerNameAE.toUpperCase();
}
+ @Override
public Properties getClientInfo() throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getClientInfo");
checkClosed();
@@ -5115,6 +5134,7 @@ public Properties getClientInfo() throws SQLException {
return p;
}
+ @Override
public String getClientInfo(String name) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "getClientInfo", name);
checkClosed();
@@ -5122,6 +5142,7 @@ public String getClientInfo(String name) throws SQLException {
return null;
}
+ @Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
loggerExternal.entering(getClassNameLogging(), "setClientInfo", properties);
// This function is only marked as throwing only SQLClientInfoException so the conversion is necessary
@@ -5145,6 +5166,7 @@ public void setClientInfo(Properties properties) throws SQLClientInfoException {
loggerExternal.exiting(getClassNameLogging(), "setClientInfo");
}
+ @Override
public void setClientInfo(String name,
String value) throws SQLClientInfoException {
loggerExternal.entering(getClassNameLogging(), "setClientInfo", new Object[] {name, value});
@@ -5181,6 +5203,7 @@ public void setClientInfo(String name,
* @throws SQLException
* if the value supplied for the timeout is less than 0.
*/
+ @Override
public boolean isValid(int timeout) throws SQLException {
boolean isValid = false;
@@ -5224,6 +5247,7 @@ public boolean isValid(int timeout) throws SQLException {
return isValid;
}
+ @Override
public boolean isWrapperFor(Class> iface) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "isWrapperFor", iface);
boolean f = iface.isInstance(this);
@@ -5231,6 +5255,7 @@ public boolean isWrapperFor(Class> iface) throws SQLException {
return f;
}
+ @Override
public T unwrap(Class iface) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "unwrap", iface);
T t;
@@ -5246,14 +5271,91 @@ public T unwrap(Class iface) throws SQLException {
return t;
}
- public void beginRequest() throws SQLFeatureNotSupportedException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLFeatureNotSupportedException("beginRequest not implemented");
- }
-
- public void endRequest() throws SQLFeatureNotSupportedException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLFeatureNotSupportedException("endRequest not implemented");
+ private boolean requestStarted = false;
+ private boolean originalDatabaseAutoCommitMode;
+ private int originalTransactionIsolationLevel;
+ private int originalNetworkTimeout;
+ private int originalHoldability;
+ private boolean originalSendTimeAsDatetime;
+ private int originalStatementPoolingCacheSize;
+ private boolean originalDisableStatementPooling;
+ private int originalServerPreparedStatementDiscardThreshold;
+ private Boolean originalEnablePrepareOnFirstPreparedStatementCall;
+ private String originalSCatalog;
+ private volatile SQLWarning originalSqlWarnings;
+ private List openStatements;
+
+ protected void beginRequestInternal() throws SQLException {
+ loggerExternal.entering(getClassNameLogging(), "beginRequest", this);
+ synchronized (this) {
+ if (!requestStarted) {
+ originalDatabaseAutoCommitMode = databaseAutoCommitMode;
+ originalTransactionIsolationLevel = transactionIsolationLevel;
+ originalNetworkTimeout = getNetworkTimeout();
+ originalHoldability = holdability;
+ originalSendTimeAsDatetime = sendTimeAsDatetime;
+ originalStatementPoolingCacheSize = statementPoolingCacheSize;
+ originalDisableStatementPooling = disableStatementPooling;
+ originalServerPreparedStatementDiscardThreshold = getServerPreparedStatementDiscardThreshold();
+ originalEnablePrepareOnFirstPreparedStatementCall = getEnablePrepareOnFirstPreparedStatementCall();
+ originalSCatalog = sCatalog;
+ originalSqlWarnings = sqlWarnings;
+ openStatements = new LinkedList();
+ requestStarted = true;
+ }
+ }
+ loggerExternal.exiting(getClassNameLogging(), "beginRequest", this);
+ }
+
+ protected void endRequestInternal() throws SQLException {
+ loggerExternal.entering(getClassNameLogging(), "endRequest", this);
+ synchronized (this) {
+ if (requestStarted) {
+ if (!databaseAutoCommitMode) {
+ rollback();
+ }
+ if (databaseAutoCommitMode != originalDatabaseAutoCommitMode) {
+ setAutoCommit(originalDatabaseAutoCommitMode);
+ }
+ if (transactionIsolationLevel != originalTransactionIsolationLevel) {
+ setTransactionIsolation(originalTransactionIsolationLevel);
+ }
+ if (getNetworkTimeout() != originalNetworkTimeout) {
+ setNetworkTimeout(null, originalNetworkTimeout);
+ }
+ if (holdability != originalHoldability) {
+ setHoldability(originalHoldability);
+ }
+ if (sendTimeAsDatetime != originalSendTimeAsDatetime) {
+ setSendTimeAsDatetime(originalSendTimeAsDatetime);
+ }
+ if (statementPoolingCacheSize != originalStatementPoolingCacheSize) {
+ setStatementPoolingCacheSize(originalStatementPoolingCacheSize);
+ }
+ if (disableStatementPooling != originalDisableStatementPooling) {
+ setDisableStatementPooling(originalDisableStatementPooling);
+ }
+ if (getServerPreparedStatementDiscardThreshold() != originalServerPreparedStatementDiscardThreshold) {
+ setServerPreparedStatementDiscardThreshold(originalServerPreparedStatementDiscardThreshold);
+ }
+ if (getEnablePrepareOnFirstPreparedStatementCall() != originalEnablePrepareOnFirstPreparedStatementCall) {
+ setEnablePrepareOnFirstPreparedStatementCall(originalEnablePrepareOnFirstPreparedStatementCall);
+ }
+ if (!sCatalog.equals(originalSCatalog)) {
+ setCatalog(originalSCatalog);
+ }
+ sqlWarnings = originalSqlWarnings;
+ if (null != openStatements) {
+ while (!openStatements.isEmpty()) {
+ try (Statement st = openStatements.get(0)) {
+ }
+ }
+ openStatements.clear();
+ }
+ requestStarted = false;
+ }
+ }
+ loggerExternal.exiting(getClassNameLogging(), "endRequest", this);
}
/**
@@ -5266,7 +5368,7 @@ public void endRequest() throws SQLFeatureNotSupportedException {
*/
static final char[] OUT = {' ', 'O', 'U', 'T'};
- /* L0 */ String replaceParameterMarkers(String sqlSrc,
+ String replaceParameterMarkers(String sqlSrc,
Parameter[] params,
boolean isReturnValueSyntax) throws SQLServerException {
final int MAX_PARAM_NAME_LEN = 6;
@@ -5311,7 +5413,7 @@ public void endRequest() throws SQLFeatureNotSupportedException {
* @param offset
* @return int
*/
- /* L0 */ static int makeParamName(int nParam,
+ static int makeParamName(int nParam,
char[] name,
int offset) {
name[offset + 0] = '@';
@@ -5449,8 +5551,7 @@ String getInstancePort(String server,
datagramSocket.receive(udpResponse);
browserResult = new String(receiveBuffer, 3, receiveBuffer.length - 3);
if (connectionlogger.isLoggable(Level.FINER))
- connectionlogger.fine(
- toString() + " Received SSRP UDP response from IP address: " + udpResponse.getAddress().getHostAddress());
+ connectionlogger.fine(toString() + " Received SSRP UDP response from IP address: " + udpResponse.getAddress().getHostAddress());
}
catch (IOException ioException) {
// Warn and retry
@@ -5484,7 +5585,7 @@ String getInstancePort(String server,
return browserResult.substring(p1, p2);
}
- /* L0 */ int getNextSavepointId() {
+ int getNextSavepointId() {
nNextSavePointId++; // Make them unique for this connection
return nNextSavePointId;
}
@@ -5525,16 +5626,15 @@ public static synchronized void setColumnEncryptionKeyCacheTtl(int columnEncrypt
static synchronized long getColumnEncryptionKeyCacheTtl() {
return columnEncryptionKeyCacheTtl;
}
-
/**
* Enqueue a discarded prepared statement handle to be clean-up on the server.
*
* @param statementHandle
- * The prepared statement handle that should be scheduled for unprepare.
+ * The prepared statement handle that should be scheduled for unprepare.
*/
final void enqueueUnprepareStatementHandle(PreparedStatementHandle statementHandle) {
- if(null == statementHandle)
+ if (null == statementHandle)
return;
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
@@ -5545,19 +5645,12 @@ final void enqueueUnprepareStatementHandle(PreparedStatementHandle statementHand
this.discardedPreparedStatementHandleCount.incrementAndGet();
}
-
- /**
- * Returns the number of currently outstanding prepared statement un-prepare actions.
- *
- * @return Returns the current value per the description.
- */
+ @Override
public int getDiscardedServerPreparedStatementCount() {
return this.discardedPreparedStatementHandleCount.get();
}
- /**
- * Forces the un-prepare requests for any outstanding discarded prepared statements to be executed.
- */
+ @Override
public void closeUnreferencedPreparedStatementHandles() {
this.unprepareUnreferencedPreparedStatementHandles(true);
}
@@ -5570,43 +5663,20 @@ private final void cleanupPreparedStatementDiscardActions() {
discardedPreparedStatementHandleCount.set(0);
}
- /**
- * Returns the behavior for a specific connection instance. If false the first execution will call sp_executesql and not prepare
- * a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following
- * executions will call sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only
- * executed once. The default for this option can be changed by calling setDefaultEnablePrepareOnFirstPreparedStatementCall().
- *
- * @return Returns the current setting per the description.
- */
+ @Override
public boolean getEnablePrepareOnFirstPreparedStatementCall() {
- if(null == this.enablePrepareOnFirstPreparedStatementCall)
+ if (null == this.enablePrepareOnFirstPreparedStatementCall)
return DEFAULT_ENABLE_PREPARE_ON_FIRST_PREPARED_STATEMENT_CALL;
else
- return this.enablePrepareOnFirstPreparedStatementCall;
+ return this.enablePrepareOnFirstPreparedStatementCall;
}
- /**
- * Specifies the behavior for a specific connection instance. If value is false the first execution will call sp_executesql and not prepare
- * a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following
- * executions will call sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only
- * executed once.
- *
- * @param value
- * Changes the setting per the description.
- */
+ @Override
public void setEnablePrepareOnFirstPreparedStatementCall(boolean value) {
this.enablePrepareOnFirstPreparedStatementCall = value;
}
- /**
- * Returns the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions
- * (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is
- * {@literal <=} 1, unprepare actions will be executed immedietely on prepared statement close. If it is set to {@literal >} 1, these calls
- * will be batched together to avoid overhead of calling sp_unprepare too often. The default for this option can be changed by calling
- * getDefaultServerPreparedStatementDiscardThreshold().
- *
- * @return Returns the current setting per the description.
- */
+ @Override
public int getServerPreparedStatementDiscardThreshold() {
if (0 > this.serverPreparedStatementDiscardThreshold)
return DEFAULT_SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD;
@@ -5614,32 +5684,24 @@ public int getServerPreparedStatementDiscardThreshold() {
return this.serverPreparedStatementDiscardThreshold;
}
- /**
- * Specifies the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions
- * (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is
- * {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to {@literal >} 1 these calls will be
- * batched together to avoid overhead of calling sp_unprepare too often.
- *
- * @param value
- * Changes the setting per the description.
- */
+ @Override
public void setServerPreparedStatementDiscardThreshold(int value) {
this.serverPreparedStatementDiscardThreshold = Math.max(0, value);
}
final boolean isPreparedStatementUnprepareBatchingEnabled() {
- return 1 < getServerPreparedStatementDiscardThreshold();
+ return 1 < getServerPreparedStatementDiscardThreshold();
}
/**
* Cleans-up discarded prepared statement handles on the server using batched un-prepare actions if the batching threshold has been reached.
*
- * @param force
- * When force is set to true we ignore the current threshold for if the discard actions should run and run them anyway.
+ * @param force
+ * When force is set to true we ignore the current threshold for if the discard actions should run and run them anyway.
*/
final void unprepareUnreferencedPreparedStatementHandles(boolean force) {
// Skip out if session is unavailable to adhere to previous non-batched behavior.
- if (isSessionUnAvailable())
+ if (isSessionUnAvailable())
return;
final int threshold = getServerPreparedStatementDiscardThreshold();
@@ -5648,33 +5710,32 @@ final void unprepareUnreferencedPreparedStatementHandles(boolean force) {
if (force || threshold < getDiscardedServerPreparedStatementCount()) {
// Create batch of sp_unprepare statements.
- StringBuilder sql = new StringBuilder(threshold * 32/*EXEC sp_cursorunprepare++;*/);
+ StringBuilder sql = new StringBuilder(threshold * 32/* EXEC sp_cursorunprepare++; */);
// Build the string containing no more than the # of handles to remove.
- // Note that sp_unprepare can fail if the statement is already removed.
- // However, the server will only abort that statement and continue with
+ // Note that sp_unprepare can fail if the statement is already removed.
+ // However, the server will only abort that statement and continue with
// the remaining clean-up.
int handlesRemoved = 0;
PreparedStatementHandle statementHandle = null;
- while (null != (statementHandle = discardedPreparedStatementHandles.poll())){
+ while (null != (statementHandle = discardedPreparedStatementHandles.poll())) {
++handlesRemoved;
-
- sql.append(statementHandle.isDirectSql() ? "EXEC sp_unprepare " : "EXEC sp_cursorunprepare ")
- .append(statementHandle.getHandle())
- .append(';');
+
+ sql.append(statementHandle.isDirectSql() ? "EXEC sp_unprepare " : "EXEC sp_cursorunprepare ").append(statementHandle.getHandle())
+ .append(';');
}
try {
// Execute the batched set.
- try(Statement stmt = this.createStatement()) {
+ try (Statement stmt = this.createStatement()) {
stmt.execute(sql.toString());
}
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.finer(this + ": Finished un-preparing handle count:" + handlesRemoved);
}
- catch(SQLException e) {
+ catch (SQLException e) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.log(Level.FINER, this + ": Error batch-closing at least one prepared handle", e);
}
@@ -5684,61 +5745,38 @@ final void unprepareUnreferencedPreparedStatementHandles(boolean force) {
}
}
- /**
- * Returns true if statement pooling is disabled.
- *
- * @return
- */
+ @Override
public boolean getDisableStatementPooling() {
return this.disableStatementPooling;
}
- /**
- * Sets statement pooling to true or false;
- *
- * @param value
- */
+ @Override
public void setDisableStatementPooling(boolean value) {
this.disableStatementPooling = value;
if (!value && 0 < this.getStatementPoolingCacheSize()) {
prepareCache();
}
}
-
- /**
- * Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
- * @return Returns the current setting per the description.
- */
+
+ @Override
public int getStatementPoolingCacheSize() {
return statementPoolingCacheSize;
- }
+ }
- /**
- * Returns the current number of pooled prepared statement handles.
- * @return Returns the current setting per the description.
- */
+ @Override
public int getStatementHandleCacheEntryCount() {
- if(!isStatementPoolingEnabled())
+ if (!isStatementPoolingEnabled())
return 0;
else
return this.preparedStatementHandleCache.size();
}
- /**
- * Whether statement pooling is enabled or not for this connection.
- * @return Returns the current setting per the description.
- */
+ @Override
public boolean isStatementPoolingEnabled() {
return null != preparedStatementHandleCache && 0 < this.getStatementPoolingCacheSize() && !this.getDisableStatementPooling();
}
- /**
- * Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache.
- *
- * @param value
- * The new cache size.
- *
- */
+ @Override
public void setStatementPoolingCacheSize(int value) {
value = Math.max(0, value);
statementPoolingCacheSize = value;
@@ -5755,6 +5793,7 @@ public void setStatementPoolingCacheSize(int value) {
/**
* Internal method to prepare the cache handle
+ *
* @param value
*/
private void prepareCache() {
@@ -5767,33 +5806,36 @@ private void prepareCache() {
/** Get a parameter metadata cache entry if statement pooling is enabled */
final SQLServerParameterMetaData getCachedParameterMetadata(Sha1HashKey key) {
- if(!isStatementPoolingEnabled())
+ if (!isStatementPoolingEnabled())
return null;
-
+
return parameterMetadataCache.get(key);
}
/** Register a parameter metadata cache entry if statement pooling is enabled */
- final void registerCachedParameterMetadata(Sha1HashKey key, SQLServerParameterMetaData pmd) {
- if(!isStatementPoolingEnabled() || null == pmd)
+ final void registerCachedParameterMetadata(Sha1HashKey key,
+ SQLServerParameterMetaData pmd) {
+ if (!isStatementPoolingEnabled() || null == pmd)
return;
-
+
parameterMetadataCache.put(key, pmd);
}
/** Get or create prepared statement handle cache entry if statement pooling is enabled */
final PreparedStatementHandle getCachedPreparedStatementHandle(Sha1HashKey key) {
- if(!isStatementPoolingEnabled())
+ if (!isStatementPoolingEnabled())
return null;
-
+
return preparedStatementHandleCache.get(key);
}
/** Get or create prepared statement handle cache entry if statement pooling is enabled */
- final PreparedStatementHandle registerCachedPreparedStatementHandle(Sha1HashKey key, int handle, boolean isDirectSql) {
- if(!isStatementPoolingEnabled() || null == key)
+ final PreparedStatementHandle registerCachedPreparedStatementHandle(Sha1HashKey key,
+ int handle,
+ boolean isDirectSql) {
+ if (!isStatementPoolingEnabled() || null == key)
return null;
-
+
PreparedStatementHandle cacheItem = new PreparedStatementHandle(key, handle, isDirectSql, false);
preparedStatementHandleCache.putIfAbsent(key, cacheItem);
return cacheItem;
@@ -5809,26 +5851,74 @@ final void returnCachedPreparedStatementHandle(PreparedStatementHandle handle) {
/** Force eviction of prepared statement handle cache entry. */
final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) {
- if(null == handle || null == handle.getKey())
- return;
-
- preparedStatementHandleCache.remove(handle.getKey());
+ if (null == handle || null == handle.getKey())
+ return;
+
+ preparedStatementHandleCache.remove(handle.getKey());
}
// Handle closing handles when removed from cache.
final class PreparedStatementCacheEvictionListener implements EvictionListener {
- public void onEviction(Sha1HashKey key, PreparedStatementHandle handle) {
- if(null != handle) {
+ public void onEviction(Sha1HashKey key,
+ PreparedStatementHandle handle) {
+ if (null != handle) {
handle.setIsEvictedFromCache(true); // Mark as evicted from cache.
// Only discard if not referenced.
- if(handle.tryDiscardHandle()) {
+ if (handle.tryDiscardHandle()) {
enqueueUnprepareStatementHandle(handle);
// Do not run discard actions here! Can interfere with executing statement.
- }
+ }
}
}
}
+
+ boolean isAzureDW() throws SQLServerException, SQLException {
+ if (null == isAzureDW) {
+ try (Statement stmt = this.createStatement(); ResultSet rs = stmt.executeQuery("SELECT CAST(SERVERPROPERTY('EngineEdition') as INT)");)
+ {
+ // SERVERPROPERTY('EngineEdition') can be used to determine whether the db server is SQL Azure.
+ // It should return 6 for SQL Azure DW. This is more reliable than @@version or serverproperty('edition').
+ // Reference: http://msdn.microsoft.com/en-us/library/ee336261.aspx
+ //
+ // SERVERPROPERTY('EngineEdition') means
+ // Database Engine edition of the instance of SQL Server installed on the server.
+ // 1 = Personal or Desktop Engine (Not available for SQL Server.)
+ // 2 = Standard (This is returned for Standard and Workgroup.)
+ // 3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and Developer.)
+ // 4 = Express (This is returned for Express, Express with Advanced Services, and Windows Embedded SQL.)
+ // 5 = SQL Azure
+ // 6 = SQL Azure DW
+ // Base data type: int
+ final int ENGINE_EDITION_FOR_SQL_AZURE_DW = 6;
+ rs.next();
+ isAzureDW = (rs.getInt(1) == ENGINE_EDITION_FOR_SQL_AZURE_DW) ? true : false;
+ }
+ return isAzureDW;
+ } else {
+ return isAzureDW;
+ }
+ }
+
+ /**
+ * @param st
+ * Statement to add to openStatements
+ */
+ final synchronized void addOpenStatement(Statement st) {
+ if (null != openStatements) {
+ openStatements.add(st);
+ }
+ }
+
+ /**
+ * @param st
+ * Statement to remove from openStatements
+ */
+ final synchronized void removeOpenStatement(Statement st) {
+ if (null != openStatements) {
+ openStatements.remove(st);
+ }
+ }
}
// Helper class for security manager functions used by SQLServerConnection class.
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java
index 217bcfc72d..27c782c0cc 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java
@@ -1,36 +1,64 @@
+/*
+ * 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.
+ */
+
package com.microsoft.sqlserver.jdbc;
-import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLException;
import java.sql.ShardingKey;
+/**
+ * SQLServerConnection43 extends {@link SQLServerConnection43} class and implements {@link ISQLServerConnection43} with methods introduced in JDBC 4.3
+ * Specifications. This class is used by the drdiver when initializing a class with 43 driver version
+ */
public class SQLServerConnection43 extends SQLServerConnection implements ISQLServerConnection43 {
+ /**
+ * Always refresh SerialVersionUID when prompted
+ */
+ private static final long serialVersionUID = -6904163521498951547L;
+
SQLServerConnection43(String parentInfo) throws SQLServerException {
super(parentInfo);
}
-
- public void setShardingKey(ShardingKey shardingKey) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLServerException("setShardingKey not implemented", new SQLFeatureNotSupportedException("setShardingKey not implemented"));
+
+ @Override
+ public void beginRequest() throws SQLException {
+ beginRequestInternal();
+ }
+
+ @Override
+ public void endRequest() throws SQLException {
+ endRequestInternal();
+ }
+
+ @Override
+ public void setShardingKey(ShardingKey shardingKey) throws SQLException {
+ SQLServerException.throwFeatureNotSupportedException();
}
+ @Override
public void setShardingKey(ShardingKey shardingKey,
- ShardingKey superShardingKey) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLServerException("setShardingKey not implemented", new SQLFeatureNotSupportedException("setShardingKey not implemented")) ;
+ ShardingKey superShardingKey) throws SQLException {
+ SQLServerException.throwFeatureNotSupportedException();
}
+ @Override
public boolean setShardingKeyIfValid(ShardingKey shardingKey,
- int timeout) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLServerException("setShardingKeyIfValid not implemented", new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented"));
+ int timeout) throws SQLException {
+ SQLServerException.throwFeatureNotSupportedException();
+ return false;
}
+ @Override
public boolean setShardingKeyIfValid(ShardingKey shardingKey,
ShardingKey superShardingKey,
- int timeout) throws SQLServerException {
- DriverJDBCVersion.checkSupportsJDBC43();
- throw new SQLServerException("setShardingKeyIfValid not implemented", new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented"));
+ int timeout) throws SQLException {
+ SQLServerException.throwFeatureNotSupportedException();
+ return false;
}
-
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
index 798a6b0361..50115cd05d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
@@ -21,10 +21,10 @@
* physical connections. For example, J2EE application servers that provide JDBC 3.0 API spec connection pooling.
*
*/
-
public class SQLServerConnectionPoolDataSource extends SQLServerDataSource implements ConnectionPoolDataSource {
// Get a new physical connection that the pool manager will issue logical connections from
- /* L0 */ public PooledConnection getPooledConnection() throws SQLException {
+ @Override
+ public PooledConnection getPooledConnection() throws SQLException {
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getPooledConnection");
PooledConnection pcon = getPooledConnection(getUser(), getPassword());
@@ -33,7 +33,8 @@ public class SQLServerConnectionPoolDataSource extends SQLServerDataSource imple
return pcon;
}
- /* L0 */ public PooledConnection getPooledConnection(String user,
+ @Override
+ public PooledConnection getPooledConnection(String user,
String password) throws SQLException {
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getPooledConnection", new Object[] {user, "Password not traced"});
@@ -45,6 +46,7 @@ public class SQLServerConnectionPoolDataSource extends SQLServerDataSource imple
// Implement javax.naming.Referenceable interface methods.
+ @Override
public Reference getReference() {
if (loggerExternal.isLoggable(Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getReference");
@@ -82,5 +84,4 @@ private Object readResolve() {
return ds;
}
}
-
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java
index 80d3a234d9..cca04ad762 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java
@@ -1,689 +1,615 @@
-/*
- * 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.
- */
-
-package com.microsoft.sqlserver.jdbc;
-
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.DatabaseMetaData;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLPermission;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.text.MessageFormat;
-import java.util.Properties;
-import java.util.UUID;
-import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-
-/**
- * SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. When returning a connection object from PooledConnection.getConnection
- * we return this proxy per SPEC.
- *
- * This class's public functions need to be kept identical to the SQLServerConnection's.
- *
- * The API javadoc for JDBC API methods that this class implements are not repeated here. Please see Sun's JDBC API interfaces javadoc for those
- * details.
- */
-
-class SQLServerConnectionPoolProxy implements ISQLServerConnection {
- private SQLServerConnection wrappedConnection;
- private boolean bIsOpen;
- static private final AtomicInteger baseConnectionID = new AtomicInteger(0); // connection id dispenser
- final private String traceID;
-
- // Permission targets
- // currently only callAbort is implemented
- private static final String callAbortPerm = "callAbort";
-
- /**
- * Generate the next unique connection id.
- *
- * @return the next conn id
- */
- /* L0 */ private static int nextConnectionID() {
- return baseConnectionID.incrementAndGet();
- }
-
- public String toString() {
- return traceID;
- }
-
- /* L0 */ SQLServerConnectionPoolProxy(SQLServerConnection con) {
- traceID = " ProxyConnectionID:" + nextConnectionID();
- wrappedConnection = con;
- // the Proxy is created with an open conn
- con.setAssociatedProxy(this);
- bIsOpen = true;
- }
-
- /* L0 */ void checkClosed() throws SQLServerException {
- if (!bIsOpen) {
- SQLServerException.makeFromDriverError(null, null, SQLServerException.getErrString("R_connectionIsClosed"), null, false);
- }
- }
-
- /* L0 */ public Statement createStatement() throws SQLServerException {
- checkClosed();
- return wrappedConnection.createStatement();
- }
-
- /* L0 */ public PreparedStatement prepareStatement(String sql) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql);
- }
-
- /* L0 */ public CallableStatement prepareCall(String sql) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareCall(sql);
- }
-
- /* L0 */ public String nativeSQL(String sql) throws SQLServerException {
- checkClosed();
- return wrappedConnection.nativeSQL(sql);
- }
-
- public void setAutoCommit(boolean newAutoCommitMode) throws SQLServerException {
- checkClosed();
- wrappedConnection.setAutoCommit(newAutoCommitMode);
- }
-
- /* L0 */ public boolean getAutoCommit() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getAutoCommit();
- }
-
- public void commit() throws SQLServerException {
- checkClosed();
- wrappedConnection.commit();
- }
-
- /**
- * Rollback a transaction.
- *
- * @throws SQLServerException
- * if no transaction exists or if the connection is in auto-commit mode.
- */
- public void rollback() throws SQLServerException {
- checkClosed();
- wrappedConnection.rollback();
- }
-
- public void abort(Executor executor) throws SQLException {
- if (!bIsOpen || (null == wrappedConnection))
- return;
-
- if (null == executor) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidArgument"));
- Object[] msgArgs = {"executor"};
- SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, false);
- }
-
- // check for callAbort permission
- SecurityManager secMgr = System.getSecurityManager();
- if (secMgr != null) {
- try {
- SQLPermission perm = new SQLPermission(callAbortPerm);
- secMgr.checkPermission(perm);
- }
- catch (SecurityException ex) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_permissionDenied"));
- Object[] msgArgs = {callAbortPerm};
- throw new SQLServerException(form.format(msgArgs), null, 0, ex);
- }
- }
-
- bIsOpen = false;
-
- executor.execute(new Runnable() {
- public void run() {
- if (wrappedConnection.getConnectionLogger().isLoggable(Level.FINER))
- wrappedConnection.getConnectionLogger().finer(toString() + " Connection proxy aborted ");
- try {
- wrappedConnection.poolCloseEventNotify();
- wrappedConnection = null;
- }
- catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
- });
- }
-
- /* L0 */ public void close() throws SQLServerException {
- if (bIsOpen && (null != wrappedConnection)) {
- if (wrappedConnection.getConnectionLogger().isLoggable(Level.FINER))
- wrappedConnection.getConnectionLogger().finer(toString() + " Connection proxy closed ");
-
- wrappedConnection.poolCloseEventNotify();
- wrappedConnection = null;
- }
- bIsOpen = false;
- }
-
- /* L0 */ void internalClose() {
- bIsOpen = false;
- wrappedConnection = null;
- }
-
- /* L0 */ public boolean isClosed() throws SQLServerException {
- return !bIsOpen;
- }
-
- /* L0 */ public DatabaseMetaData getMetaData() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getMetaData();
- }
-
- /* L0 */ public void setReadOnly(boolean readOnly) throws SQLServerException {
- checkClosed();
- wrappedConnection.setReadOnly(readOnly);
- }
-
- /* L0 */ public boolean isReadOnly() throws SQLServerException {
- checkClosed();
- return wrappedConnection.isReadOnly();
- }
-
- /* L0 */ public void setCatalog(String catalog) throws SQLServerException {
- checkClosed();
- wrappedConnection.setCatalog(catalog);
- }
-
- /* L0 */ public String getCatalog() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getCatalog();
- }
-
- /* L0 */ public void setTransactionIsolation(int level) throws SQLServerException {
- checkClosed();
- wrappedConnection.setTransactionIsolation(level);
- }
-
- /* L0 */ public int getTransactionIsolation() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getTransactionIsolation();
- }
-
- /* L0 */ public SQLWarning getWarnings() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getWarnings(); // Warnings support added
- }
-
- /* L2 */ public void clearWarnings() throws SQLServerException {
- checkClosed();
- wrappedConnection.clearWarnings();
- }
-
- // --------------------------JDBC 2.0-----------------------------
-
- /* L2 */ public Statement createStatement(int resultSetType,
- int resultSetConcurrency) throws SQLException {
- checkClosed();
- return wrappedConnection.createStatement(resultSetType, resultSetConcurrency);
- }
-
- /* L2 */ public PreparedStatement prepareStatement(String sSql,
- int resultSetType,
- int resultSetConcurrency) throws SQLException {
- checkClosed();
- return wrappedConnection.prepareStatement(sSql, resultSetType, resultSetConcurrency);
- }
-
- /* L2 */ public CallableStatement prepareCall(String sql,
- int resultSetType,
- int resultSetConcurrency) throws SQLException {
- checkClosed();
- return wrappedConnection.prepareCall(sql, resultSetType, resultSetConcurrency);
- }
-
- /* L2 */ public void setTypeMap(java.util.Map> map) throws SQLServerException {
- checkClosed();
- wrappedConnection.setTypeMap(map);
- }
-
- public java.util.Map> getTypeMap() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getTypeMap();
- }
-
- /* L3 */ public Statement createStatement(int nType,
- int nConcur,
- int nHold) throws SQLServerException {
- checkClosed();
- return wrappedConnection.createStatement(nType, nConcur, nHold);
- }
-
- /**
- * Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
- * This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and
- * holdability to be overridden.
- *
- * @param nType
- * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
- * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
- * @param nConcur
- * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
- * ResultSet.CONCUR_UPDATABLE
- * @param nHold
- * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
- * ResultSet.CLOSE_CURSORS_AT_COMMIT
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new Statement object that will generate ResultSet objects with the given type, concurrency, and holdability
- * @exception SQLException
- * if a database access error occurs, this method is called on a closed connection or the given parameters are not
- * ResultSet constants indicating type, concurrency, and holdability
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method or this method is not supported for the specified result set type, result set
- * holdability and result set concurrency.
- */
- public Statement createStatement(int nType,
- int nConcur,
- int nHold,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- checkClosed();
- return wrappedConnection.createStatement(nType, nConcur, nHold, stmtColEncSetting);
- }
-
- /* L3 */ public PreparedStatement prepareStatement(java.lang.String sql,
- int nType,
- int nConcur,
- int nHold) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, nType, nConcur, nHold);
- }
-
- /**
- * Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and
- * holdability.
- *
- * This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and
- * holdability to be overridden.
- *
- * @param sql
- * a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
- * @param nType
- * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
- * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
- * @param nConcur
- * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
- * ResultSet.CONCUR_UPDATABLE
- * @param nHold
- * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
- * ResultSet.CLOSE_CURSORS_AT_COMMIT
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will generate ResultSet
- * objects with the given type, concurrency, and holdability
- * @exception SQLException
- * if a database access error occurs, this method is called on a closed connection or the given parameters are not
- * ResultSet constants indicating type, concurrency, and holdability
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method or this method is not supported for the specified result set type, result set
- * holdability and result set concurrency.
- */
- public PreparedStatement prepareStatement(String sql,
- int nType,
- int nConcur,
- int nHold,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, nType, nConcur, nHold, stmtColEncSetting);
- }
-
- /* L3 */ public CallableStatement prepareCall(String sql,
- int nType,
- int nConcur,
- int nHold) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareCall(sql, nType, nConcur, nHold);
- }
-
- /**
- * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This
- * method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and
- * holdability to be overridden.
- *
- * @param sql
- * a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters
- * @param nType
- * one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
- * ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
- * @param nConcur
- * one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or
- * ResultSet.CONCUR_UPDATABLE
- * @param nHold
- * one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
- * ResultSet.CLOSE_CURSORS_AT_COMMIT
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet
- * objects with the given type, concurrency, and holdability
- * @exception SQLException
- * if a database access error occurs, this method is called on a closed connection or the given parameters are not
- * ResultSet constants indicating type, concurrency, and holdability
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method or this method is not supported for the specified result set type, result set
- * holdability and result set concurrency.
- */
- public CallableStatement prepareCall(String sql,
- int nType,
- int nConcur,
- int nHold,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetiing) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareCall(sql, nType, nConcur, nHold, stmtColEncSetiing);
- }
-
- /* JDBC 3.0 Auto generated keys */
-
- /* L3 */ public PreparedStatement prepareStatement(String sql,
- int flag) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, flag);
- }
-
- /**
- * Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the
- * driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an
- * INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param flag
- * a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or
- * Statement.NO_GENERATED_KEYS
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning
- * auto-generated keys
- * @exception SQLException
- * if a database access error occurs, this method is called on a closed connection or the given parameter is not a
- * Statement constant indicating whether auto-generated keys should be returned
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
- */
- public PreparedStatement prepareStatement(String sql,
- int flag,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, flag, stmtColEncSetting);
- }
-
- /* L3 */ public PreparedStatement prepareStatement(String sql,
- int[] columnIndexes) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, columnIndexes);
- }
-
- /**
- * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
- * contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will
- * ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list
- * of such statements is vendor-specific).
- *
- * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param columnIndexes
- * an array of column indexes indicating the columns that should be returned from the inserted row or rows
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
- * keys designated by the given array of column indexes
- * @exception SQLException
- * if a database access error occurs or this method is called on a closed connection
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- */
- public PreparedStatement prepareStatement(String sql,
- int[] columnIndexes,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, columnIndexes, stmtColEncSetting);
- }
-
- /* L3 */ public PreparedStatement prepareStatement(String sql,
- String[] columnNames) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, columnNames);
- }
-
- /**
- * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array
- * contains the names of the columns in the target table that contain the auto-generated keys that should be returned. The driver will ignore the
- * array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such
- * statements is vendor-specific).
- *
- * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports
- * precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not
- * support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is
- * executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
- *
- * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a
- * concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling
- * {@link #getHoldability}.
- *
- * @param sql
- * an SQL statement that may contain one or more '?' IN parameter placeholders
- * @param columnNames
- * an array of column names indicating the columns that should be returned from the inserted row or rows
- * @param stmtColEncSetting
- * Specifies how data will be sent and received when reading and writing encrypted columns.
- * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated
- * keys designated by the given array of column names
- * @exception SQLException
- * if a database access error occurs or this method is called on a closed connection
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- */
- public PreparedStatement prepareStatement(String sql,
- String[] columnNames,
- SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
- checkClosed();
- return wrappedConnection.prepareStatement(sql, columnNames, stmtColEncSetting);
- }
-
- /* JDBC 3.0 Savepoints */
-
- /* L3 */ public void releaseSavepoint(Savepoint savepoint) throws SQLServerException {
- checkClosed();
- wrappedConnection.releaseSavepoint(savepoint);
- }
-
- /* L3 */ public Savepoint setSavepoint(String sName) throws SQLServerException {
- checkClosed();
- return wrappedConnection.setSavepoint(sName);
- }
-
- /* L3 */ public Savepoint setSavepoint() throws SQLServerException {
- checkClosed();
- return wrappedConnection.setSavepoint();
- }
-
- /* L3 */ public void rollback(Savepoint s) throws SQLServerException {
- checkClosed();
- wrappedConnection.rollback(s);
- }
-
- /* L3 */ public int getHoldability() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getHoldability();
- }
-
- /* L3 */ public void setHoldability(int nNewHold) throws SQLServerException {
- checkClosed();
- wrappedConnection.setHoldability(nNewHold);
- }
-
- public int getNetworkTimeout() throws SQLException {
- checkClosed();
- return wrappedConnection.getNetworkTimeout();
- }
-
- public void setNetworkTimeout(Executor executor,
- int timeout) throws SQLException {
- checkClosed();
- wrappedConnection.setNetworkTimeout(executor, timeout);
- }
-
- public String getSchema() throws SQLException {
- checkClosed();
- return wrappedConnection.getSchema();
- }
-
- public void setSchema(String schema) throws SQLException {
- checkClosed();
- wrappedConnection.setSchema(schema);
- }
-
- public java.sql.Array createArrayOf(String typeName,
- Object[] elements) throws SQLException {
- checkClosed();
- return wrappedConnection.createArrayOf(typeName, elements);
- }
-
- public Blob createBlob() throws SQLException {
- checkClosed();
- return wrappedConnection.createBlob();
- }
-
- public Clob createClob() throws SQLException {
- checkClosed();
- return wrappedConnection.createClob();
- }
-
- public NClob createNClob() throws SQLException {
- checkClosed();
- return wrappedConnection.createNClob();
- }
-
- public SQLXML createSQLXML() throws SQLException {
- checkClosed();
- return wrappedConnection.createSQLXML();
- }
-
- public Struct createStruct(String typeName,
- Object[] attributes) throws SQLException {
- checkClosed();
- return wrappedConnection.createStruct(typeName, attributes);
- }
-
- public Properties getClientInfo() throws SQLException {
- checkClosed();
- return wrappedConnection.getClientInfo();
- }
-
- public String getClientInfo(String name) throws SQLException {
- checkClosed();
- return wrappedConnection.getClientInfo(name);
- }
-
- public void setClientInfo(Properties properties) throws SQLClientInfoException {
- // No checkClosed() call since we can only throw SQLClientInfoException from here
- wrappedConnection.setClientInfo(properties);
- }
-
- public void setClientInfo(String name,
- String value) throws SQLClientInfoException {
- // No checkClosed() call since we can only throw SQLClientInfoException from here
- wrappedConnection.setClientInfo(name, value);
- }
-
- public boolean isValid(int timeout) throws SQLException {
- checkClosed();
- return wrappedConnection.isValid(timeout);
- }
-
- public boolean isWrapperFor(Class> iface) throws SQLException {
- wrappedConnection.getConnectionLogger().entering(toString(), "isWrapperFor", iface);
- boolean f = iface.isInstance(this);
- wrappedConnection.getConnectionLogger().exiting(toString(), "isWrapperFor", f);
- return f;
- }
-
- public T unwrap(Class iface) throws SQLException {
- wrappedConnection.getConnectionLogger().entering(toString(), "unwrap", iface);
- T t;
- try {
- t = iface.cast(this);
- }
- catch (ClassCastException e) {
- SQLServerException newe = new SQLServerException(e.getMessage(), e);
- throw newe;
- }
- wrappedConnection.getConnectionLogger().exiting(toString(), "unwrap", t);
- return t;
- }
-
- public UUID getClientConnectionId() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getClientConnectionId();
- }
-
- /**
- * Modifies the setting of the sendTimeAsDatetime connection property. When true, java.sql.Time values will be sent to the server as SQL
- * Serverdatetime values. When false, java.sql.Time values will be sent to the server as SQL Servertime values. sendTimeAsDatetime can also be
- * modified programmatically with SQLServerDataSource.setSendTimeAsDatetime. The default value for this property may change in a future release.
- *
- * @param sendTimeAsDateTimeValue
- * enables/disables setting the sendTimeAsDatetime connection property. For more information about how the Microsoft JDBC Driver for
- * SQL Server configures java.sql.Time values before sending them to the server, see
- * Configuring How java.sql.Time Values are Sent to the
- * Server.
- */
- public synchronized void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException {
- checkClosed();
- wrappedConnection.setSendTimeAsDatetime(sendTimeAsDateTimeValue);
- }
-
- /**
- * Returns the setting of the sendTimeAsDatetime connection property.
- *
- * @return if enabled, returns true. Otherwise, false.
- * @throws SQLServerException
- * when an error occurs.
- */
- public synchronized final boolean getSendTimeAsDatetime() throws SQLServerException {
- checkClosed();
- return wrappedConnection.getSendTimeAsDatetime();
- }
-}
+/*
+ * 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.
+ */
+
+package com.microsoft.sqlserver.jdbc;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.text.MessageFormat;
+import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. When returning a connection object from PooledConnection.getConnection
+ * we return this proxy per SPEC.
+ *