From 6409468a81401c7f60fb98ec4914cf08843e0bcf Mon Sep 17 00:00:00 2001 From: gstojsic Date: Fri, 18 Nov 2016 10:09:00 +0100 Subject: [PATCH 01/42] Make Ms Jdbc driver more spring friendly (https://connect.microsoft.com/SQLServer/Feedback/Details/3100563) --- .../sqlserver/jdbc/SQLServerDataTable.java | 16 ++++++++++++++-- .../java/com/microsoft/sqlserver/jdbc/TVP.java | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index fef139b5a..7b2cefc60 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -35,6 +35,8 @@ public final class SQLServerDataTable { Map columnMetadata = null; Map rows = null; + private String sqlType = null; + /** * The constant in the Java programming language, sometimes referred to as a type code, * that identifies the type TVP. @@ -235,5 +237,15 @@ else if(val instanceof OffsetTime) public synchronized Map getColumnMetadata() { return columnMetadata; - } - } + } + + public String getSqlType() + { + return sqlType; + } + + public void setSqlType(String sqlType) + { + this.sqlType = sqlType; + } + } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java index da9dc8b7b..a79c009ac 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java @@ -72,7 +72,10 @@ void initTVP(TVPType type, String tvpPartName) throws SQLServerException // Name used in CREATE TYPE TVP(String tvpPartName, SQLServerDataTable tvpDataTable) throws SQLServerException { - initTVP(TVPType.SQLServerDataTable, tvpPartName); + if (tvpPartName == null) { + tvpPartName = tvpDataTable.getSqlType(); + } + initTVP(TVPType.SQLServerDataTable, tvpPartName); sourceDataTable = tvpDataTable; sourceDataTableRowIterator = sourceDataTable.getIterator(); populateMetadataFromDataTable(); From 75bf4fb3373bc6221d03d8b877c5b3d4b7540613 Mon Sep 17 00:00:00 2001 From: cosmofrit Date: Sat, 19 Nov 2016 22:24:14 +1000 Subject: [PATCH 02/42] Use 'equals()'' for String comparisons instead of '==' --- src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java index e92ee9888..fa1a5f14d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java @@ -631,7 +631,7 @@ private void setTypeDefinition(DTV dtv) case BINARY: case VARBINARY: // To avoid the server side cost of re-preparing, once a "long" type, always a "long" type... - if (VARBINARY_MAX == param.typeDefinition || IMAGE == param.typeDefinition) + if (VARBINARY_MAX.equals(param.typeDefinition) || IMAGE.equals(param.typeDefinition)) break; if(param.shouldHonorAEForParameter && (null!=jdbcTypeSetByUser) && @@ -787,7 +787,7 @@ private void setTypeDefinition(DTV dtv) case CHAR: case VARCHAR: // To avoid the server side cost of re-preparing, once a "long" type, always a "long" type... - if (VARCHAR_MAX == param.typeDefinition || TEXT == param.typeDefinition) + if (VARCHAR_MAX.equals(param.typeDefinition) || TEXT.equals(param.typeDefinition)) break; // Adding for case useColumnEncryption=true & sendStringParametersAsUnicode=false @@ -885,7 +885,7 @@ else if(DataTypes.SHORT_VARTYPE_MAX_CHARS < valueLength){ case NCHAR: case NVARCHAR: // To avoid the server side cost of re-preparing, once a "long" type, always a "long" type... - if (NVARCHAR_MAX == param.typeDefinition || NTEXT == param.typeDefinition) + if (NVARCHAR_MAX.equals(param.typeDefinition) || NTEXT.equals(param.typeDefinition)) break; if(param.shouldHonorAEForParameter && From 1eeb465a38098bd62d710786f45042689cf7485e Mon Sep 17 00:00:00 2001 From: cosmofrit Date: Sat, 19 Nov 2016 22:35:55 +1000 Subject: [PATCH 03/42] Removed unused imports --- src/main/java/com/microsoft/sqlserver/jdbc/Column.java | 1 - .../microsoft/sqlserver/jdbc/ISQLServerDataRecord.java | 2 -- .../jdbc/SQLServerAeadAes256CbcHmac256Factory.java | 2 -- .../sqlserver/jdbc/SQLServerCallableStatement.java | 1 - ...SQLServerColumnEncryptionCertificateStoreProvider.java | 2 -- .../com/microsoft/sqlserver/jdbc/SQLServerConnection.java | 2 -- .../com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java | 8 -------- .../sqlserver/jdbc/SQLServerDataSourceObjectFactory.java | 1 - .../com/microsoft/sqlserver/jdbc/SQLServerDataTable.java | 3 --- .../com/microsoft/sqlserver/jdbc/SQLServerDriver.java | 1 - .../jdbc/SQLServerEncryptionAlgorithmFactoryList.java | 1 - .../sqlserver/jdbc/SQLServerSecurityUtility.java | 3 --- .../com/microsoft/sqlserver/jdbc/SQLServerStatement.java | 2 -- 13 files changed, 29 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java index 087b5df56..f811c9e39 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java @@ -19,7 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.math.BigDecimal; import java.text.MessageFormat; import java.util.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index a27705bcc..838e0f217 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -19,8 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.util.Set; - /** * 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java index f523c60c1..c239c1d84 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java @@ -20,9 +20,7 @@ package com.microsoft.sqlserver.jdbc; import java.io.UnsupportedEncodingException; -import java.sql.SQLException; import java.text.MessageFormat; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.xml.bind.DatatypeConverter; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index aec394ef9..52b50bb4c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -22,7 +22,6 @@ import java.sql.*; import java.math.BigDecimal; import java.util.Calendar; -import java.util.UUID; import java.io.*; import java.net.*; import java.util.ArrayList; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index f68388818..942c2f999 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -21,10 +21,8 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 77a7cdf18..b6cb7b02c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -19,8 +19,6 @@ package com.microsoft.sqlserver.jdbc; import java.io.*; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.net.*; import java.sql.*; import java.util.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java index 9beb03a09..999fda48e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java @@ -19,14 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.text.MessageFormat; -import java.util.Map.Entry; - public final class SQLServerDataColumn { String columnName; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 0c81ba457..643ef0fd1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -23,7 +23,6 @@ import javax.naming.*; import javax.naming.spi.*; import java.util.*; -import java.lang.reflect.*; /** * SQLServerDataSourceObjectFactory is an object factory to materialize datasources from JNDI. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index fef139b5a..dc2a22e84 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -21,9 +21,6 @@ import java.util.*; import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; import java.text.MessageFormat; import java.util.Map.Entry; import java.time.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index af2b7d771..7456d9522 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -633,7 +633,6 @@ A callable statement param used for IN and OUT may have a different type registe import java.util.*; import java.text.*; import java.util.logging.*; -import java.net.IDN; /** * SQLServerDriver implements the java.sql.Driver for SQLServerConnect. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java index b1b87aac0..7b0367063 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java @@ -21,7 +21,6 @@ import java.text.MessageFormat; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java index 9aa1633a9..406ae0189 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java @@ -20,10 +20,7 @@ package com.microsoft.sqlserver.jdbc; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.text.MessageFormat; -import java.util.Arrays; import java.util.Iterator; -import java.util.concurrent.TimeUnit; import javax.crypto.Mac; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 9426f3d6c..33e57c4f7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -19,8 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.sql.*; import java.util.*; import java.text.MessageFormat; From ef4de3a3fc2d5b047095d5f4fdb10c6c6b657899 Mon Sep 17 00:00:00 2001 From: cosmofrit Date: Sun, 20 Nov 2016 13:31:14 +1000 Subject: [PATCH 04/42] Make expression more readable by using contains() instead of indexOf() --- src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java | 2 +- .../java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 56c93556c..435db0d10 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -1760,7 +1760,7 @@ void enableSSL(String host, int port) throws SQLServerException // The error message may have a connection id appended to it. Extract the message only for comparison. // This client connection id is appended in method checkAndAppendClientConnId(). - if (-1 != errMsg.indexOf(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)) + if (errMsg.contains(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)) { errMsg = errMsg.substring(0, errMsg.indexOf(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 33e57c4f7..24034d90d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -1050,7 +1050,7 @@ final void resetForReexecute() throws SQLServerException * @return the result */ /*L0*/ static String replaceMarkerWithNull(String sql){ - if (sql.indexOf("'") < 0) { + if (!sql.contains("'")) { String retStr = replaceParameterWithString(sql , '?' , "null"); return retStr; } From 64e30cacd0ee4d7675fd01c919c67d46c40009c7 Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 20 Nov 2016 14:01:10 +0100 Subject: [PATCH 05/42] Implement missing MetaData #unwrap methods The driver currently implements some #unwrap methods but for MetaData * implement DatabaseMetaData#unwrap * implement ParameterMetaData#unwrap * implement ResultSetMetaData#unwrap * use for spaces for indentation where spaces are used * use tabs for indentation where tabs are used --- .../sqlserver/jdbc/SQLServerDatabaseMetaData.java | 11 ++++++++++- .../sqlserver/jdbc/SQLServerParameterMetaData.java | 11 ++++++++++- .../sqlserver/jdbc/SQLServerResultSetMetaData.java | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 5abce9ca0..4c3b62d09 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -133,7 +133,16 @@ public boolean isWrapperFor(Class iface) throws SQLException public T unwrap(Class iface) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); - throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); + T t; + try + { + t = iface.cast(this); + } + catch (ClassCastException e) + { + throw new SQLServerException(e.getMessage(), e); + } + return t; } private void checkClosed() throws SQLServerException diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 640e6ab06..7f4a33032 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -638,7 +638,16 @@ public boolean isWrapperFor(Class iface) throws SQLException public T unwrap(Class iface) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); - throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); + T t; + try + { + t = iface.cast(this); + } + catch (ClassCastException e) + { + throw new SQLServerException(e.getMessage(), e); + } + return t; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java index 2ef95a879..86eb33c5d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java @@ -86,7 +86,16 @@ public boolean isWrapperFor(Class iface) throws SQLException public T unwrap(Class iface) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); - throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); + T t; + try + { + t = iface.cast(this); + } + catch (ClassCastException e) + { + throw new SQLServerException(e.getMessage(), e); + } + return t; } public String getCatalogName(int column) throws SQLServerException From 234657ed338cd559558c7ac6c648a0872befea2a Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 20 Nov 2016 14:54:13 +0100 Subject: [PATCH 06/42] Avoid unnecessary calls to String copy constructor The driver currently contains 20 calls to the String(String) copy constructor. To quote from the Javadoc > Unless an explicit copy of {@code original} is needed, use of this > constructor is unnecessary since Strings are immutable. Calling the constructor only results in unnecessary pressure of both the allocator and the heap. --- .../java/com/microsoft/sqlserver/jdbc/IOBuffer.java | 2 +- .../sqlserver/jdbc/SQLServerCallableStatement.java | 2 +- .../microsoft/sqlserver/jdbc/SQLServerConnection.java | 8 ++++---- .../com/microsoft/sqlserver/jdbc/SQLServerDriver.java | 2 +- .../sqlserver/jdbc/SQLServerParameterMetaData.java | 2 +- .../sqlserver/jdbc/SQLServerPreparedStatement.java | 10 +++++----- .../microsoft/sqlserver/jdbc/SQLServerSavepoint.java | 2 +- .../microsoft/sqlserver/jdbc/SQLServerStatement.java | 2 +- .../microsoft/sqlserver/jdbc/SQLServerXAResource.java | 2 +- src/main/java/com/microsoft/sqlserver/jdbc/dtv.java | 6 +++--- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 56c93556c..71342aa42 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -4006,7 +4006,7 @@ void writeNonUnicodeReader( else { // encoding as per collation - streamByteBuffer[charsCopied] = new String(streamCharBuffer[charsCopied] + + streamByteBuffer[charsCopied] = (streamCharBuffer[charsCopied] + "") .getBytes(charSet)[0]; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index aec394ef9..e515bd725 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -100,7 +100,7 @@ public void registerOutParameter(int index, int sqlType) throws SQLServerExcepti if (2012 == sqlType) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_featureNotSupported")); - Object[] msgArgs = {new String("REF_CURSOR")}; + Object[] msgArgs = {"REF_CURSOR"}; SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 77a7cdf18..6682ce21c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -749,7 +749,7 @@ public String toString() if (lcpropValue.equals("true")) return true; if (lcpropValue.equals("false")) return false; MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidBooleanValue")); - Object[] msgArgs = {new String(propName)}; + Object[] msgArgs = {propName}; SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false); // Adding return false here for compiler's sake, this code is unreachable. return false; @@ -1128,7 +1128,7 @@ Connection connectInternal(Properties propsIn, SQLServerPooledConnection pooledC else { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidselectMethod")); - Object[] msgArgs = {new String(sPropValue)}; + Object[] msgArgs = {sPropValue}; SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false); } @@ -1142,7 +1142,7 @@ Connection connectInternal(Properties propsIn, SQLServerPooledConnection pooledC else { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidresponseBuffering")); - Object[] msgArgs = {new String(sPropValue)}; + Object[] msgArgs = {sPropValue}; SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false); } @@ -1779,7 +1779,7 @@ else if(isDBMirroring) curserverinfo = curserverinfo + currentFOPlaceHolder.getInstanceName(); } MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPartnerConfiguration")); - Object[] msgArgs = { new String(activeConnectionProperties.getProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString())), + Object[] msgArgs = { activeConnectionProperties.getProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString()), curserverinfo}; terminate(SQLServerException.DRIVER_ERROR_UNSUPPORTED_CONFIG, form.format(msgArgs)); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index af2b7d771..179d68492 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -831,7 +831,7 @@ else if(value.equalsIgnoreCase(ApplicationIntent.READ_WRITE.toString())) else { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidapplicationIntent")); - Object[] msgArgs = {new String(value)}; + Object[] msgArgs = {value}; throw new SQLServerException(null , form.format(msgArgs) , null, 0 , false); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 640e6ab06..8f824cdf8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -606,7 +606,7 @@ private void checkClosed() throws SQLServerException if (null == metaInfo) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cantIdentifyTableMetadata")); - Object[] msgArgs = {new String(sProcString)}; + Object[] msgArgs = {sProcString}; SQLServerException.makeFromDriverError(con, stmtParent, form.format(msgArgs), null, false); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index dcda8af09..1cd8e0afb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -914,7 +914,7 @@ private final boolean doPrepExec(TDSWriter tdsWriter, Parameter[] params, boolea { // if the error is not no resultset then throw a processings error. MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_processingError")); - Object[] msgArgs = {new String(sqle.getMessage())}; + Object[] msgArgs = {sqle.getMessage()}; SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, true); @@ -2338,25 +2338,25 @@ public final void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLExce /*L0*/ public final int executeUpdate(String sql) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "executeUpdate", sql); MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable")); - Object[] msgArgs = {new String("executeUpdate()")}; + Object[] msgArgs = {"executeUpdate()"}; throw new SQLServerException(this , form.format(msgArgs), null, 0 , false); } /*L0*/ public final boolean execute(String sql) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "execute", sql); MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable")); - Object[] msgArgs = {new String("execute()")}; + Object[] msgArgs = {"execute()"}; throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false); } /*L0*/ public final java.sql.ResultSet executeQuery(String sql) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "executeQuery", sql); MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable")); - Object[] msgArgs = {new String("executeQuery()")}; + Object[] msgArgs = {"executeQuery()"}; throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false); } /*L0*/ public void addBatch(String sql) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "addBatch", sql); MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable")); - Object[] msgArgs = {new String("addBatch()")}; + Object[] msgArgs = {"addBatch()"}; throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java index b3746cf06..6fa59638a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java @@ -80,7 +80,7 @@ public int getSavepointId() throws SQLServerException { if (sName != null) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_savepointNamed")); - Object[] msgArgs = {new String(sName)}; + Object[] msgArgs = {sName}; SQLServerException.makeFromDriverError(con, null, form.format(msgArgs), null, false); } return nId; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 9426f3d6c..e46a3516b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -2518,7 +2518,7 @@ else if(value.equalsIgnoreCase("adaptive")) else { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidresponseBuffering")); - Object[] msgArgs = {new String(value)}; + Object[] msgArgs = {value}; SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false); } loggerExternal.exiting(getClassNameLogging(), "setResponseBuffering"); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java index 141e9c494..7ca508f40 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java @@ -452,7 +452,7 @@ private String typeDisplay(int type) catch (SQLServerException e1) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_failedToCreateXAConnection")); - Object[] msgArgs = {new String(e1.getMessage())}; + Object[] msgArgs = {e1.getMessage()}; if (xaLogger.isLoggable(Level.FINER)) xaLogger.finer(toString() + " exception:" + form.format(msgArgs)); SQLServerException.makeFromDriverError(null,null, form.format(msgArgs), null, true); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java index 931f37a1e..466d79ff1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java @@ -336,7 +336,7 @@ void execute(DTV dtv, Clob clobValue) throws SQLServerException catch (UnsupportedEncodingException ex) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; + Object[] msgArgs = {ex.getMessage()}; SQLServerException.makeFromDriverError( conn, null, @@ -2353,7 +2353,7 @@ else if (null != collation && catch (UnsupportedEncodingException ex) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; + Object[] msgArgs = {ex.getMessage()}; SQLServerException.makeFromDriverError( con, null, @@ -2642,7 +2642,7 @@ else if (null != collation && catch (UnsupportedEncodingException ex) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; + Object[] msgArgs = {ex.getMessage()}; SQLServerException.makeFromDriverError( con, null, From 6399e1f3720c6a7445b40240ad9f65fd1532035c Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 20 Nov 2016 17:48:16 +0100 Subject: [PATCH 07/42] Use StandardCharsets where possible Since Java 1.7 there is the StandardCharsets class which provides constants for frequently used Charsets. Using this also allows us to remove several UnsupportedEncodingException catch blocks. * use StandardCharsets in String constructors where possible * use StandardCharsets in #getBytes where possible * use StandardCharsets instead of Charset.foreName where possible --- .../com/microsoft/sqlserver/jdbc/DDC.java | 8 ++- ...rverAeadAes256CbcHmac256EncryptionKey.java | 16 ++--- .../SQLServerAeadAes256CbcHmac256Factory.java | 58 ++++++++----------- .../sqlserver/jdbc/SQLServerBulkCopy.java | 8 ++- ...ColumnEncryptionAzureKeyVaultProvider.java | 12 +--- ...rColumnEncryptionJavaKeyStoreProvider.java | 13 +---- .../sqlserver/jdbc/SQLServerConnection.java | 40 ++----------- .../jdbc/SQLServerSymmetricKeyCache.java | 14 +---- .../com/microsoft/sqlserver/jdbc/dtv.java | 5 +- 9 files changed, 58 insertions(+), 116 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java index 058c96b39..0a0f36b32 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java @@ -25,6 +25,8 @@ import java.text.*; import java.util.*; +import static java.nio.charset.StandardCharsets.US_ASCII; + /** * Utility class for all Data Dependant Conversions (DDC). */ @@ -532,7 +534,7 @@ static final Object convertStringToObject( case CHARACTER: return new StringReader(stringVal); case ASCII: - return new ByteArrayInputStream(stringVal.getBytes("US-ASCII")); + return new ByteArrayInputStream(stringVal.getBytes(US_ASCII)); case BINARY: return new ByteArrayInputStream(stringVal.getBytes()); @@ -622,7 +624,7 @@ static final Object convertStreamToObject( } else { - return new ByteArrayInputStream((new String(stream.getBytes(), typeInfo.getCharset())).getBytes("US-ASCII")); + return new ByteArrayInputStream((new String(stream.getBytes(), typeInfo.getCharset())).getBytes(US_ASCII)); } } else if (StreamType.CHARACTER == getterArgs.streamType || @@ -1357,7 +1359,7 @@ static AsciiFilteredUnicodeInputStream MakeAsciiFilteredUnicodeInputStream(BaseI private AsciiFilteredUnicodeInputStream( Reader rd) throws SQLServerException { containedReader = rd; - asciiCharSet = Charset.forName("US-ASCII"); + asciiCharSet = US_ASCII; } public void close() throws IOException diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java index cdbd49603..d8b213aea 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java @@ -19,11 +19,12 @@ package com.microsoft.sqlserver.jdbc; -import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.text.MessageFormat; +import static java.nio.charset.StandardCharsets.UTF_16LE; + /** * Encryption key class which consist of following 4 keys : * 1) root key - Main key which is used to derive following keys @@ -81,7 +82,7 @@ class SQLServerAeadAes256CbcHmac256EncryptionKey extends SQLServerSymmetricKey // By default Java is big endian, we are getting bytes in little endian(LE in UTF-16LE) // to make it compatible with C# driver which is little endian encKeyBuff = SQLServerSecurityUtility.getHMACWithSHA256( - encryptionKeySaltFormat.getBytes("UTF-16LE"), + encryptionKeySaltFormat.getBytes(UTF_16LE), rootKey, encKeyBuff.length); @@ -90,7 +91,7 @@ class SQLServerAeadAes256CbcHmac256EncryptionKey extends SQLServerSymmetricKey // Derive mac key from root key byte[] macKeyBuff = new byte[keySizeInBytes]; macKeyBuff = SQLServerSecurityUtility.getHMACWithSHA256( - macKeySaltFormat.getBytes("UTF-16LE"), + macKeySaltFormat.getBytes(UTF_16LE), rootKey, macKeyBuff.length); @@ -99,18 +100,11 @@ class SQLServerAeadAes256CbcHmac256EncryptionKey extends SQLServerSymmetricKey // Derive the initialization vector from root key byte[] ivKeyBuff = new byte[keySizeInBytes]; ivKeyBuff = SQLServerSecurityUtility.getHMACWithSHA256( - ivKeySaltFormat.getBytes("UTF-16LE"), + ivKeySaltFormat.getBytes(UTF_16LE), rootKey, ivKeyBuff.length); ivKey = new SQLServerSymmetricKey(ivKeyBuff); } - catch (UnsupportedEncodingException e) - { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } catch (InvalidKeyException | NoSuchAlgorithmException e) { MessageFormat form = new MessageFormat( diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java index f523c60c1..94124ebd8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java @@ -19,14 +19,13 @@ package com.microsoft.sqlserver.jdbc; -import java.io.UnsupportedEncodingException; -import java.sql.SQLException; import java.text.MessageFormat; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.xml.bind.DatatypeConverter; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Factory for SQLServerAeadAes256CbcHmac256Algorithm */ @@ -49,40 +48,33 @@ SQLServerEncryptionAlgorithm create( } String factoryKey=""; - try { - StringBuffer factoryKeyBuilder=new StringBuffer(); - factoryKeyBuilder.append( - DatatypeConverter.printBase64Binary( - new String( - columnEncryptionKey.getRootKey(), - "UTF-8" - ).getBytes() - ) - ); + StringBuffer factoryKeyBuilder=new StringBuffer(); + factoryKeyBuilder.append( + DatatypeConverter.printBase64Binary( + new String( + columnEncryptionKey.getRootKey(), + UTF_8 + ).getBytes() + ) + ); - factoryKeyBuilder.append(":"); - factoryKeyBuilder.append(encryptionType); - factoryKeyBuilder.append(":"); - factoryKeyBuilder.append(algorithmVersion); - - factoryKey =factoryKeyBuilder.toString(); - - SQLServerAeadAes256CbcHmac256Algorithm aesAlgorithm; - - if(!encryptionAlgorithms.containsKey(factoryKey)){ - SQLServerAeadAes256CbcHmac256EncryptionKey encryptedKey = new SQLServerAeadAes256CbcHmac256EncryptionKey(columnEncryptionKey.getRootKey(), SQLServerAeadAes256CbcHmac256Algorithm.algorithmName); - aesAlgorithm = new SQLServerAeadAes256CbcHmac256Algorithm(encryptedKey, encryptionType, algorithmVersion); - encryptionAlgorithms.putIfAbsent(factoryKey, aesAlgorithm); - } + factoryKeyBuilder.append(":"); + factoryKeyBuilder.append(encryptionType); + factoryKeyBuilder.append(":"); + factoryKeyBuilder.append(algorithmVersion); + + factoryKey =factoryKeyBuilder.toString(); + + SQLServerAeadAes256CbcHmac256Algorithm aesAlgorithm; + + if(!encryptionAlgorithms.containsKey(factoryKey)){ + SQLServerAeadAes256CbcHmac256EncryptionKey encryptedKey = new SQLServerAeadAes256CbcHmac256EncryptionKey(columnEncryptionKey.getRootKey(), SQLServerAeadAes256CbcHmac256Algorithm.algorithmName); + aesAlgorithm = new SQLServerAeadAes256CbcHmac256Algorithm(encryptedKey, encryptionType, algorithmVersion); + encryptionAlgorithms.putIfAbsent(factoryKey, aesAlgorithm); + } - } catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-8" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } return encryptionAlgorithms.get(factoryKey); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index 6136d08ee..0779d5189 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -28,7 +28,6 @@ import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.charset.Charset; import java.sql.Connection; import java.sql.Date; import java.sql.ResultSet; @@ -54,6 +53,9 @@ import java.util.Vector; import java.util.logging.Level; +import static java.nio.charset.StandardCharsets.UTF_16LE; +import static java.nio.charset.StandardCharsets.UTF_8; + import javax.sql.RowSet; import microsoft.sql.DateTimeOffset; @@ -3524,7 +3526,7 @@ private byte[] normalizedValue(JDBCType destJdbcType, Object value, JDBCType src Object[] msgArgs = { srcJdbcType, destJdbcType }; throw new SQLServerException(this, form.format(msgArgs), null, 0, false); } - return ((String)value).getBytes(Charset.forName("UTF-8")); + return ((String)value).getBytes(UTF_8); case NCHAR: case NVARCHAR: @@ -3536,7 +3538,7 @@ private byte[] normalizedValue(JDBCType destJdbcType, Object value, JDBCType src Object[] msgArgs = { srcJdbcType, destJdbcType }; throw new SQLServerException(this, form.format(msgArgs), null, 0, false); } - return ((String)value).getBytes(Charset.forName("UTF-16LE")); + return ((String)value).getBytes(UTF_16LE); case REAL: case FLOAT: diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index afd8586ae..e39768b1d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -30,6 +30,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; +import static java.nio.charset.StandardCharsets.UTF_16LE; + import org.apache.http.impl.client.HttpClientBuilder; import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.KeyVaultClientImpl; @@ -284,15 +286,7 @@ public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryption byte[] version = new byte[] { firstVersion[0] }; // Get the Unicode encoded bytes of cultureinvariant lower case masterKeyPath - byte[] masterKeyPathBytes = null; - try { - masterKeyPathBytes = masterKeyPath.toLowerCase().getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } + byte[] masterKeyPathBytes = masterKeyPath.toLowerCase().getBytes(UTF_16LE); byte[] keyPathLength = new byte[2]; keyPathLength[0] = (byte)(((short)masterKeyPathBytes.length) & 0xff); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index 569869256..c94ea98bf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -23,7 +23,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.InvalidKeyException; @@ -46,6 +45,8 @@ import com.microsoft.sqlserver.jdbc.KeyStoreProviderCommon; +import static java.nio.charset.StandardCharsets.UTF_16LE; + public class SQLServerColumnEncryptionJavaKeyStoreProvider extends SQLServerColumnEncryptionKeyStoreProvider { String name = "MSSQL_JAVA_KEYSTORE"; @@ -254,15 +255,7 @@ else if (0==plainTextColumnEncryptionKey.length) { CertificateDetails certificateDetails = getCertificateDetails(masterKeyPath); byte [] cipherText=encryptRSAOAEP(plainTextColumnEncryptionKey, certificateDetails); byte[] cipherTextLength=getLittleEndianBytesFromShort((short)cipherText.length); - byte[] masterKeyPathBytes; - - try { - masterKeyPathBytes = masterKeyPath.toLowerCase().getBytes( - "UTF-16LE"); - } catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unsupportedEncoding")); - throw new SQLServerException(form.format(new Object[] {"UTF-16LE"}), null, 0, null); - } + byte[] masterKeyPathBytes = masterKeyPath.toLowerCase().getBytes(UTF_16LE); byte[] keyPathLength=getLittleEndianBytesFromShort((short)masterKeyPathBytes.length); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 77a7cdf18..8d08e67de 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -32,6 +32,8 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; +import static java.nio.charset.StandardCharsets.UTF_16LE; + /** * SQLServerConnection implements a JDBC connection to SQL Server. * SQLServerConnections support JDBC connection pooling and may be either physical JDBC connections @@ -1234,14 +1236,7 @@ Connection connectInternal(Properties propsIn, SQLServerPooledConnection pooledC sPropValue = activeConnectionProperties.getProperty(sPropKey); if (null != sPropValue) { - try { - accessTokenInByte = sPropValue.getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } + accessTokenInByte = sPropValue.getBytes(UTF_16LE); } if((null != accessTokenInByte) && 0 == accessTokenInByte.length) @@ -3552,13 +3547,7 @@ final void processFedAuthInfo(TDSReader tdsReader, TDSTokenHandler tdsTokenHandl try { byte[] dataArray = new byte[dataLen]; System.arraycopy(tokenData, dataOffset, dataArray, 0, dataLen); - data = new String(dataArray, "UTF-16LE"); - } - catch(UnsupportedEncodingException e){ - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); + data = new String(dataArray, UTF_16LE); } catch(Exception e){ connectionlogger.severe(toString() + "Failed to read FedAuthInfoData."); @@ -3724,16 +3713,7 @@ else if(authenticationString.trim().equalsIgnoreCase(SqlAuthentication.ActiveDir byte[] accessTokenFromDLL = dllInfo.accessTokenBytes; - String accessToken = null; - try { - accessToken = new String(accessTokenFromDLL, "UTF-16LE"); - } - catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(null, form.format(msgArgs), null, 0, false); - } + String accessToken = new String(accessTokenFromDLL, UTF_16LE); SqlFedAuthToken fedAuthToken = new SqlFedAuthToken(accessToken, dllInfo.expiresIn); @@ -3754,15 +3734,7 @@ private void sendFedAuthToken(FedAuthTokenCommand fedAuthCommand, SqlFedAuthToke TDSWriter tdsWriter = fedAuthCommand.startRequest(TDS.PKT_FEDAUTH_TOKEN_MESSAGE); - byte[] accessToken = null; - try { - accessToken = fedAuthToken.accessToken.getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - MessageFormat form = new MessageFormat( - SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-16LE" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } + byte[] accessToken = fedAuthToken.accessToken.getBytes(UTF_16LE); // Send total length (length of token plus 4 bytes for the token length field) // If we were sending a nonce, this would include that length as well diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java index b7e1531d9..cadce87b9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java @@ -19,7 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.io.UnsupportedEncodingException; import java.text.MessageFormat; import java.util.List; import java.util.concurrent.ConcurrentHashMap; @@ -27,6 +26,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; +import static java.nio.charset.StandardCharsets.UTF_8; + import static java.util.concurrent.TimeUnit.*; import javax.xml.bind.DatatypeConverter; @@ -123,16 +124,7 @@ SQLServerSymmetricKey getKey(EncryptionKeyInfo keyInfo, SQLServerConnection conn String keyLookupValue=null; keyLookupValuebuffer.append(":"); - try - { - keyLookupValuebuffer.append(DatatypeConverter.printBase64Binary((new String(keyInfo.encryptedKey,"UTF-8")).getBytes())); - } - catch (UnsupportedEncodingException e) - { - MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unsupportedEncoding")); - Object[] msgArgs = { "UTF-8" }; - throw new SQLServerException(this, form.format(msgArgs), null, 0, false); - } + keyLookupValuebuffer.append(DatatypeConverter.printBase64Binary((new String(keyInfo.encryptedKey,UTF_8)).getBytes())); keyLookupValuebuffer.append(":"); keyLookupValuebuffer.append(keyInfo.keyStoreName); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java index 931f37a1e..7f6325e28 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java @@ -26,11 +26,12 @@ import java.math.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.charset.Charset; import java.sql.*; import java.text.MessageFormat; import java.time.*; +import static java.nio.charset.StandardCharsets.UTF_16LE; + import com.microsoft.sqlserver.jdbc.JavaType.SetterConversionAE; @@ -1911,7 +1912,7 @@ else if ((JDBCType.NVARCHAR == jdbcTypeSetByUser) // Each character is represented using 2 bytes in NVARCHAR else if((JDBCType.NVARCHAR == jdbcTypeSetByUser) || (JDBCType.NCHAR == jdbcTypeSetByUser) || (JDBCType.LONGNVARCHAR == jdbcTypeSetByUser)) { - byteValue = ((String)value).getBytes(Charset.forName("UTF-16LE")); + byteValue = ((String)value).getBytes(UTF_16LE); } // Each character is represented using 1 bytes in VARCHAR else if((JDBCType.VARCHAR == jdbcTypeSetByUser) || (JDBCType.CHAR == jdbcTypeSetByUser) || (JDBCType.LONGVARCHAR == jdbcTypeSetByUser)) From ee34b8a6b052943b2263f005cffa8adfd71e734a Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Tue, 22 Nov 2016 14:50:30 -0800 Subject: [PATCH 08/42] ISSUE-17 azure-keyvault (mssql-jdbc's dependencies) #17 : Adding section in README related to dependency --- README.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3ea12b67..ab18a4b8e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ This driver is documented on [Microsoft's Documentation web site](https://msdn.m For samples, please see the src\sample directory. ### Download the DLLs -For some features (e.g. Integrated Authentication and Distributed Transactions), you may need to use the sqljdbc_xa and sqljdbc_auth DLLs. They can be downloaded from the [Microsoft Download Center](https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774) +For some features (e.g. Integrated Authentication and Distributed Transactions), you may need to use the `sqljdbc_xa` and `sqljdbc_auth` DLLs. They can be downloaded from the [Microsoft Download Center](https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774) ### Download the driver Don't want to compile anything? @@ -69,6 +69,88 @@ We're now on the Maven Central Repository. Add the following to your POM file: The driver can be downloaded from the [Microsoft Download Center](https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774) +##Dependencies +This project has following dependencies: + +Compile Time: + + - `azure-keyvault` + +Test Time: + + - `junit:jar` + +If anybody wants to use driver as a run-time dependency but not using Azure Web Services for authentication then you either describe as optional dependency or exclude azure. + +``` + + com.microsoft.sqlserver + mssql-jdbc + 6.1.0.jre8 + runtime + + + com.microsoft.azure + azure-keyvault + + + +``` + +###Dependency Tree +``` +mvn dependency:tree +[INFO] Scanning for projects... +[INFO] +[INFO] ------------------------------------------------------------------------ +[INFO] Building Microsoft JDBC Driver for SQL Server 6.1.0 +[INFO] ------------------------------------------------------------------------ +[INFO] +[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mssql-jdbc --- +[INFO] com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0 +[INFO] +- com.microsoft.azure:azure-keyvault:jar:0.9.3:compile +[INFO] | +- com.microsoft.azure:azure-core:jar:0.9.3:compile +[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile +[INFO] | | +- commons-lang:commons-lang:jar:2.6:compile +[INFO] | | +- javax.mail:mail:jar:1.4.5:compile +[INFO] | | | \- javax.activation:activation:jar:1.1:compile +[INFO] | | +- com.sun.jersey:jersey-client:jar:1.13:compile +[INFO] | | | \- com.sun.jersey:jersey-core:jar:1.13:compile +[INFO] | | \- com.sun.jersey:jersey-json:jar:1.13:compile +[INFO] | | +- org.codehaus.jettison:jettison:jar:1.1:compile +[INFO] | | | \- stax:stax-api:jar:1.0.1:compile +[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile +[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile +[INFO] | | | \- javax.xml.stream:stax-api:jar:1.0-2:compile +[INFO] | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile +[INFO] | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile +[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile +[INFO] | | \- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile +[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile +[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile +[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile +[INFO] | +- javax.inject:javax.inject:jar:1:compile +[INFO] | \- com.microsoft.azure:adal4j:jar:1.0.0:compile +[INFO] | +- com.nimbusds:oauth2-oidc-sdk:jar:4.5:compile +[INFO] | | +- net.jcip:jcip-annotations:jar:1.0:compile +[INFO] | | +- org.apache.commons:commons-lang3:jar:3.3.1:compile +[INFO] | | +- net.minidev:json-smart:jar:1.1.1:compile +[INFO] | | +- com.nimbusds:lang-tag:jar:1.4:compile +[INFO] | | \- com.nimbusds:nimbus-jose-jwt:jar:3.1.2:compile +[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.51:compile +[INFO] | +- com.google.code.gson:gson:jar:2.2.4:compile +[INFO] | \- org.slf4j:slf4j-api:jar:1.7.5:compile +[INFO] \- junit:junit:jar:4.12:test +[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 1.423 s +[INFO] Finished at: 2016-11-22T13:13:55-08:00 +[INFO] Final Memory: 12M/304M +[INFO] ------------------------------------------------------------------------ +``` + ## Guidelines for Reporting Issues We appreciate you taking the time to test the driver, provide feedback and report any issues. It would be extremely helpful if you: From d107930a668a449d37717a1e7e591de24ebc655b Mon Sep 17 00:00:00 2001 From: Shawn Sun Date: Tue, 22 Nov 2016 17:11:56 -0800 Subject: [PATCH 09/42] removed UnsupportedEncodingException import --- .../jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index e39768b1d..e3be179d3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -19,7 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.nio.ByteBuffer; From 59a17a61e0b0b63604a99298e7434f36ca8ad400 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Wed, 23 Nov 2016 16:41:51 -0800 Subject: [PATCH 10/42] use environment variables for test instead of config file --- README.md | 7 +- .../microsoft/sqlserver/jdbc/bvt/bvtTest.java | 67 +++++-------------- src/test/serverConfig.cfg | 5 -- 3 files changed, 18 insertions(+), 61 deletions(-) delete mode 100644 src/test/serverConfig.cfg diff --git a/README.md b/README.md index b3ea12b67..40ed43fb3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ What's coming next? We will look into adding a more comprehensive set of tests, * [**Mac + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-mac) * [**Windows + SQL Server + Java**](https://www.microsoft.com/en-us/sql-server/developer-get-started/java-windows) - ## Build ### Prerequisites * Java 8 @@ -26,19 +25,19 @@ What's coming next? We will look into adding a more comprehensive set of tests, * An instance of SQL Server or Azure SQL Database that you can connect to. ### Build the JAR files -The build automatically triggers a set of verification tests to run. For these tests to pass, you will first need to modify the serverConfig.cfg file under .\src\test to provide the correct connection properties for your SQL Server or Azure SQL Database instance. +The build automatically triggers 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://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) for your SQL Server or Azure SQL Database instance. To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. You can choose to build a JDBC 4.1 compliant jar file (for use with JRE 7) and/or a JDBC 4.2 compliant jar file (for use with JRE 8). * Ant: - 1. If you have not already done so, update the serverConfig.cfg file under .\src\test with the connection properties for your SQL Server or SQL DB instance. + 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, JDBC 4.2 compliant jar, or both in the \build directory. * Run `ant`. This creates both JDBC 4.1 compliant jar and JDBC 4.2 compliant jar in \build directory * Run `ant build41`. This creates JDBC 4.1 compliant jar in \build directory * Run `ant build42`. This creates JDBC 4.2 compliant jar in \build directory * Maven: - 1. If you have not already done so, update the serverConfig.cfg file under .\src\test with the connection properties for your SQL Server or SQL DB instance. + 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 directory. * Run `mvn install -Pbuild41`. This creates JDBC 4.1 compliant jar in \target directory * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java index 94e72c21b..64e5276b1 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java @@ -16,8 +16,9 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of IN THE SOFTWARE. */ -import java.io.BufferedReader; -import java.io.FileReader; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -27,24 +28,15 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of import java.sql.Statement; import java.util.regex.Matcher; import java.util.regex.Pattern; - -import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement; -import static org.junit.Assert.*; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement; public class bvtTest { - private static boolean cursor = false; private static String connectionUrl = ""; private static Connection con; - private static String serverName = null; - private static String portNumber = null; - private static String databaseName = null; - private static String username = null; - private static String password = null; - private static String line = null; private static String driverNamePattern = "Microsoft JDBC Driver \\d.\\d for SQL Server"; private static String table1 = "stmt_test_bvt"; private static String table2 = "rs_test_bvt"; @@ -61,8 +53,6 @@ public static void init() throws SQLException { e.printStackTrace(); } - readFromConfig(); - Statement stmt = null; try { stmt = conn().createStatement(); @@ -617,44 +607,17 @@ public static void terminate() throws SQLException { } public static String getConnectionURL() { - - // Create a variable for the connection string. - connectionUrl = "jdbc:sqlserver://" + serverName + ":" + portNumber + ";" + "databaseName=" + databaseName - + ";username=" + username + ";password=" + password + ";"; - - if (cursor) - connectionUrl += "selectMethod=cursor;"; - - return connectionUrl; - } - - public static void readFromConfig() { - - try (BufferedReader in = new BufferedReader(new FileReader("src/test/serverConfig.cfg"));) { - - line = in.readLine(); - String[] parts = line.split("="); - serverName = parts[1].trim(); - - line = in.readLine(); - parts = line.split("="); - portNumber = parts[1].trim(); - - line = in.readLine(); - parts = line.split("="); - databaseName = parts[1].trim(); - - line = in.readLine(); - parts = line.split("="); - username = parts[1].trim(); - - line = in.readLine(); - parts = line.split("="); - password = parts[1].trim(); - - } catch (Exception e) { - fail(e.toString()); + connectionUrl = System.getenv("mssql_jdbc_test_connection_properties"); + + if(null == connectionUrl){ + fail("Please setup environment variable mssql_jdbc_test_connection_properties"); } + + if (cursor){ + connectionUrl += ";selectMethod=cursor;"; + } + + return connectionUrl; } public static Connection conn() { @@ -667,7 +630,7 @@ public static Connection conn() { return con; // Handle any errors that may have occurred. } catch (SQLException e) { - fail("Please make sure the serverConfig.cfg file is updated with correct connection properties.\n" + fail("Please make sure the environment variable mssql_jdbc_test_connection_properties is set with correct connection properties.\n" + e.toString()); } return null; diff --git a/src/test/serverConfig.cfg b/src/test/serverConfig.cfg deleted file mode 100644 index 192d9ba5f..000000000 --- a/src/test/serverConfig.cfg +++ /dev/null @@ -1,5 +0,0 @@ -server= -port= -database name= -user= -password= \ No newline at end of file From 08a841735b52e33cce322b4b386fbde6ca3e34e6 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Wed, 23 Nov 2016 17:03:24 -0800 Subject: [PATCH 11/42] added manifest entry to POM file and removed nonexistent files from POM and build.xml --- build.xml | 4 ++-- pom.xml | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build.xml b/build.xml index dcb9644da..a6577750b 100644 --- a/build.xml +++ b/build.xml @@ -55,7 +55,7 @@ - + @@ -74,7 +74,7 @@ - + diff --git a/pom.xml b/pom.xml index e3795df5a..c2e57e571 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,10 @@ + + Microsoft Corporation + + Andrea Lam @@ -67,8 +71,6 @@ 3.1 - **/com/microsoft/sqlserver/jdbc/SQLServerJdbc3.java - **/com/microsoft/sqlserver/jdbc/SQLServerJdbc4.java **/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java 1.7 @@ -80,7 +82,12 @@ maven-jar-plugin 3.0.2 - ${project.artifactId}-${project.version}.jre7 + ${project.artifactId}-${project.version}.jre7 + + + true + + @@ -96,8 +103,6 @@ 3.1 - **/com/microsoft/sqlserver/jdbc/SQLServerJdbc3.java - **/com/microsoft/sqlserver/jdbc/SQLServerJdbc4.java **/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java 1.8 @@ -109,7 +114,12 @@ maven-jar-plugin 3.0.2 - ${project.artifactId}-${project.version}.jre8 + ${project.artifactId}-${project.version}.jre8 + + + true + + From 490e2c4fa2de72a990845220249fccc82ab9923e Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Wed, 23 Nov 2016 17:42:57 -0800 Subject: [PATCH 12/42] Travis CI and Appveyor config files --- .travis.yml | 24 ++++++++++++++++++++++++ appveyor.yml | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .travis.yml create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..a3cf7524a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +sudo: required + +language: java +jdk: + - oraclejdk8 + +services: + - docker + +env: + - mssql_jdbc_test_connection_properties='jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=;' + +install: + - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41 + - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42 + +before_script: + - docker pull microsoft/mssql-server-linux + - docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=' -p 1433:1433 -d microsoft/mssql-server-linux + +script: + - docker ps -a + - mvn test -B -Pbuild41 + - mvn test -B -Pbuild42 \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..9c5bb3f98 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,16 @@ +version: '{build}' + +environment: + mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=SQL2016;databaseName=master;username=sa;password=Password12!; + matrix: + - JAVA_HOME: C:\Program Files\Java\jdk1.8.0 + +services: + - mssql2016 + +build_script: + - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41 + - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42 +test_script: + - mvn test -B -Pbuild41 + - mvn test -B -Pbuild42 \ No newline at end of file From bb2129f631c4f3ccdf3e2e5f1f58d5968ac3265c Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Thu, 24 Nov 2016 16:40:12 +0100 Subject: [PATCH 13/42] Fix StreamError class comment The StreamError class comment says it's serializable because it is held by SQLServerException. Both statements are wrong. --- src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java index ab3806aaa..1d7b34f18 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java @@ -21,9 +21,6 @@ /** * StreamError represents a TDS error or message event. -* -* NOTE: Insure that this class is kept serializable because it is held by -* the SQLServerException object which is required to be serializable. */ final class StreamError extends StreamPacket From 34c3d971b4df699a498cfdb522b195b2033a9941 Mon Sep 17 00:00:00 2001 From: gstojsic Date: Thu, 24 Nov 2016 23:43:57 +0100 Subject: [PATCH 14/42] Rename sqlType to tvpName --- .../sqlserver/jdbc/SQLServerDataTable.java | 13 +++++-------- src/main/java/com/microsoft/sqlserver/jdbc/TVP.java | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index 7b2cefc60..1a360537e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -21,9 +21,6 @@ import java.util.*; import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; import java.text.MessageFormat; import java.util.Map.Entry; import java.time.*; @@ -35,7 +32,7 @@ public final class SQLServerDataTable { Map columnMetadata = null; Map rows = null; - private String sqlType = null; + private String tvpName = null; /** * The constant in the Java programming language, sometimes referred to as a type code, @@ -239,13 +236,13 @@ public synchronized Map getColumnMetadata() return columnMetadata; } - public String getSqlType() + public String getTvpName() { - return sqlType; + return tvpName; } - public void setSqlType(String sqlType) + public void setTvpName(String tvpName) { - this.sqlType = sqlType; + this.tvpName = tvpName; } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java index a79c009ac..0264d49fb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java @@ -73,7 +73,7 @@ void initTVP(TVPType type, String tvpPartName) throws SQLServerException TVP(String tvpPartName, SQLServerDataTable tvpDataTable) throws SQLServerException { if (tvpPartName == null) { - tvpPartName = tvpDataTable.getSqlType(); + tvpPartName = tvpDataTable.getTvpName(); } initTVP(TVPType.SQLServerDataTable, tvpPartName); sourceDataTable = tvpDataTable; From ccb6712bb19512c8b00e3d4394f9d6251caea924 Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Thu, 24 Nov 2016 16:37:24 -0700 Subject: [PATCH 15/42] Changes made as per review comments. Update Dependency section in README #18 --- README.md | 70 ++++++++----------------------------------------------- 1 file changed, 10 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index ab18a4b8e..b103e860e 100644 --- a/README.md +++ b/README.md @@ -73,15 +73,20 @@ The driver can be downloaded from the [Microsoft Download Center](https://www.mi This project has following dependencies: Compile Time: - - - `azure-keyvault` + - `azure-keyvault` : Azure Key Vault Provider for Always Encrypted feature Test Time: + - `junit:jar` : For Unit Test cases. - - `junit:jar` - -If anybody wants to use driver as a run-time dependency but not using Azure Web Services for authentication then you either describe as optional dependency or exclude azure. +###Dependency Tree +One can see all dependencies including Transitive Dependency by executing following command. +``` +mvn dependency:tree +``` +###Exclude Dependencies +If you wish to limit the number of run-time dependencies, and your project does not require the features named above, you can explicitly exclude them by adding exclusion tag. +***For Example:*** If you are not using *Always Encrypted Azure Key Vault feature* then you can exclude *azure-keyvault* dependency. Please see following snippet. ``` com.microsoft.sqlserver @@ -97,61 +102,6 @@ If anybody wants to use driver as a run-time dependency but not using Azure Web ``` -###Dependency Tree -``` -mvn dependency:tree -[INFO] Scanning for projects... -[INFO] -[INFO] ------------------------------------------------------------------------ -[INFO] Building Microsoft JDBC Driver for SQL Server 6.1.0 -[INFO] ------------------------------------------------------------------------ -[INFO] -[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mssql-jdbc --- -[INFO] com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0 -[INFO] +- com.microsoft.azure:azure-keyvault:jar:0.9.3:compile -[INFO] | +- com.microsoft.azure:azure-core:jar:0.9.3:compile -[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile -[INFO] | | +- commons-lang:commons-lang:jar:2.6:compile -[INFO] | | +- javax.mail:mail:jar:1.4.5:compile -[INFO] | | | \- javax.activation:activation:jar:1.1:compile -[INFO] | | +- com.sun.jersey:jersey-client:jar:1.13:compile -[INFO] | | | \- com.sun.jersey:jersey-core:jar:1.13:compile -[INFO] | | \- com.sun.jersey:jersey-json:jar:1.13:compile -[INFO] | | +- org.codehaus.jettison:jettison:jar:1.1:compile -[INFO] | | | \- stax:stax-api:jar:1.0.1:compile -[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile -[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile -[INFO] | | | \- javax.xml.stream:stax-api:jar:1.0-2:compile -[INFO] | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile -[INFO] | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile -[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile -[INFO] | | \- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile -[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile -[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.3.3:compile -[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile -[INFO] | +- javax.inject:javax.inject:jar:1:compile -[INFO] | \- com.microsoft.azure:adal4j:jar:1.0.0:compile -[INFO] | +- com.nimbusds:oauth2-oidc-sdk:jar:4.5:compile -[INFO] | | +- net.jcip:jcip-annotations:jar:1.0:compile -[INFO] | | +- org.apache.commons:commons-lang3:jar:3.3.1:compile -[INFO] | | +- net.minidev:json-smart:jar:1.1.1:compile -[INFO] | | +- com.nimbusds:lang-tag:jar:1.4:compile -[INFO] | | \- com.nimbusds:nimbus-jose-jwt:jar:3.1.2:compile -[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.51:compile -[INFO] | +- com.google.code.gson:gson:jar:2.2.4:compile -[INFO] | \- org.slf4j:slf4j-api:jar:1.7.5:compile -[INFO] \- junit:junit:jar:4.12:test -[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 1.423 s -[INFO] Finished at: 2016-11-22T13:13:55-08:00 -[INFO] Final Memory: 12M/304M -[INFO] ------------------------------------------------------------------------ -``` - - ## Guidelines for Reporting Issues We appreciate you taking the time to test the driver, provide feedback and report any issues. It would be extremely helpful if you: From ae9baa5a81f0cd189f9a8c84efcc3a17e43a17f6 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 24 Nov 2016 15:59:32 -0800 Subject: [PATCH 16/42] added AppVeyor and Travic CI build status badges --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 40ed43fb3..6d9f084de 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,14 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. * Run `mvn install -Pbuild41`. This creates JDBC 4.1 compliant jar in \target directory * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory +### AppVeyor Build Status +* master branch: [![Build status](https://ci.appveyor.com/api/projects/status/vsgfwi0jqtlbamnm/branch/master?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc-7l4dn/branch/master) +* dev branch: [![Build status](https://ci.appveyor.com/api/projects/status/vsgfwi0jqtlbamnm/branch/dev?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc-7l4dn/branch/dev) + +### Travis CI Build Status +* master branch: [![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?branch=master)](https://travis-ci.org/Microsoft/mssql-jdbc) +* dev branch: [![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?branch=dev)](https://travis-ci.org/Microsoft/mssql-jdbc) + ## Resources ### Documentation From 8f432d1170544eb6c3555715b26e43edb25344f0 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 24 Nov 2016 16:31:02 -0800 Subject: [PATCH 17/42] fix the AppVeyor badge --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d9f084de..cbcd50b79 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory ### AppVeyor Build Status -* master branch: [![Build status](https://ci.appveyor.com/api/projects/status/vsgfwi0jqtlbamnm/branch/master?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc-7l4dn/branch/master) -* dev branch: [![Build status](https://ci.appveyor.com/api/projects/status/vsgfwi0jqtlbamnm/branch/dev?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc-7l4dn/branch/dev) +* master branch: [![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3/branch/master?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc/branch/master) +* dev branch: [![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3/branch/dev?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc/branch/dev) ### Travis CI Build Status * master branch: [![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?branch=master)](https://travis-ci.org/Microsoft/mssql-jdbc) From 8046f37d1eb090527a35f7ddfb1788d1377a3c2d Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 24 Nov 2016 17:12:05 -0800 Subject: [PATCH 18/42] only show the badge of the most recent build --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cbcd50b79..aa9b00b32 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,10 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory ### AppVeyor Build Status -* master branch: [![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3/branch/master?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc/branch/master) -* dev branch: [![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3/branch/dev?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc/branch/dev) +[![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc) ### Travis CI Build Status -* master branch: [![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?branch=master)](https://travis-ci.org/Microsoft/mssql-jdbc) -* dev branch: [![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?branch=dev)](https://travis-ci.org/Microsoft/mssql-jdbc) +[![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?)](https://travis-ci.org/Microsoft/mssql-jdbc) ## Resources From 108be45571c2ba51fe0a8edc1b632672ec8c7975 Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Thu, 24 Nov 2016 17:59:35 +0100 Subject: [PATCH 19/42] Use Charset throughout The driver spends a lot of time converting from Charset to String and from String to Charset. Every time checked exceptions have to be caught. In addition the Charset lookup code is quite involved. It would be simpler to use Charset everywhere. --- .../com/microsoft/sqlserver/jdbc/DDC.java | 2 +- .../microsoft/sqlserver/jdbc/IOBuffer.java | 28 +++----- .../sqlserver/jdbc/ReaderInputStream.java | 18 +---- .../sqlserver/jdbc/SQLCollation.java | 30 +++++--- .../sqlserver/jdbc/SQLServerBulkCopy.java | 36 ++++------ .../sqlserver/jdbc/SQLServerClob.java | 14 ++-- .../sqlserver/jdbc/SQLServerSQLXML.java | 32 +-------- .../com/microsoft/sqlserver/jdbc/Util.java | 10 +-- .../com/microsoft/sqlserver/jdbc/dtv.java | 71 ++++--------------- 9 files changed, 70 insertions(+), 171 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java index 0a0f36b32..d8b702291 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java @@ -468,7 +468,7 @@ static final Object convertBytesToObject(byte[] bytesValue, JDBCType jdbcType, T */ static final Object convertStringToObject( String stringVal, - String charset, + Charset charset, JDBCType jdbcType, StreamType streamType) throws UnsupportedEncodingException, IllegalArgumentException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 56c93556c..b176601c9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -21,6 +21,7 @@ import java.io.*; import java.nio.*; import java.nio.channels.*; +import java.nio.charset.Charset; import java.net.*; import java.math.*; import java.util.concurrent.*; @@ -3946,7 +3947,7 @@ void writeNonUnicodeReader( Reader reader, long advertisedLength, boolean isDestBinary, - String charSet) throws SQLServerException + Charset charSet) throws SQLServerException { assert DataTypes.UNKNOWN_STREAM_LENGTH == advertisedLength || advertisedLength >= 0; @@ -3997,25 +3998,16 @@ void writeNonUnicodeReader( for (int charsCopied = 0; charsCopied < charsToWrite; ++charsCopied) { - try + if(null == charSet) { - if(null == charSet) - { - streamByteBuffer[charsCopied] = (byte)(streamCharBuffer[charsCopied] & 0xFF); - } - else - { - // encoding as per collation - streamByteBuffer[charsCopied] = new String(streamCharBuffer[charsCopied] + - "") - .getBytes(charSet)[0]; - } + streamByteBuffer[charsCopied] = (byte)(streamCharBuffer[charsCopied] & 0xFF); } - catch (UnsupportedEncodingException e) + else { - throw new SQLServerException( - SQLServerException.getErrString("R_encodingErrorWritingTDS"), - e); + // encoding as per collation + streamByteBuffer[charsCopied] = new String(streamCharBuffer[charsCopied] + + "") + .getBytes(charSet)[0]; } } writeBytes(streamByteBuffer, 0, charsToWrite); @@ -7257,7 +7249,7 @@ final Object readGUID(int valueLength, JDBCType jdbcType, StreamType streamType) try { - return DDC.convertStringToObject(sb.toString(), Encoding.UNICODE.charsetName(), jdbcType, streamType); + return DDC.convertStringToObject(sb.toString(), Encoding.UNICODE.charset(), jdbcType, streamType); } catch (UnsupportedEncodingException e) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java index e98fbecef..623ca9d88 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java @@ -66,26 +66,14 @@ class ReaderInputStream extends InputStream private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0); private ByteBuffer encodedChars = EMPTY_BUFFER; - ReaderInputStream(Reader reader, String charsetName, long readerLength) throws UnsupportedEncodingException + ReaderInputStream(Reader reader, Charset charset, long readerLength) { assert reader != null; - assert charsetName != null; + assert charset != null; assert DataTypes.UNKNOWN_STREAM_LENGTH == readerLength || readerLength >= 0; this.reader = reader; - try - { - this.charset = Charset.forName(charsetName); - } - catch (IllegalCharsetNameException e) - { - throw new UnsupportedEncodingException(e.getMessage()); - } - catch (UnsupportedCharsetException e) - { - throw new UnsupportedEncodingException(e.getMessage()); - } - + this.charset = charset; this.readerLength = readerLength; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java index bffdc0757..38ad09b05 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java @@ -20,6 +20,7 @@ package com.microsoft.sqlserver.jdbc; import java.io.*; +import java.nio.charset.Charset; import java.util.*; import java.text.MessageFormat; @@ -49,7 +50,7 @@ final class SQLCollation implements java.io.Serializable private final Encoding encoding; // Utility methods for getting details of this collation's encoding - final String getCharset() { return encoding.charsetName(); } + final Charset getCharset() throws SQLServerException { return encoding.charset(); } final boolean supportsAsciiConversion() { return encoding.supportsAsciiConversion(); } final boolean hasAsciiCompatibleSBCS() { return encoding.hasAsciiCompatibleSBCS(); } @@ -541,7 +542,7 @@ private Encoding encodingFromSortId() throws UnsupportedEncodingException /** * Enumeration of encodings that are supported by SQL Server (and hopefully the JVM). * - * See, for example, http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html + * See, for example, https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html * for a complete list of supported encodings with their canonical names. */ enum Encoding @@ -568,6 +569,7 @@ enum Encoding private final boolean supportsAsciiConversion; private final boolean hasAsciiCompatibleSBCS; private boolean jvmSupportConfirmed = false; + private Charset charset; private Encoding( String charsetName, @@ -585,11 +587,7 @@ final Encoding checkSupported() throws UnsupportedEncodingException { // Checks for support by converting a java.lang.String // This works for all of the code pages above in SE 5 and later. - try - { - " ".getBytes(charsetName); - } - catch (UnsupportedEncodingException e) + if (!Charset.isSupported(charsetName)) { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_codePageNotSupported")); Object[] msgArgs = {charsetName}; @@ -602,7 +600,23 @@ final Encoding checkSupported() throws UnsupportedEncodingException return this; } - final String charsetName() { return charsetName; } + final Charset charset() throws SQLServerException + { + try + { + checkSupported(); + if (charset == null) + { + charset = Charset.forName(charsetName); + } + } catch (UnsupportedEncodingException e) + { + MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_codePageNotSupported")); + Object[] msgArgs = {charsetName}; + throw new SQLServerException(form.format(msgArgs), e); + } + return charset; + } /** * Returns true if the collation supports conversion to ascii. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index 0779d5189..aaa1af0d1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -24,7 +24,6 @@ import java.io.InputStream; import java.io.Reader; import java.io.StringReader; -import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -2552,31 +2551,22 @@ else if (null != sourceBulkRecord) } else { - try + tdsWriter.writeShort((short) (colValueStr.length())); + // converting string into destination collation using Charset + + SQLCollation destCollation = destColumnMetadata + .get(destColOrdinal).collation; + if (null != destCollation) { - tdsWriter.writeShort((short) (colValueStr.length())); - // converting string into destination collation using Charset + tdsWriter.writeBytes(colValueStr.getBytes( + destColumnMetadata.get(destColOrdinal).collation + .getCharset())); - SQLCollation destCollation = destColumnMetadata - .get(destColOrdinal).collation; - if (null != destCollation) - { - tdsWriter.writeBytes(colValueStr.getBytes( - destColumnMetadata.get(destColOrdinal).collation - .getCharset())); - - } - else - { - tdsWriter.writeBytes(colValueStr.getBytes()); - } } - catch (UnsupportedEncodingException e) - { - throw new SQLServerException( - SQLServerException.getErrString("R_encodingErrorWritingTDS"), - e); - } + else + { + tdsWriter.writeBytes(colValueStr.getBytes()); + } } } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java index 28d2a4d01..dae0a2944 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java @@ -24,6 +24,8 @@ import java.util.*; import java.util.logging.*; +import static java.nio.charset.StandardCharsets.US_ASCII; + /** * SQLServerClob represents a character LOB object and implements java.sql.Clob. */ @@ -186,16 +188,8 @@ public InputStream getAsciiStream() throws SQLException if (null != sqlCollation && !sqlCollation.supportsAsciiConversion()) DataTypes.throwConversionError(getDisplayClassName(), "AsciiStream"); - InputStream getterStream; - try - { - // Need to use a BufferedInputStream since the stream returned by this method is assumed to support mark/reset - getterStream = new BufferedInputStream(new ReaderInputStream(new StringReader(value), "US-ASCII", value.length())); - } - catch (UnsupportedEncodingException unsupportedEncodingException) - { - throw new SQLServerException(unsupportedEncodingException.getMessage(), null, 0, unsupportedEncodingException); - } + // Need to use a BufferedInputStream since the stream returned by this method is assumed to support mark/reset + InputStream getterStream = new BufferedInputStream(new ReaderInputStream(new StringReader(value), US_ASCII, value.length())); activeStreams.add(getterStream); return getterStream; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java index 6b9a9864c..c52fe1d75 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java @@ -101,7 +101,6 @@ InputStream getValue() throws SQLServerException ByteArrayOutputStreamToInputStream strm = new ByteArrayOutputStreamToInputStream(); // Need to beat a stream out of docValue TransformerFactory factory; - Writer wr=null; try { factory = TransformerFactory.newInstance(); @@ -126,14 +125,7 @@ InputStream getValue() throws SQLServerException assert null ==outputStreamValue; assert null == docValue; assert null !=strValue; - try - { - o = new ByteArrayInputStream(strValue.getBytes(Encoding.UNICODE.charsetName())); - } - catch (UnsupportedEncodingException ex) - { - throw new SQLServerException(null, ex.getMessage(), null, 0, true); - } + o = new ByteArrayInputStream(strValue.getBytes(Encoding.UNICODE.charset())); } assert null != o; isFreed = true; // we have consumed the data @@ -252,16 +244,7 @@ public java.io.Writer setCharacterStream() throws SQLException checkWriteXML(); isUsed = true; outputStreamValue = new ByteArrayOutputStreamToInputStream(); - java.io.Writer wrt=null; - try - { - wrt = new OutputStreamWriter(outputStreamValue, Encoding.UNICODE.charsetName()); - } - catch (UnsupportedEncodingException ex) - { - throw new SQLServerException(null, ex.getMessage(), null, 0, true); - } - return wrt; + return new OutputStreamWriter(outputStreamValue, Encoding.UNICODE.charset()); } public Reader getCharacterStream() throws SQLException { @@ -309,16 +292,7 @@ public String getString() throws SQLException } byte byteContents[] = contents.getBytes(); - String ret = null; - try - { - ret = new String(byteContents,0, byteContents.length, Encoding.UNICODE.charsetName() ); - } - catch (UnsupportedEncodingException ex) - { - throw new SQLServerException(null, ex.getMessage(), null, 0, true); - } - return ret; + return new String(byteContents,0, byteContents.length, Encoding.UNICODE.charset() ); } public void setString(String value) throws SQLException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index d37a37d42..57e1d0c3d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -619,15 +619,7 @@ static String readUnicodeString(byte [] b, int offset, int byteLength, SQLServer { try { - return new String(b, offset, byteLength, Encoding.UNICODE.charsetName()); - } - catch (UnsupportedEncodingException ex) - { - String txtMsg = SQLServerException.checkAndAppendClientConnId(SQLServerException.getErrString("R_stringReadError"), conn); - MessageFormat form = new MessageFormat(txtMsg); - Object[] msgArgs = {new Integer(offset)}; - // Re-throw SQLServerException if conversion fails. - throw new SQLServerException(null, form.format(msgArgs), null, 0, true); + return new String(b, offset, byteLength, Encoding.UNICODE.charset()); } catch (IndexOutOfBoundsException ex) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java index 7f6325e28..f113a970c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java @@ -26,6 +26,7 @@ import java.math.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.charset.Charset; import java.sql.*; import java.text.MessageFormat; import java.time.*; @@ -325,26 +326,10 @@ void execute(DTV dtv, Clob clobValue) throws SQLServerException } else { - ReaderInputStream clobStream = null; - - try - { - clobStream = new ReaderInputStream( - clobReader, - collation.getCharset(), - clobLength); - } - catch (UnsupportedEncodingException ex) - { - MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; - SQLServerException.makeFromDriverError( - conn, - null, - form.format(msgArgs), - null, - true); - } + ReaderInputStream clobStream = new ReaderInputStream( + clobReader, + collation.getCharset(), + clobLength); tdsWriter.writeRPCInputStream( name, @@ -2347,21 +2332,7 @@ else if (null != collation && if (null != strValue) { - try - { - nativeEncoding = strValue.getBytes(collation.getCharset()); - } - catch (UnsupportedEncodingException ex) - { - MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; - SQLServerException.makeFromDriverError( - con, - null, - form.format(msgArgs), - null, // Don't close the connection - true); - } + nativeEncoding = strValue.getBytes(collation.getCharset()); } dtv.setValue(nativeEncoding, JavaType.BYTEARRAY); @@ -2631,26 +2602,10 @@ else if (null != collation && JDBCType.LONGVARCHAR == jdbcType || JDBCType.CLOB == jdbcType)) { - ReaderInputStream streamValue = null; - - try - { - streamValue = new ReaderInputStream( + ReaderInputStream streamValue = new ReaderInputStream( readerValue, collation.getCharset(), readerLength); - } - catch (UnsupportedEncodingException ex) - { - MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS")); - Object[] msgArgs = {new String(ex.getMessage())}; - SQLServerException.makeFromDriverError( - con, - null, - form.format(msgArgs), - null, // Don't close the connection - true); - } dtv.setValue(streamValue, JavaType.INPUTSTREAM); @@ -2780,7 +2735,7 @@ final class TypeInfo // Collation (will be null for non-textual types). private SQLCollation collation; - private String charset; + private Charset charset; SSType getSSType() { return ssType; } SSLenType getSSLenType() { return ssLenType; } @@ -2791,7 +2746,7 @@ final class TypeInfo int getScale() { return scale; } SQLCollation getSQLCollation() { return collation; } void setSQLCollation(SQLCollation collation) { this.collation = collation; } - String getCharset() { return charset; } + Charset getCharset() { return charset; } boolean isNullable() { return 0x0001 == (flags & 0x0001); } boolean isCaseSensitive() { return 0x0002 == (flags & 0x0002); } boolean isSparseColumnSet() { return 0x0400 == (flags & 0x0400); } @@ -3085,7 +3040,7 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept typeInfo.displaySize = typeInfo.precision = typeInfo.maxLength / 2; typeInfo.ssType = SSType.NCHAR; typeInfo.collation = tdsReader.readCollation(); - typeInfo.charset = Encoding.UNICODE.charsetName(); + typeInfo.charset = Encoding.UNICODE.charset(); } }), @@ -3111,7 +3066,7 @@ else if (typeInfo.maxLength <= DataTypes.SHORT_VARTYPE_MAX_BYTES && 0 == typeInf tdsReader.throwInvalidTDS(); } typeInfo.collation = tdsReader.readCollation(); - typeInfo.charset = Encoding.UNICODE.charsetName(); + typeInfo.charset = Encoding.UNICODE.charset(); } }), @@ -3126,7 +3081,7 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept typeInfo.ssType = SSType.NTEXT; typeInfo.displaySize = typeInfo.precision = Integer.MAX_VALUE / 2; typeInfo.collation = tdsReader.readCollation(); - typeInfo.charset = Encoding.UNICODE.charsetName(); + typeInfo.charset = Encoding.UNICODE.charset(); } }), @@ -3185,7 +3140,7 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept typeInfo.ssLenType = SSLenType.PARTLENTYPE; typeInfo.ssType = SSType.XML; typeInfo.displaySize = typeInfo.precision = Integer.MAX_VALUE / 2; - typeInfo.charset = Encoding.UNICODE.charsetName(); + typeInfo.charset = Encoding.UNICODE.charset(); } }), From 676b2b0ad2cc0dece19659daa218a85ab86dd259 Mon Sep 17 00:00:00 2001 From: gstojsic Date: Sat, 26 Nov 2016 00:38:05 +0100 Subject: [PATCH 20/42] Corrected CRLF to LF --- .../sqlserver/jdbc/KerbAuthentication.java | 680 +++---- .../jdbc/SQLServerConnectionPoolProxy.java | 1185 +++++------ .../sqlserver/jdbc/SQLServerDataSource.java | 1751 +++++++++-------- .../jdbc/SQLServerPooledConnection.java | 528 ++--- 4 files changed, 2073 insertions(+), 2071 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java index 46e9adb9c..06ee22124 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java @@ -1,340 +1,340 @@ -//--------------------------------------------------------------------------------------------------------------------------------- -// File: KerbAuthentication.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), -// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//--------------------------------------------------------------------------------------------------------------------------------- - - -package com.microsoft.sqlserver.jdbc; -import java.util.logging.*; -import org.ietf.jgss.*; -import javax.security.auth.Subject; -import java.util.*; -import javax.security.auth.login.*; -import java.net.IDN; -import java.security.*; - - -/** -* KerbAuthentication for int auth. -*/ -final class KerbAuthentication extends SSPIAuthentication -{ - private final static String CONFIGNAME = "SQLJDBCDriver"; - private final static java.util.logging.Logger authLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.KerbAuthentication"); - - private final SQLServerConnection con; - private final String spn; - - private final GSSManager manager = GSSManager.getInstance(); - private LoginContext lc = null; - private GSSCredential peerCredentials = null; - private GSSContext peerContext = null; - - - static - { - // The driver on load will look to see if there is a configuration set for the SQLJDBCDriver, if not it will install its - // own configuration. Note it is possible that there is a configuration exists but it does not contain a configuration entry - // for the driver in that case, we will override the configuration but will flow the configuration requests to existing - // config for anything other than SQLJDBCDriver - // - class SQLJDBCDriverConfig extends Configuration - { - Configuration current = null; - AppConfigurationEntry[] driverConf; - - SQLJDBCDriverConfig() - { - try - { - current = Configuration.getConfiguration(); - } - catch (SecurityException e) - { - // if we cant get the configuration, it is likely that no configuration has been specified. So go ahead and set the config - authLogger.finer(toString() + " No configurations provided, setting driver default"); - } - AppConfigurationEntry[] config = null; - - if(null != current) - { - config = current.getAppConfigurationEntry(CONFIGNAME); - } - // If there is user provided configuration we leave use that and not install our configuration - if(null == config) - { - if (authLogger.isLoggable(Level.FINER)) - authLogger.finer(toString() + " SQLJDBCDriver configuration entry is not provided, setting driver default"); - - AppConfigurationEntry appConf; - if(Util.isIBM()) - { - Map confDetails = new HashMap(); - confDetails.put("useDefaultCcache", "true"); - confDetails.put("moduleBanner", "false"); - appConf = new AppConfigurationEntry("com.ibm.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, confDetails); - if (authLogger.isLoggable(Level.FINER)) - authLogger.finer(toString() + " Setting IBM Krb5LoginModule"); - } - else - { - Map confDetails = new HashMap(); - confDetails.put("useTicketCache", "true"); - confDetails.put("doNotPrompt", "true"); - appConf = new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, confDetails); - if (authLogger.isLoggable(Level.FINER)) - authLogger.finer(toString() + " Setting Sun Krb5LoginModule"); - } - driverConf = new AppConfigurationEntry[1]; - driverConf[0] = appConf; - Configuration.setConfiguration(this); - } - - } - - public AppConfigurationEntry[] getAppConfigurationEntry(String name) - { - // we should only handle anything that is related to our part, everything else is handled by the configuration - // already existing configuration if there is one. - if(name.equals(CONFIGNAME)) - { - return driverConf; - } - else - { - if(null != current) - return current.getAppConfigurationEntry(name); - else - return null; - } - } - - public void refresh() - { - if(null != current) - current.refresh(); - } - } - SQLJDBCDriverConfig driverconfig = new SQLJDBCDriverConfig(); - } - - private void intAuthInit() throws SQLServerException - { - try - { - // If we need to support NTLM as well, we can use null - // Kerberos OID - Oid kerberos = new Oid("1.2.840.113554.1.2.2"); - Subject currentSubject=null; - try - { - AccessControlContext context = AccessController.getContext(); - currentSubject = Subject.getSubject(context); - if(null == currentSubject) - { - lc = new LoginContext(CONFIGNAME); - lc.login(); - // per documentation LoginContext will instantiate a new subject. - currentSubject = lc.getSubject(); - } - } - catch (LoginException le) - { - con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), le); - } - - // http://blogs.sun.com/harcey/entry/of_java_kerberos_and_access - // We pass null to indicate that the system should interpret the SPN as it is. - GSSName remotePeerName = manager.createName(spn, null); - if (authLogger.isLoggable(Level.FINER)) - { - authLogger.finer(toString() + " Getting client credentials"); - } - peerCredentials = getClientCredential(currentSubject,manager, kerberos); - if (authLogger.isLoggable(Level.FINER)) - { - authLogger.finer(toString() + " creating security context"); - } - - peerContext = manager.createContext(remotePeerName, - kerberos, - peerCredentials, - GSSContext.DEFAULT_LIFETIME); - // The following flags should be inline with our native implementation. - peerContext.requestCredDeleg(true); - peerContext.requestMutualAuth(true); - peerContext.requestInteg(true); - } - - catch(GSSException ge) - { - authLogger.finer(toString() + "initAuthInit failed GSSException:-" + ge); - con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); - } - catch(PrivilegedActionException ge) - { - authLogger.finer(toString() + "initAuthInit failed privileged exception:-" + ge); - con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); - } - - - } - - // We have to do a privileged action to create the credential of the user in the current context - private static GSSCredential getClientCredential(final Subject subject, final GSSManager MANAGER, final Oid kerboid) - throws PrivilegedActionException - { - final PrivilegedExceptionAction action = - new PrivilegedExceptionAction() { - public GSSCredential run() throws GSSException { - return MANAGER.createCredential( - null // use the default principal - , GSSCredential.DEFAULT_LIFETIME - ,kerboid - , GSSCredential.INITIATE_ONLY); - } - }; - // TO support java 5, 6 we have to do this - // The signature for Java 5 returns an object 6 returns GSSCredential, immediate casting throws - // warning in Java 6. - Object credential = Subject.doAs(subject, action); - return (GSSCredential)credential; - } - private byte [] intAuthHandShake(byte[] pin, boolean[] done) throws SQLServerException - { - try - { - if (authLogger.isLoggable(Level.FINER)) - { - authLogger.finer(toString() + " Sending token to server over secure context"); - } - byte [] byteToken = peerContext.initSecContext(pin, 0, pin.length); - - if (peerContext.isEstablished()) - { - done[0] = true; - if (authLogger.isLoggable(Level.FINER)) - authLogger.finer(toString() + "Authentication done."); - } - else - if (null == byteToken) - { - // The documentation is not clear on when this can happen but it does say this could happen - authLogger.info(toString() + "byteToken is null in initSecContext."); - con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed")); - } - return byteToken; - } - catch(GSSException ge) - { - authLogger.finer(toString() + "initSecContext Failed :-" + ge); - con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); - } - // keep the compiler happy - return null; - } - - private String makeSpn(String server, int port) throws SQLServerException - { - if (authLogger.isLoggable(Level.FINER)) - { - authLogger.finer(toString() + " Server: " + server + " port: " + port); - } - StringBuilder spn = new StringBuilder("MSSQLSvc/"); - //Format is MSSQLSvc/myhost.domain.company.com:1433 - // FQDN must be provided - if(con.serverNameAsACE()) - { - spn.append(IDN.toASCII(server)); - } - else - { - spn.append(server); - } - spn.append(":"); - spn.append(port); - String strSPN = spn.toString(); - if (authLogger.isLoggable(Level.FINER)) - { - authLogger.finer(toString() + " SPN: " + strSPN); - } - return strSPN; - } - - // Package visible members below. - KerbAuthentication(SQLServerConnection con, String address, int port) throws SQLServerException - { - this.con = con; - // Get user provided SPN string; if not provided then build the generic one - String userSuppliedServerSpn = con.activeConnectionProperties. - getProperty(SQLServerDriverStringProperty.SERVER_SPN.toString()); - - if (null != userSuppliedServerSpn) - { - // serverNameAsACE is true, translate the user supplied serverSPN to ASCII - if(con.serverNameAsACE()) - { - int slashPos = userSuppliedServerSpn.indexOf("/"); - spn = userSuppliedServerSpn.substring(0,slashPos+1) - + IDN.toASCII(userSuppliedServerSpn.substring(slashPos+1)); - } - else - { - spn = userSuppliedServerSpn; - } - } - else - { - spn = makeSpn(address, port); - } - } - - byte[] GenerateClientContext(byte[] pin, boolean[] done ) throws SQLServerException - { - if(null == peerContext) - { - intAuthInit(); - } - return intAuthHandShake(pin, done); - } - int ReleaseClientContext() throws SQLServerException - { - try - { - if(null != peerCredentials) - peerCredentials.dispose(); - if(null != peerContext) - peerContext.dispose(); - if(null != lc) - lc.logout(); - } - catch(LoginException e) - { - // yes we are eating exceptions here but this should not fail in the normal circumstances and we do not want to eat previous - // login errors if caused before which is more useful to the user than the cleanup errors. - authLogger.fine(toString() + " Release of the credentials failed LoginException: " + e); - } - catch(GSSException e) - { - // yes we are eating exceptions here but this should not fail in the normal circumstances and we do not want to eat previous - // login errors if caused before which is more useful to the user than the cleanup errors. - authLogger.fine(toString() + " Release of the credentials failed GSSException: " + e); - } - return 0; - } -} - - +//--------------------------------------------------------------------------------------------------------------------------------- +// File: KerbAuthentication.java +// +// +// Microsoft JDBC Driver for SQL Server +// Copyright(c) Microsoft Corporation +// All rights reserved. +// MIT License +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//--------------------------------------------------------------------------------------------------------------------------------- + + +package com.microsoft.sqlserver.jdbc; +import java.util.logging.*; +import org.ietf.jgss.*; +import javax.security.auth.Subject; +import java.util.*; +import javax.security.auth.login.*; +import java.net.IDN; +import java.security.*; + + +/** +* KerbAuthentication for int auth. +*/ +final class KerbAuthentication extends SSPIAuthentication +{ + private final static String CONFIGNAME = "SQLJDBCDriver"; + private final static java.util.logging.Logger authLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.KerbAuthentication"); + + private final SQLServerConnection con; + private final String spn; + + private final GSSManager manager = GSSManager.getInstance(); + private LoginContext lc = null; + private GSSCredential peerCredentials = null; + private GSSContext peerContext = null; + + + static + { + // The driver on load will look to see if there is a configuration set for the SQLJDBCDriver, if not it will install its + // own configuration. Note it is possible that there is a configuration exists but it does not contain a configuration entry + // for the driver in that case, we will override the configuration but will flow the configuration requests to existing + // config for anything other than SQLJDBCDriver + // + class SQLJDBCDriverConfig extends Configuration + { + Configuration current = null; + AppConfigurationEntry[] driverConf; + + SQLJDBCDriverConfig() + { + try + { + current = Configuration.getConfiguration(); + } + catch (SecurityException e) + { + // if we cant get the configuration, it is likely that no configuration has been specified. So go ahead and set the config + authLogger.finer(toString() + " No configurations provided, setting driver default"); + } + AppConfigurationEntry[] config = null; + + if(null != current) + { + config = current.getAppConfigurationEntry(CONFIGNAME); + } + // If there is user provided configuration we leave use that and not install our configuration + if(null == config) + { + if (authLogger.isLoggable(Level.FINER)) + authLogger.finer(toString() + " SQLJDBCDriver configuration entry is not provided, setting driver default"); + + AppConfigurationEntry appConf; + if(Util.isIBM()) + { + Map confDetails = new HashMap(); + confDetails.put("useDefaultCcache", "true"); + confDetails.put("moduleBanner", "false"); + appConf = new AppConfigurationEntry("com.ibm.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, confDetails); + if (authLogger.isLoggable(Level.FINER)) + authLogger.finer(toString() + " Setting IBM Krb5LoginModule"); + } + else + { + Map confDetails = new HashMap(); + confDetails.put("useTicketCache", "true"); + confDetails.put("doNotPrompt", "true"); + appConf = new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, confDetails); + if (authLogger.isLoggable(Level.FINER)) + authLogger.finer(toString() + " Setting Sun Krb5LoginModule"); + } + driverConf = new AppConfigurationEntry[1]; + driverConf[0] = appConf; + Configuration.setConfiguration(this); + } + + } + + public AppConfigurationEntry[] getAppConfigurationEntry(String name) + { + // we should only handle anything that is related to our part, everything else is handled by the configuration + // already existing configuration if there is one. + if(name.equals(CONFIGNAME)) + { + return driverConf; + } + else + { + if(null != current) + return current.getAppConfigurationEntry(name); + else + return null; + } + } + + public void refresh() + { + if(null != current) + current.refresh(); + } + } + SQLJDBCDriverConfig driverconfig = new SQLJDBCDriverConfig(); + } + + private void intAuthInit() throws SQLServerException + { + try + { + // If we need to support NTLM as well, we can use null + // Kerberos OID + Oid kerberos = new Oid("1.2.840.113554.1.2.2"); + Subject currentSubject=null; + try + { + AccessControlContext context = AccessController.getContext(); + currentSubject = Subject.getSubject(context); + if(null == currentSubject) + { + lc = new LoginContext(CONFIGNAME); + lc.login(); + // per documentation LoginContext will instantiate a new subject. + currentSubject = lc.getSubject(); + } + } + catch (LoginException le) + { + con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), le); + } + + // http://blogs.sun.com/harcey/entry/of_java_kerberos_and_access + // We pass null to indicate that the system should interpret the SPN as it is. + GSSName remotePeerName = manager.createName(spn, null); + if (authLogger.isLoggable(Level.FINER)) + { + authLogger.finer(toString() + " Getting client credentials"); + } + peerCredentials = getClientCredential(currentSubject,manager, kerberos); + if (authLogger.isLoggable(Level.FINER)) + { + authLogger.finer(toString() + " creating security context"); + } + + peerContext = manager.createContext(remotePeerName, + kerberos, + peerCredentials, + GSSContext.DEFAULT_LIFETIME); + // The following flags should be inline with our native implementation. + peerContext.requestCredDeleg(true); + peerContext.requestMutualAuth(true); + peerContext.requestInteg(true); + } + + catch(GSSException ge) + { + authLogger.finer(toString() + "initAuthInit failed GSSException:-" + ge); + con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); + } + catch(PrivilegedActionException ge) + { + authLogger.finer(toString() + "initAuthInit failed privileged exception:-" + ge); + con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); + } + + + } + + // We have to do a privileged action to create the credential of the user in the current context + private static GSSCredential getClientCredential(final Subject subject, final GSSManager MANAGER, final Oid kerboid) + throws PrivilegedActionException + { + final PrivilegedExceptionAction action = + new PrivilegedExceptionAction() { + public GSSCredential run() throws GSSException { + return MANAGER.createCredential( + null // use the default principal + , GSSCredential.DEFAULT_LIFETIME + ,kerboid + , GSSCredential.INITIATE_ONLY); + } + }; + // TO support java 5, 6 we have to do this + // The signature for Java 5 returns an object 6 returns GSSCredential, immediate casting throws + // warning in Java 6. + Object credential = Subject.doAs(subject, action); + return (GSSCredential)credential; + } + private byte [] intAuthHandShake(byte[] pin, boolean[] done) throws SQLServerException + { + try + { + if (authLogger.isLoggable(Level.FINER)) + { + authLogger.finer(toString() + " Sending token to server over secure context"); + } + byte [] byteToken = peerContext.initSecContext(pin, 0, pin.length); + + if (peerContext.isEstablished()) + { + done[0] = true; + if (authLogger.isLoggable(Level.FINER)) + authLogger.finer(toString() + "Authentication done."); + } + else + if (null == byteToken) + { + // The documentation is not clear on when this can happen but it does say this could happen + authLogger.info(toString() + "byteToken is null in initSecContext."); + con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed")); + } + return byteToken; + } + catch(GSSException ge) + { + authLogger.finer(toString() + "initSecContext Failed :-" + ge); + con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), ge); + } + // keep the compiler happy + return null; + } + + private String makeSpn(String server, int port) throws SQLServerException + { + if (authLogger.isLoggable(Level.FINER)) + { + authLogger.finer(toString() + " Server: " + server + " port: " + port); + } + StringBuilder spn = new StringBuilder("MSSQLSvc/"); + //Format is MSSQLSvc/myhost.domain.company.com:1433 + // FQDN must be provided + if(con.serverNameAsACE()) + { + spn.append(IDN.toASCII(server)); + } + else + { + spn.append(server); + } + spn.append(":"); + spn.append(port); + String strSPN = spn.toString(); + if (authLogger.isLoggable(Level.FINER)) + { + authLogger.finer(toString() + " SPN: " + strSPN); + } + return strSPN; + } + + // Package visible members below. + KerbAuthentication(SQLServerConnection con, String address, int port) throws SQLServerException + { + this.con = con; + // Get user provided SPN string; if not provided then build the generic one + String userSuppliedServerSpn = con.activeConnectionProperties. + getProperty(SQLServerDriverStringProperty.SERVER_SPN.toString()); + + if (null != userSuppliedServerSpn) + { + // serverNameAsACE is true, translate the user supplied serverSPN to ASCII + if(con.serverNameAsACE()) + { + int slashPos = userSuppliedServerSpn.indexOf("/"); + spn = userSuppliedServerSpn.substring(0,slashPos+1) + + IDN.toASCII(userSuppliedServerSpn.substring(slashPos+1)); + } + else + { + spn = userSuppliedServerSpn; + } + } + else + { + spn = makeSpn(address, port); + } + } + + byte[] GenerateClientContext(byte[] pin, boolean[] done ) throws SQLServerException + { + if(null == peerContext) + { + intAuthInit(); + } + return intAuthHandShake(pin, done); + } + int ReleaseClientContext() throws SQLServerException + { + try + { + if(null != peerCredentials) + peerCredentials.dispose(); + if(null != peerContext) + peerContext.dispose(); + if(null != lc) + lc.logout(); + } + catch(LoginException e) + { + // yes we are eating exceptions here but this should not fail in the normal circumstances and we do not want to eat previous + // login errors if caused before which is more useful to the user than the cleanup errors. + authLogger.fine(toString() + " Release of the credentials failed LoginException: " + e); + } + catch(GSSException e) + { + // yes we are eating exceptions here but this should not fail in the normal circumstances and we do not want to eat previous + // login errors if caused before which is more useful to the user than the cleanup errors. + authLogger.fine(toString() + " Release of the credentials failed GSSException: " + e); + } + return 0; + } +} + + diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java index 1de5d5d01..13992a77b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java @@ -1,592 +1,593 @@ -//--------------------------------------------------------------------------------------------------------------------------------- -// File: SQLServerConnectionPoolProxy.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), -// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//--------------------------------------------------------------------------------------------------------------------------------- - - -package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.util.*; -import java.util.logging.*; -import java.util.concurrent.Executor; -import java.text.*; - -/** -* SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. -* When returning a connection object from PooledConnection.getConnection we returnt 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, java.io.Serializable -{ - private SQLServerConnection wrappedConnection; - private boolean bIsOpen; - static private int baseConnectionID=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 synchronized static int nextConnectionID() - { - baseConnectionID++; - return baseConnectionID; - } - - 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 transcation. - * - * @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 - { - DriverJDBCVersion.checkSupportsJDBC41(); - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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 - { - DriverJDBCVersion.checkSupportsJDBC41(); - - // The driver currently does not implement JDDBC 4.1 APIs - throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); - } - - public void setNetworkTimeout(Executor executor, int timeout) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC41(); - - // The driver currently does not implement JDDBC 4.1 APIs - throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); - } - - public String getSchema() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC41(); - - checkClosed(); - return wrappedConnection.getSchema(); - } - - public void setSchema(String schema) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC41(); - - checkClosed(); - wrappedConnection.setSchema(schema); - } - - public java.sql.Array createArrayOf(String typeName, Object[] elements) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createArrayOf(typeName, elements); - } - - public Blob createBlob() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createBlob(); - } - - public Clob createClob() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createClob(); - } - - public NClob createNClob() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createNClob(); - } - - public SQLXML createSQLXML() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createSQLXML(); - } - - public Struct createStruct(String typeName, Object[] attributes) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.createStruct(typeName, attributes); - } - - public Properties getClientInfo() throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.getClientInfo(); - } - - public String getClientInfo(String name) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.getClientInfo(name); - } - - public void setClientInfo(Properties properties) throws SQLClientInfoException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - // No checkClosed() call since we can only throw SQLClientInfoException from here - wrappedConnection.setClientInfo(properties); - } - - public void setClientInfo(String name, String value) throws SQLClientInfoException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - // No checkClosed() call since we can only throw SQLClientInfoException from here - wrappedConnection.setClientInfo(name, value); - } - - public boolean isValid(int timeout) throws SQLException - { - DriverJDBCVersion.checkSupportsJDBC4(); - - checkClosed(); - return wrappedConnection.isValid(timeout); - } - - public boolean isWrapperFor(Class iface) throws SQLException - { - wrappedConnection.getConnectionLogger().entering ( toString(), "isWrapperFor", iface ); - DriverJDBCVersion.checkSupportsJDBC4(); - 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 ); - DriverJDBCVersion.checkSupportsJDBC4(); - 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(); - } - - public synchronized void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException - { - checkClosed(); - wrappedConnection.setSendTimeAsDatetime(sendTimeAsDateTimeValue); - } - - public synchronized final boolean getSendTimeAsDatetime() throws SQLServerException - { - checkClosed(); - return wrappedConnection.getSendTimeAsDatetime(); - } -} +//--------------------------------------------------------------------------------------------------------------------------------- +// File: SQLServerConnectionPoolProxy.java +// +// +// Microsoft JDBC Driver for SQL Server +// Copyright(c) Microsoft Corporation +// All rights reserved. +// MIT License +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//--------------------------------------------------------------------------------------------------------------------------------- + + +package com.microsoft.sqlserver.jdbc; +import java.sql.*; +import java.util.*; +import java.util.logging.*; +import java.util.concurrent.Executor; +import java.text.*; + +/** +* SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. +* When returning a connection object from PooledConnection.getConnection we returnt 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, java.io.Serializable +{ + private SQLServerConnection wrappedConnection; + private boolean bIsOpen; + static private int baseConnectionID=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 synchronized static int nextConnectionID() + { + baseConnectionID++; + return baseConnectionID; + } + + 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 transcation. + * + * @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 + { + DriverJDBCVersion.checkSupportsJDBC41(); + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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 + { + DriverJDBCVersion.checkSupportsJDBC41(); + + // The driver currently does not implement JDDBC 4.1 APIs + throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); + } + + public void setNetworkTimeout(Executor executor, int timeout) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC41(); + + // The driver currently does not implement JDDBC 4.1 APIs + throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); + } + + public String getSchema() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC41(); + + checkClosed(); + return wrappedConnection.getSchema(); + } + + public void setSchema(String schema) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC41(); + + checkClosed(); + wrappedConnection.setSchema(schema); + } + + public java.sql.Array createArrayOf(String typeName, Object[] elements) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createArrayOf(typeName, elements); + } + + public Blob createBlob() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createBlob(); + } + + public Clob createClob() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createClob(); + } + + public NClob createNClob() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createNClob(); + } + + public SQLXML createSQLXML() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createSQLXML(); + } + + public Struct createStruct(String typeName, Object[] attributes) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.createStruct(typeName, attributes); + } + + public Properties getClientInfo() throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.getClientInfo(); + } + + public String getClientInfo(String name) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.getClientInfo(name); + } + + public void setClientInfo(Properties properties) throws SQLClientInfoException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + // No checkClosed() call since we can only throw SQLClientInfoException from here + wrappedConnection.setClientInfo(properties); + } + + public void setClientInfo(String name, String value) throws SQLClientInfoException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + // No checkClosed() call since we can only throw SQLClientInfoException from here + wrappedConnection.setClientInfo(name, value); + } + + public boolean isValid(int timeout) throws SQLException + { + DriverJDBCVersion.checkSupportsJDBC4(); + + checkClosed(); + return wrappedConnection.isValid(timeout); + } + + public boolean isWrapperFor(Class iface) throws SQLException + { + wrappedConnection.getConnectionLogger().entering ( toString(), "isWrapperFor", iface ); + DriverJDBCVersion.checkSupportsJDBC4(); + 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 ); + DriverJDBCVersion.checkSupportsJDBC4(); + + 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(); + } + + public synchronized void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException + { + checkClosed(); + wrappedConnection.setSendTimeAsDatetime(sendTimeAsDateTimeValue); + } + + public synchronized final boolean getSendTimeAsDatetime() throws SQLServerException + { + checkClosed(); + return wrappedConnection.getSendTimeAsDatetime(); + } +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index 16bae5861..f379a43d1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -1,875 +1,876 @@ -//--------------------------------------------------------------------------------------------------------------------------------- -// File: SQLServerDataSource.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), -// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//--------------------------------------------------------------------------------------------------------------------------------- - - -package com.microsoft.sqlserver.jdbc; - -import javax.sql.*; -import java.sql.*; -import java.io.*; -import java.util.*; -import java.util.logging.*; -import javax.naming.*; - -/** -* This datasource lists properties specific for the SQLServerConnection class. -*/ -public class SQLServerDataSource implements ISQLServerDataSource, DataSource, java.io.Serializable, javax.naming.Referenceable -{ - // dsLogger is logger used for all SQLServerDataSource instances. - static final java.util.logging.Logger dsLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerDataSource"); - static final java.util.logging.Logger loggerExternal = - java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.DataSource"); - static final private java.util.logging.Logger parentLogger = - java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc"); - final private String loggingClassName; - private boolean trustStorePasswordStripped = false; - private static final long serialVersionUID = 654861379544314296L; - - private Properties connectionProps; // Properties passed to SQLServerConnection class. - private String dataSourceURL; // URL for datasource. - private String dataSourceDescription; // Description for datasource. - static private int baseDataSourceID = 0; // Unique id generator for each DataSource instance (used for logging). - final private String traceID; - - public SQLServerDataSource() - { - connectionProps = new Properties(); - int dataSourceID = nextDataSourceID(); - String nameL = getClass().getName(); - traceID = nameL.substring(1 + nameL.lastIndexOf('.')) + ":" + dataSourceID; - loggingClassName = "com.microsoft.sqlserver.jdbc." + nameL.substring(1 + nameL.lastIndexOf('.')) + ":" + dataSourceID; - } - - String getClassNameLogging() - { - return loggingClassName; - } - public String toString() - { - return traceID; - } - - // DataSource interface public methods - - public Connection getConnection() throws SQLServerException - { - loggerExternal.entering(getClassNameLogging(), "getConnection"); - Connection con = getConnectionInternal(null, null, null); - loggerExternal.exiting(getClassNameLogging(), "getConnection", con); - return con; - } - public Connection getConnection(String username, String password) throws SQLServerException - { - if (loggerExternal.isLoggable(Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "getConnection", new Object[]{username, "Password not traced"}); - Connection con = getConnectionInternal(username, password, null); - loggerExternal.exiting(getClassNameLogging(), "getConnection", con); - return con; - } - - // Sets the maximum time in seconds that this data source will wait while - // attempting to connect to a database. Note default value is 0. - public void setLoginTimeout(int loginTimeout) - { - setIntProperty(connectionProps, SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), loginTimeout); - } - public int getLoginTimeout() - { - int defaultTimeOut = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); - final int logintimeout = getIntProperty(connectionProps, SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), defaultTimeOut); - // even if the user explicitly sets the timeout to zero, convert to 15 - return (logintimeout==0)?defaultTimeOut:logintimeout; - } - - // Sets the log writer for this DataSource. - // Currently we just hold onto this logWriter and pass it back to callers, nothing else. - private transient PrintWriter logWriter; - public void setLogWriter(PrintWriter out) - { - loggerExternal.entering(getClassNameLogging(), "setLogWriter" ,out); - logWriter = out; - loggerExternal.exiting(getClassNameLogging(), "setLogWriter"); - } - - // Retrieves the log writer for this DataSource. - public PrintWriter getLogWriter() - { - loggerExternal.entering(getClassNameLogging(), "getLogWriter" ); - loggerExternal.exiting(getClassNameLogging(), "getLogWriter", logWriter); - return logWriter; - } - - public Logger getParentLogger() throws SQLFeatureNotSupportedException - { - DriverJDBCVersion.checkSupportsJDBC41(); - - return parentLogger; - } - - // Core Connection property setters/getters. - - // applicationName is used to identify the specific application in various SQL Server - // profiling and logging tools. - public void setApplicationName(String applicationName) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_NAME.toString(), applicationName); - } - public String getApplicationName() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_NAME.toString(), SQLServerDriverStringProperty.APPLICATION_NAME.getDefaultValue()); - } - - // databaseName is the name of the database to connect to. If databaseName is not set, - // getDatabaseName returns the default value of null. - public void setDatabaseName(String databaseName) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.DATABASE_NAME.toString(), databaseName); - } - public String getDatabaseName() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.DATABASE_NAME.toString(), null); - } - - // instanceName is the SQL Server instance name to connect to. - // If instanceName is not set, getInstanceName returns the default value of null. - public void setInstanceName(String instanceName) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.INSTANCE_NAME.toString(), instanceName); - } - public String getInstanceName() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.INSTANCE_NAME.toString(), null); - } - - public void setIntegratedSecurity(boolean enable) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.INTEGRATED_SECURITY.toString(), enable); - } - public void setAuthenticationScheme(String authenticationScheme) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION_SCHEME.toString(), authenticationScheme); - } - - public void setAuthentication(String authentication) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), authentication); - } - - public String getAuthentication(){ - return getStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue()); - } - - public void setAccessToken(String accessToken) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), accessToken); - } - - public String getAccessToken(){ - return getStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), null); - } - - // If lastUpdateCount is set to true, the driver will return only the last update - // count from all the update counts returned by a batch. The default of false will - // return all update counts. If lastUpdateCount is not set, getLastUpdateCount - // returns the default value of false. - - public void setColumnEncryptionSetting(String columnEncryptionSetting) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), columnEncryptionSetting); - } - public String getColumnEncryptionSetting() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), SQLServerDriverStringProperty.COLUMN_ENCRYPTION.getDefaultValue()); - } - - public void setKeyStoreAuthentication(String keyStoreAuthentication) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), keyStoreAuthentication); - } - public String getKeyStoreAuthentication() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.getDefaultValue()); - } - - public void setKeyStoreSecret(String keyStoreSecret) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_SECRET.toString(), keyStoreSecret); - } - - public void setKeyStoreLocation(String keyStoreLocation) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), keyStoreLocation); - } - public String getKeyStoreLocation() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), SQLServerDriverStringProperty.KEY_STORE_LOCATION.getDefaultValue()); - } - - public void setLastUpdateCount(boolean lastUpdateCount) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.toString(), lastUpdateCount); - } - public boolean getLastUpdateCount() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.toString(), SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.getDefaultValue()); - } - - // Encryption - public void setEncrypt(boolean encrypt) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.ENCRYPT.toString(), encrypt); - } - public boolean getEncrypt() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.ENCRYPT.toString(), SQLServerDriverBooleanProperty.ENCRYPT.getDefaultValue()); - } - - public void setTransparentNetworkIPResolution(boolean tnir) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), tnir); - } - public boolean getTransparentNetworkIPResolution() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.getDefaultValue()); - } - - public void setTrustServerCertificate(boolean e) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.toString(), e); - } - public boolean getTrustServerCertificate() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.toString(), SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.getDefaultValue()); - } - public void setTrustStore(String st) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE.toString(), st); - } - public String getTrustStore() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE.toString(), null); - } - - public void setTrustStorePassword(String p) - { - // if a non value property is set - if (p!=null) - trustStorePasswordStripped = false; - setStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString(), p); - } - public void setHostNameInCertificate(String host) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), host); - } - public String getHostNameInCertificate() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), null); - } - - // lockTimeout is the number of milliseconds to wait before the database reports - // a lock timeout. The default value of -1 means wait forever. If specified, - // this value will be the default for all statements on the connection. Note a - // value of 0 means no wait. If lockTimeout is not set, getLockTimeout returns - // the default of -1. - public void setLockTimeout(int lockTimeout) - { - setIntProperty(connectionProps, SQLServerDriverIntProperty.LOCK_TIMEOUT.toString(), lockTimeout); - } - public int getLockTimeout() - { - return getIntProperty(connectionProps, SQLServerDriverIntProperty.LOCK_TIMEOUT.toString(), SQLServerDriverIntProperty.LOCK_TIMEOUT.getDefaultValue()); - } - - // setPassword sets the password that will be used when connecting to SQL Server. - // Note getPassword is deliberately declared non-public for security reasons. - // If the password is not set, getPassword returns the default value of null. - public void setPassword(String password) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.PASSWORD.toString(), password); - } - String getPassword() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.PASSWORD.toString(), null); - } - - // portNumber is the TCP-IP port number used when opening a socket connection - // to SQL Server. If portNumber is not set, getPortNumber returns the default - // of 1433. Note as mentioned above, setPortNumber does not do any range - // checking on the port value passed in, invalid port numbers like 99999 can - // be passed in without triggering any error. - public void setPortNumber(int portNumber) - { - setIntProperty(connectionProps, SQLServerDriverIntProperty.PORT_NUMBER.toString(), portNumber); - } - public int getPortNumber() - { - return getIntProperty(connectionProps, SQLServerDriverIntProperty.PORT_NUMBER.toString(), SQLServerDriverIntProperty.PORT_NUMBER.getDefaultValue()); - } - - // selectMethod is the default cursor type used for the result set. This - // property is useful when you are dealing with large result sets and don't - // want to store the whole result set in memory on the client side. By setting - // the property to "cursor" you will be able to create a server side cursor that - // can fetch smaller chunks of data at a time. If selectMethod is not set, - // getSelectMethod returns the default value of "direct". - public void setSelectMethod(String selectMethod) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.SELECT_METHOD.toString(), selectMethod); - } - public String getSelectMethod() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.SELECT_METHOD.toString(), SQLServerDriverStringProperty.SELECT_METHOD.getDefaultValue() ); - } - - public void setResponseBuffering(String respo) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.RESPONSE_BUFFERING.toString(), respo); - } - public String getResponseBuffering() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.RESPONSE_BUFFERING.toString(), SQLServerDriverStringProperty.RESPONSE_BUFFERING.getDefaultValue()); - } - - public void setApplicationIntent(String applicationIntent) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_INTENT.toString(), applicationIntent); - } - public String getApplicationIntent() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_INTENT.toString(), SQLServerDriverStringProperty.APPLICATION_INTENT.getDefaultValue()); - } - - public void setSendTimeAsDatetime(boolean sendTimeAsDatetime) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.toString(), sendTimeAsDatetime); - } - - public boolean getSendTimeAsDatetime() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.toString(), SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.getDefaultValue()); - } - - // If sendStringParametersAsUnicode is set to true (which is the default), - // string parameters are sent to the server in UNICODE format. If sendStringParametersAsUnicode - // is set to false, string parameters are sent to the server in the native TDS collation - // format of the database, not in UNICODE. If sendStringParametersAsUnicode is not set, - // getSendStringParametersAsUnicode returns the default of true. - public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), sendStringParametersAsUnicode); - } - public boolean getSendStringParametersAsUnicode() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue()); - } - // Translates the serverName from Unicode to ASCII Compatible Encoding (ACE) - public void setServerNameAsACE(boolean serverNameAsACE) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), serverNameAsACE); - } - public boolean getServerNameAsACE() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.getDefaultValue()); - } - // serverName is the host name of the target SQL Server. If serverName is not set, - // getServerName returns the default value of null is returned. - public void setServerName(String serverName) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_NAME.toString(), serverName); - } - public String getServerName() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_NAME.toString(), null); - } - // Specify an Service Principal Name (SPN) of the target SQL Server. - // https://msdn.microsoft.com/en-us/library/cc280459.aspx - public void setServerSpn(String serverSpn) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_SPN.toString(), serverSpn); - } - public String getServerSpn() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_SPN.toString(), null); - } - // serverName is the host name of the target SQL Server. If serverName is not set, - // getServerName returns the default value of null is returned. - public void setFailoverPartner(String serverName) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(), serverName); - } - public String getFailoverPartner() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(), null); - } - - public void setMultiSubnetFailover(boolean multiSubnetFailover) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.toString(), multiSubnetFailover); - } - - public boolean getMultiSubnetFailover() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.toString(), SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.getDefaultValue()); - } - - // setUser set's the user name that will be used when connecting to SQL Server. - // If user is not set, getUser returns the default value of null. - public void setUser(String user) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.USER.toString(), user); - } - public String getUser() - { - return getStringProperty(connectionProps, SQLServerDriverStringProperty.USER.toString(), null); - } - - // workstationID is the name of the client machine (or client workstation). - // workstationID is the host name of the client in other words. If workstationID - // is not set, the default value is constructed by calling InetAddress.getLocalHost().getHostName() - // or if getHostName() returns blank then getHostAddress().toString(). - public void setWorkstationID(String workstationID) - { - setStringProperty(connectionProps, SQLServerDriverStringProperty.WORKSTATION_ID.toString(), workstationID); - } - public String getWorkstationID() - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER) ) - loggerExternal.entering(getClassNameLogging(), "getWorkstationID"); - String getWSID = connectionProps.getProperty(SQLServerDriverStringProperty.WORKSTATION_ID.toString()); - // Per spec, return what the logon will send here if workstationID property is not set. - if (null == getWSID) - { - getWSID = Util.lookupHostName(); - } - loggerExternal.exiting(getClassNameLogging(), "getWorkstationID", getWSID); - return getWSID; - } - - // If xopenStates is set to true, the driver will convert SQL states to XOPEN - // compliant states. The default is false which causes the driver to generate SQL 99 - // state codes. If xopenStates is not set, getXopenStates returns the default value - // of false. - public void setXopenStates(boolean xopenStates) - { - setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), xopenStates); - } - public boolean getXopenStates() - { - return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), SQLServerDriverBooleanProperty.XOPEN_STATES.getDefaultValue()); - } - - // The URL property is exposed for backwards compatibility reasons. Also, several - // Java Application servers expect a setURL function on the DataSource and set it - // by default (JBoss and WebLogic). - - // Note for security reasons we do not recommend that customers include the password - // in the url supplied to setURL. The reason for this is third-party Java Application - // Servers will very often display the value set to URL property in their DataSource - // configuration GUI. We recommend instead that clients use the setPassword method - // to set the password value. The Java Application Servers will not display a password - // that is set on the DataSource in the configuration GUI. - - // Note if setURL is not called, getURL returns the default value of "jdbc:sqlserver://". - public void setURL(String url) - { - loggerExternal.entering(getClassNameLogging(), "setURL", url); - // URL is not stored in a property set, it is maintained separately. - dataSourceURL = url; - loggerExternal.exiting(getClassNameLogging(), "setURL"); - } - public String getURL() - { - String url = dataSourceURL; - loggerExternal.entering(getClassNameLogging(), "getURL"); - - if (null == dataSourceURL) - url = "jdbc:sqlserver://"; - loggerExternal.exiting(getClassNameLogging(), "getURL", url); - return url; - } - - // DataSource specific property setters/getters. - - // Per JDBC specification 16.1.1 "...the only property that all DataSource - // implementations are required to support is the description property". - public void setDescription(String description) - { - loggerExternal.entering(getClassNameLogging(), "setDescription", description); - dataSourceDescription = description; - loggerExternal.exiting(getClassNameLogging(), "setDescription"); - } - public String getDescription() - { - loggerExternal.entering(getClassNameLogging(), "getDescription"); - loggerExternal.exiting(getClassNameLogging(), "getDescription", dataSourceDescription); - return dataSourceDescription; - } - - // packetSize is the size (in bytes) to use for the TCP/IP send and receive - // buffer. It is also the value used for the TDS packet size (SQL Server - // Network Packet Size). Validity of the value is checked at connect time. - // If no value is set for this property, its default value is 4KB. - public void setPacketSize(int packetSize) - { - setIntProperty(connectionProps, SQLServerDriverIntProperty.PACKET_SIZE.toString(), packetSize); - } - public int getPacketSize() - { - return getIntProperty(connectionProps, SQLServerDriverIntProperty.PACKET_SIZE.toString(), SQLServerDriverIntProperty.PACKET_SIZE.getDefaultValue()); - } - - // responseBuffering controls the driver's buffering of responses from SQL Server. - // Possible values are: - // - // "full" - Fully buffer the response at execution time. - // Advantages: - // 100% back compat with v1.1 driver - // Maximizes concurrency on the server - // Disadvantages: - // Consumes more client-side memory - // Client scalability limits with large responses - // More execute latency - // - // "adaptive" - Data Pipe adaptive buffering - // Advantages: - // Buffers only when necessary, only as much as necessary - // Enables handling very large responses, values - // Disadvantages - // Reduced concurrency on the server - // Internal functions for setting/getting property values. - - // Set a string property value. - // Caller will always supply a non-null props and propKey. - // Caller may supply a null propValue, in this case no property value is set. - private void setStringProperty(Properties props, String propKey, String propValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER) && !propKey.contains("password") && !propKey.contains("Password")) - { - loggerExternal.entering(getClassNameLogging(), "set"+propKey, propValue); - } - else - loggerExternal.entering(getClassNameLogging(), "set"+propKey); - if (null!=propValue) - props.setProperty(propKey, propValue); - loggerExternal.exiting(getClassNameLogging(), "set"+propKey); - } - - // Reads property value in String format. - // Caller will always supply a non-null props and propKey. - // Returns null if the specific property value is not set. - private String getStringProperty(Properties props, String propKey, String defaultValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "get"+propKey); - String propValue = props.getProperty(propKey); - if (null==propValue) - propValue = defaultValue; - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)&& !propKey.contains("password") && !propKey.contains("Password")) - loggerExternal.exiting(getClassNameLogging(), "get"+propKey, propValue); - return propValue; - } - - // Set an integer property value. - // Caller will always supply a non-null props and propKey. - private void setIntProperty(Properties props, String propKey, int propValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "set"+propKey, new Integer(propValue)); - props.setProperty(propKey, new Integer(propValue).toString()); - loggerExternal.exiting(getClassNameLogging(), "set"+propKey); - } - - // Reads a property value in int format. - // Caller will always supply a non-null props and propKey. - // Returns defaultValue if the specific property value is not set. - private int getIntProperty(Properties props, String propKey, int defaultValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "get"+propKey); - String propValue = props.getProperty(propKey); - int value = defaultValue; - if (null!=propValue) - { - try - { - value = Integer.parseInt(propValue); - } - catch(NumberFormatException nfe) - { - // This exception cannot occur as all of our properties - // are set internally by int -> Integer.toString. - assert false : "Bad portNumber:-"+ propValue; - } - } - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.exiting(getClassNameLogging(), "get"+propKey, new Integer(value)); - return value; - } - - // Set a boolean property value. - // Caller will always supply a non-null props and propKey. - private void setBooleanProperty(Properties props, String propKey, boolean propValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "set"+propKey, Boolean.valueOf(propValue)); - props.setProperty(propKey, (propValue) ? "true" : "false" ); - loggerExternal.exiting(getClassNameLogging(), "set"+propKey); - } - - // Reads a property value in boolean format. - // Caller will always supply a non-null props and propKey. - // Returns defaultValue if the specific property value is not set. - private boolean getBooleanProperty(Properties props, String propKey, boolean defaultValue) - { - if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "get"+propKey); - String propValue = props.getProperty(propKey); - Boolean value; - if (null==propValue) - { - value = defaultValue; - } - else - { - // Since we set the value of the String property ourselves to - // "true" or "false", we can do this. - value = Boolean.valueOf(propValue); - } - loggerExternal.exiting(getClassNameLogging(), "get"+propKey, value); - return value.booleanValue(); - } - - - // Returns a SQLServerConnection given username, password, and pooledConnection. - // Note that the DataSource properties set to connectionProps are used when creating - // the connection. - - // Both username and password can be null. - - // If pooledConnection is not null, then connection returned is attached to the pooledConnection - // and participates in connection pooling. - SQLServerConnection getConnectionInternal(String username, String password, - SQLServerPooledConnection pooledConnection) throws SQLServerException - { - Properties userSuppliedProps = null; - Properties mergedProps = null; - // Trust store password stripped and this object got created via Objectfactory referencing. - if(trustStorePasswordStripped) - SQLServerException.makeFromDriverError(null, null, - SQLServerException.getErrString("R_referencingFailedTSP"), null, true); - - // If username or password is passed in, clone the property set so we - // don't alter original connectionProps. - if (null != username || null != password) - { - userSuppliedProps = (Properties)this.connectionProps.clone(); - - // Remove user and password from connectionProps if set. - // We want the user supplied user+password to replace - // whatever is set in connectionProps. - userSuppliedProps.remove(SQLServerDriverStringProperty.USER.toString()); - userSuppliedProps.remove(SQLServerDriverStringProperty.PASSWORD.toString()); - - if (null != username) - userSuppliedProps.put(SQLServerDriverStringProperty.USER.toString(), username); - if (null != password) - userSuppliedProps.put(SQLServerDriverStringProperty.PASSWORD.toString(), password); - } - else - { - userSuppliedProps = connectionProps; - } - - // Merge in URL properties into userSuppliedProps if URL is set. - if (null != dataSourceURL) - { - Properties urlProps = Util.parseUrl(dataSourceURL, dsLogger); - // null returned properties means that the passed in URL is not supported. - if(null == urlProps) - SQLServerException.makeFromDriverError(null, null, - SQLServerException.getErrString("R_errorConnectionString"), null, true); - // Manually merge URL props and user supplied props. - mergedProps = SQLServerDriver.mergeURLAndSuppliedProperties(urlProps, userSuppliedProps); - } - else - { - mergedProps = userSuppliedProps; - } - - // Create new connection and connect. - if (dsLogger.isLoggable(Level.FINER)) - dsLogger.finer(toString() + " Begin create new connection."); - SQLServerConnection result = new SQLServerConnection(toString()); - result.connect(mergedProps, pooledConnection); - if (dsLogger.isLoggable(Level.FINER)) - dsLogger.finer(toString() + " End create new connection " + result.toString()); - return result; - } - - // Implement javax.naming.Referenceable interface methods. - - public Reference getReference() - { - loggerExternal.entering(getClassNameLogging(), "getReference"); - Reference ref = getReferenceInternal("com.microsoft.sqlserver.jdbc.SQLServerDataSource"); - loggerExternal.exiting(getClassNameLogging(), "getReference", ref); - return ref; - } - - Reference getReferenceInternal(String dataSourceClassString) - { - if (dsLogger.isLoggable(Level.FINER)) - dsLogger.finer(toString() + " creating reference for " + dataSourceClassString + "."); - - Reference ref = new Reference(this.getClass().getName(), - "com.microsoft.sqlserver.jdbc.SQLServerDataSourceObjectFactory", null); - if(null != dataSourceClassString) - ref.add(new StringRefAddr("class", dataSourceClassString)); - - if(trustStorePasswordStripped) - ref.add(new StringRefAddr("trustStorePasswordStripped", "true")); - - // Add each property name+value pair found in connectionProps. - Enumeration e = connectionProps.keys(); - while (e.hasMoreElements()) - { - String propertyName = (String)e.nextElement(); - // If a trustStore password is set, it is omitted and a trustStorePasswordSet flag is set. - if(propertyName.equals(SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString())) - { - // The property set and the variable set at the same time is not possible - assert trustStorePasswordStripped == false; - ref.add(new StringRefAddr("trustStorePasswordStripped", "true")); - } - else - { - // do not add passwords to the collection. we have normal password - if (!propertyName.contains(SQLServerDriverStringProperty.PASSWORD.toString())) - ref.add(new StringRefAddr(propertyName, connectionProps.getProperty(propertyName))); - } - } - - // Add dataSourceURL and dataSourceDescription as these will not appear in connectionProps. - if (null != dataSourceURL) - ref.add(new StringRefAddr("dataSourceURL", dataSourceURL)); - - if (null != dataSourceDescription) - ref.add(new StringRefAddr("dataSourceDescription", dataSourceDescription)); - - return ref; - } - - // Initialize this datasource from properties found inside the reference ref. - // Called by SQLServerDataSourceObjectFactory to initialize new DataSource instance. - void initializeFromReference(javax.naming.Reference ref) - { - // Enumerate all the StringRefAddr objects in the Reference and assign properties appropriately. - Enumeration e = ref.getAll(); - while (e.hasMoreElements()) - { - StringRefAddr addr = (StringRefAddr) e.nextElement(); - String propertyName = addr.getType(); - String propertyValue = (String) addr.getContent(); - - // Special case dataSourceURL and dataSourceDescription. - if (propertyName.equals("dataSourceURL")) - { - dataSourceURL = propertyValue; - } - else if (propertyName.equals("dataSourceDescription")) - { - dataSourceDescription = propertyValue; - } - else if (propertyName.equals("trustStorePasswordStripped")) - { - trustStorePasswordStripped = true; - } - // Just skip "class" StringRefAddr, it does not go into connectionProps - else if (false == propertyName.equals("class")) - { - - connectionProps.setProperty(propertyName, propertyValue); - } - } - } - - public boolean isWrapperFor(Class iface) throws SQLException - { - loggerExternal.entering(getClassNameLogging(), "isWrapperFor", iface ); - DriverJDBCVersion.checkSupportsJDBC4(); - boolean f = iface.isInstance(this); - loggerExternal.exiting(getClassNameLogging(), "isWrapperFor", Boolean.valueOf(f)); - return f; - } - - public T unwrap(Class iface) throws SQLException - { - loggerExternal.entering(getClassNameLogging(), "unwrap", iface); - DriverJDBCVersion.checkSupportsJDBC4(); - T t; - try - { - t = iface.cast(this); - } - catch (ClassCastException e) - { - throw new SQLServerException(e.getMessage(), e); - } - loggerExternal.exiting(getClassNameLogging(), "unwrap", t); - return t; - } - - // Returns unique id for each DataSource instance. - private synchronized static int nextDataSourceID() - { - baseDataSourceID++; - return baseDataSourceID; - } - private Object writeReplace() throws java.io.ObjectStreamException - { - return new SerializationProxy(this); - } - private void readObject(java.io.ObjectInputStream stream) throws java.io.InvalidObjectException - { - // For added security/robustness, the only way to rehydrate a serialized SQLServerDataSource - // is to use a SerializationProxy. Direct use of readObject() is not supported. - throw new java.io.InvalidObjectException(""); - } - - // This code is duplicated in pooled and XA datasource classes. - private static class SerializationProxy - implements java.io.Serializable - { - private final Reference ref; - private static final long serialVersionUID = 654661379542314226L; - - SerializationProxy (SQLServerDataSource ds) - { - // We do not need the class name so pass null, serialization mechanism - // stores the class info. - ref = ds.getReferenceInternal(null); - } - private Object readResolve() - { - SQLServerDataSource ds = new SQLServerDataSource(); - ds.initializeFromReference(ref); - return ds; - } - } -} +//--------------------------------------------------------------------------------------------------------------------------------- +// File: SQLServerDataSource.java +// +// +// Microsoft JDBC Driver for SQL Server +// Copyright(c) Microsoft Corporation +// All rights reserved. +// MIT License +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//--------------------------------------------------------------------------------------------------------------------------------- + + +package com.microsoft.sqlserver.jdbc; + +import javax.sql.*; +import java.sql.*; +import java.io.*; +import java.util.*; +import java.util.logging.*; +import javax.naming.*; + +/** +* This datasource lists properties specific for the SQLServerConnection class. +*/ +public class SQLServerDataSource implements ISQLServerDataSource, DataSource, java.io.Serializable, javax.naming.Referenceable +{ + // dsLogger is logger used for all SQLServerDataSource instances. + static final java.util.logging.Logger dsLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerDataSource"); + static final java.util.logging.Logger loggerExternal = + java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.DataSource"); + static final private java.util.logging.Logger parentLogger = + java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc"); + final private String loggingClassName; + private boolean trustStorePasswordStripped = false; + private static final long serialVersionUID = 654861379544314296L; + + private Properties connectionProps; // Properties passed to SQLServerConnection class. + private String dataSourceURL; // URL for datasource. + private String dataSourceDescription; // Description for datasource. + static private int baseDataSourceID = 0; // Unique id generator for each DataSource instance (used for logging). + final private String traceID; + + public SQLServerDataSource() + { + connectionProps = new Properties(); + int dataSourceID = nextDataSourceID(); + String nameL = getClass().getName(); + traceID = nameL.substring(1 + nameL.lastIndexOf('.')) + ":" + dataSourceID; + loggingClassName = "com.microsoft.sqlserver.jdbc." + nameL.substring(1 + nameL.lastIndexOf('.')) + ":" + dataSourceID; + } + + String getClassNameLogging() + { + return loggingClassName; + } + public String toString() + { + return traceID; + } + + // DataSource interface public methods + + public Connection getConnection() throws SQLServerException + { + loggerExternal.entering(getClassNameLogging(), "getConnection"); + Connection con = getConnectionInternal(null, null, null); + loggerExternal.exiting(getClassNameLogging(), "getConnection", con); + return con; + } + public Connection getConnection(String username, String password) throws SQLServerException + { + if (loggerExternal.isLoggable(Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "getConnection", new Object[]{username, "Password not traced"}); + Connection con = getConnectionInternal(username, password, null); + loggerExternal.exiting(getClassNameLogging(), "getConnection", con); + return con; + } + + // Sets the maximum time in seconds that this data source will wait while + // attempting to connect to a database. Note default value is 0. + public void setLoginTimeout(int loginTimeout) + { + setIntProperty(connectionProps, SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), loginTimeout); + } + public int getLoginTimeout() + { + int defaultTimeOut = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); + final int logintimeout = getIntProperty(connectionProps, SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), defaultTimeOut); + // even if the user explicitly sets the timeout to zero, convert to 15 + return (logintimeout==0)?defaultTimeOut:logintimeout; + } + + // Sets the log writer for this DataSource. + // Currently we just hold onto this logWriter and pass it back to callers, nothing else. + private transient PrintWriter logWriter; + public void setLogWriter(PrintWriter out) + { + loggerExternal.entering(getClassNameLogging(), "setLogWriter" ,out); + logWriter = out; + loggerExternal.exiting(getClassNameLogging(), "setLogWriter"); + } + + // Retrieves the log writer for this DataSource. + public PrintWriter getLogWriter() + { + loggerExternal.entering(getClassNameLogging(), "getLogWriter" ); + loggerExternal.exiting(getClassNameLogging(), "getLogWriter", logWriter); + return logWriter; + } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException + { + DriverJDBCVersion.checkSupportsJDBC41(); + + return parentLogger; + } + + // Core Connection property setters/getters. + + // applicationName is used to identify the specific application in various SQL Server + // profiling and logging tools. + public void setApplicationName(String applicationName) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_NAME.toString(), applicationName); + } + public String getApplicationName() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_NAME.toString(), SQLServerDriverStringProperty.APPLICATION_NAME.getDefaultValue()); + } + + // databaseName is the name of the database to connect to. If databaseName is not set, + // getDatabaseName returns the default value of null. + public void setDatabaseName(String databaseName) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.DATABASE_NAME.toString(), databaseName); + } + public String getDatabaseName() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.DATABASE_NAME.toString(), null); + } + + // instanceName is the SQL Server instance name to connect to. + // If instanceName is not set, getInstanceName returns the default value of null. + public void setInstanceName(String instanceName) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.INSTANCE_NAME.toString(), instanceName); + } + public String getInstanceName() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.INSTANCE_NAME.toString(), null); + } + + public void setIntegratedSecurity(boolean enable) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.INTEGRATED_SECURITY.toString(), enable); + } + public void setAuthenticationScheme(String authenticationScheme) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION_SCHEME.toString(), authenticationScheme); + } + + public void setAuthentication(String authentication) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), authentication); + } + + public String getAuthentication(){ + return getStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue()); + } + + public void setAccessToken(String accessToken) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), accessToken); + } + + public String getAccessToken(){ + return getStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), null); + } + + // If lastUpdateCount is set to true, the driver will return only the last update + // count from all the update counts returned by a batch. The default of false will + // return all update counts. If lastUpdateCount is not set, getLastUpdateCount + // returns the default value of false. + + public void setColumnEncryptionSetting(String columnEncryptionSetting) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), columnEncryptionSetting); + } + public String getColumnEncryptionSetting() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), SQLServerDriverStringProperty.COLUMN_ENCRYPTION.getDefaultValue()); + } + + public void setKeyStoreAuthentication(String keyStoreAuthentication) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), keyStoreAuthentication); + } + public String getKeyStoreAuthentication() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.getDefaultValue()); + } + + public void setKeyStoreSecret(String keyStoreSecret) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_SECRET.toString(), keyStoreSecret); + } + + public void setKeyStoreLocation(String keyStoreLocation) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), keyStoreLocation); + } + public String getKeyStoreLocation() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), SQLServerDriverStringProperty.KEY_STORE_LOCATION.getDefaultValue()); + } + + public void setLastUpdateCount(boolean lastUpdateCount) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.toString(), lastUpdateCount); + } + public boolean getLastUpdateCount() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.toString(), SQLServerDriverBooleanProperty.LAST_UPDATE_COUNT.getDefaultValue()); + } + + // Encryption + public void setEncrypt(boolean encrypt) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.ENCRYPT.toString(), encrypt); + } + public boolean getEncrypt() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.ENCRYPT.toString(), SQLServerDriverBooleanProperty.ENCRYPT.getDefaultValue()); + } + + public void setTransparentNetworkIPResolution(boolean tnir) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), tnir); + } + public boolean getTransparentNetworkIPResolution() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.getDefaultValue()); + } + + public void setTrustServerCertificate(boolean e) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.toString(), e); + } + public boolean getTrustServerCertificate() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.toString(), SQLServerDriverBooleanProperty.TRUST_SERVER_CERTIFICATE.getDefaultValue()); + } + public void setTrustStore(String st) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE.toString(), st); + } + public String getTrustStore() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE.toString(), null); + } + + public void setTrustStorePassword(String p) + { + // if a non value property is set + if (p!=null) + trustStorePasswordStripped = false; + setStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString(), p); + } + public void setHostNameInCertificate(String host) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), host); + } + public String getHostNameInCertificate() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), null); + } + + // lockTimeout is the number of milliseconds to wait before the database reports + // a lock timeout. The default value of -1 means wait forever. If specified, + // this value will be the default for all statements on the connection. Note a + // value of 0 means no wait. If lockTimeout is not set, getLockTimeout returns + // the default of -1. + public void setLockTimeout(int lockTimeout) + { + setIntProperty(connectionProps, SQLServerDriverIntProperty.LOCK_TIMEOUT.toString(), lockTimeout); + } + public int getLockTimeout() + { + return getIntProperty(connectionProps, SQLServerDriverIntProperty.LOCK_TIMEOUT.toString(), SQLServerDriverIntProperty.LOCK_TIMEOUT.getDefaultValue()); + } + + // setPassword sets the password that will be used when connecting to SQL Server. + // Note getPassword is deliberately declared non-public for security reasons. + // If the password is not set, getPassword returns the default value of null. + public void setPassword(String password) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.PASSWORD.toString(), password); + } + String getPassword() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.PASSWORD.toString(), null); + } + + // portNumber is the TCP-IP port number used when opening a socket connection + // to SQL Server. If portNumber is not set, getPortNumber returns the default + // of 1433. Note as mentioned above, setPortNumber does not do any range + // checking on the port value passed in, invalid port numbers like 99999 can + // be passed in without triggering any error. + public void setPortNumber(int portNumber) + { + setIntProperty(connectionProps, SQLServerDriverIntProperty.PORT_NUMBER.toString(), portNumber); + } + public int getPortNumber() + { + return getIntProperty(connectionProps, SQLServerDriverIntProperty.PORT_NUMBER.toString(), SQLServerDriverIntProperty.PORT_NUMBER.getDefaultValue()); + } + + // selectMethod is the default cursor type used for the result set. This + // property is useful when you are dealing with large result sets and don't + // want to store the whole result set in memory on the client side. By setting + // the property to "cursor" you will be able to create a server side cursor that + // can fetch smaller chunks of data at a time. If selectMethod is not set, + // getSelectMethod returns the default value of "direct". + public void setSelectMethod(String selectMethod) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.SELECT_METHOD.toString(), selectMethod); + } + public String getSelectMethod() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.SELECT_METHOD.toString(), SQLServerDriverStringProperty.SELECT_METHOD.getDefaultValue() ); + } + + public void setResponseBuffering(String respo) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.RESPONSE_BUFFERING.toString(), respo); + } + public String getResponseBuffering() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.RESPONSE_BUFFERING.toString(), SQLServerDriverStringProperty.RESPONSE_BUFFERING.getDefaultValue()); + } + + public void setApplicationIntent(String applicationIntent) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_INTENT.toString(), applicationIntent); + } + public String getApplicationIntent() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_INTENT.toString(), SQLServerDriverStringProperty.APPLICATION_INTENT.getDefaultValue()); + } + + public void setSendTimeAsDatetime(boolean sendTimeAsDatetime) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.toString(), sendTimeAsDatetime); + } + + public boolean getSendTimeAsDatetime() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.toString(), SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.getDefaultValue()); + } + + // If sendStringParametersAsUnicode is set to true (which is the default), + // string parameters are sent to the server in UNICODE format. If sendStringParametersAsUnicode + // is set to false, string parameters are sent to the server in the native TDS collation + // format of the database, not in UNICODE. If sendStringParametersAsUnicode is not set, + // getSendStringParametersAsUnicode returns the default of true. + public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), sendStringParametersAsUnicode); + } + public boolean getSendStringParametersAsUnicode() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue()); + } + // Translates the serverName from Unicode to ASCII Compatible Encoding (ACE) + public void setServerNameAsACE(boolean serverNameAsACE) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), serverNameAsACE); + } + public boolean getServerNameAsACE() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.getDefaultValue()); + } + // serverName is the host name of the target SQL Server. If serverName is not set, + // getServerName returns the default value of null is returned. + public void setServerName(String serverName) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_NAME.toString(), serverName); + } + public String getServerName() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_NAME.toString(), null); + } + // Specify an Service Principal Name (SPN) of the target SQL Server. + // https://msdn.microsoft.com/en-us/library/cc280459.aspx + public void setServerSpn(String serverSpn) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_SPN.toString(), serverSpn); + } + public String getServerSpn() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_SPN.toString(), null); + } + // serverName is the host name of the target SQL Server. If serverName is not set, + // getServerName returns the default value of null is returned. + public void setFailoverPartner(String serverName) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(), serverName); + } + public String getFailoverPartner() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(), null); + } + + public void setMultiSubnetFailover(boolean multiSubnetFailover) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.toString(), multiSubnetFailover); + } + + public boolean getMultiSubnetFailover() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.toString(), SQLServerDriverBooleanProperty.MULTI_SUBNET_FAILOVER.getDefaultValue()); + } + + // setUser set's the user name that will be used when connecting to SQL Server. + // If user is not set, getUser returns the default value of null. + public void setUser(String user) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.USER.toString(), user); + } + public String getUser() + { + return getStringProperty(connectionProps, SQLServerDriverStringProperty.USER.toString(), null); + } + + // workstationID is the name of the client machine (or client workstation). + // workstationID is the host name of the client in other words. If workstationID + // is not set, the default value is constructed by calling InetAddress.getLocalHost().getHostName() + // or if getHostName() returns blank then getHostAddress().toString(). + public void setWorkstationID(String workstationID) + { + setStringProperty(connectionProps, SQLServerDriverStringProperty.WORKSTATION_ID.toString(), workstationID); + } + public String getWorkstationID() + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER) ) + loggerExternal.entering(getClassNameLogging(), "getWorkstationID"); + String getWSID = connectionProps.getProperty(SQLServerDriverStringProperty.WORKSTATION_ID.toString()); + // Per spec, return what the logon will send here if workstationID property is not set. + if (null == getWSID) + { + getWSID = Util.lookupHostName(); + } + loggerExternal.exiting(getClassNameLogging(), "getWorkstationID", getWSID); + return getWSID; + } + + // If xopenStates is set to true, the driver will convert SQL states to XOPEN + // compliant states. The default is false which causes the driver to generate SQL 99 + // state codes. If xopenStates is not set, getXopenStates returns the default value + // of false. + public void setXopenStates(boolean xopenStates) + { + setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), xopenStates); + } + public boolean getXopenStates() + { + return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), SQLServerDriverBooleanProperty.XOPEN_STATES.getDefaultValue()); + } + + // The URL property is exposed for backwards compatibility reasons. Also, several + // Java Application servers expect a setURL function on the DataSource and set it + // by default (JBoss and WebLogic). + + // Note for security reasons we do not recommend that customers include the password + // in the url supplied to setURL. The reason for this is third-party Java Application + // Servers will very often display the value set to URL property in their DataSource + // configuration GUI. We recommend instead that clients use the setPassword method + // to set the password value. The Java Application Servers will not display a password + // that is set on the DataSource in the configuration GUI. + + // Note if setURL is not called, getURL returns the default value of "jdbc:sqlserver://". + public void setURL(String url) + { + loggerExternal.entering(getClassNameLogging(), "setURL", url); + // URL is not stored in a property set, it is maintained separately. + dataSourceURL = url; + loggerExternal.exiting(getClassNameLogging(), "setURL"); + } + public String getURL() + { + String url = dataSourceURL; + loggerExternal.entering(getClassNameLogging(), "getURL"); + + if (null == dataSourceURL) + url = "jdbc:sqlserver://"; + loggerExternal.exiting(getClassNameLogging(), "getURL", url); + return url; + } + + // DataSource specific property setters/getters. + + // Per JDBC specification 16.1.1 "...the only property that all DataSource + // implementations are required to support is the description property". + public void setDescription(String description) + { + loggerExternal.entering(getClassNameLogging(), "setDescription", description); + dataSourceDescription = description; + loggerExternal.exiting(getClassNameLogging(), "setDescription"); + } + public String getDescription() + { + loggerExternal.entering(getClassNameLogging(), "getDescription"); + loggerExternal.exiting(getClassNameLogging(), "getDescription", dataSourceDescription); + return dataSourceDescription; + } + + // packetSize is the size (in bytes) to use for the TCP/IP send and receive + // buffer. It is also the value used for the TDS packet size (SQL Server + // Network Packet Size). Validity of the value is checked at connect time. + // If no value is set for this property, its default value is 4KB. + public void setPacketSize(int packetSize) + { + setIntProperty(connectionProps, SQLServerDriverIntProperty.PACKET_SIZE.toString(), packetSize); + } + public int getPacketSize() + { + return getIntProperty(connectionProps, SQLServerDriverIntProperty.PACKET_SIZE.toString(), SQLServerDriverIntProperty.PACKET_SIZE.getDefaultValue()); + } + + // responseBuffering controls the driver's buffering of responses from SQL Server. + // Possible values are: + // + // "full" - Fully buffer the response at execution time. + // Advantages: + // 100% back compat with v1.1 driver + // Maximizes concurrency on the server + // Disadvantages: + // Consumes more client-side memory + // Client scalability limits with large responses + // More execute latency + // + // "adaptive" - Data Pipe adaptive buffering + // Advantages: + // Buffers only when necessary, only as much as necessary + // Enables handling very large responses, values + // Disadvantages + // Reduced concurrency on the server + // Internal functions for setting/getting property values. + + // Set a string property value. + // Caller will always supply a non-null props and propKey. + // Caller may supply a null propValue, in this case no property value is set. + private void setStringProperty(Properties props, String propKey, String propValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER) && !propKey.contains("password") && !propKey.contains("Password")) + { + loggerExternal.entering(getClassNameLogging(), "set"+propKey, propValue); + } + else + loggerExternal.entering(getClassNameLogging(), "set"+propKey); + if (null!=propValue) + props.setProperty(propKey, propValue); + loggerExternal.exiting(getClassNameLogging(), "set"+propKey); + } + + // Reads property value in String format. + // Caller will always supply a non-null props and propKey. + // Returns null if the specific property value is not set. + private String getStringProperty(Properties props, String propKey, String defaultValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "get"+propKey); + String propValue = props.getProperty(propKey); + if (null==propValue) + propValue = defaultValue; + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)&& !propKey.contains("password") && !propKey.contains("Password")) + loggerExternal.exiting(getClassNameLogging(), "get"+propKey, propValue); + return propValue; + } + + // Set an integer property value. + // Caller will always supply a non-null props and propKey. + private void setIntProperty(Properties props, String propKey, int propValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "set"+propKey, new Integer(propValue)); + props.setProperty(propKey, new Integer(propValue).toString()); + loggerExternal.exiting(getClassNameLogging(), "set"+propKey); + } + + // Reads a property value in int format. + // Caller will always supply a non-null props and propKey. + // Returns defaultValue if the specific property value is not set. + private int getIntProperty(Properties props, String propKey, int defaultValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "get"+propKey); + String propValue = props.getProperty(propKey); + int value = defaultValue; + if (null!=propValue) + { + try + { + value = Integer.parseInt(propValue); + } + catch(NumberFormatException nfe) + { + // This exception cannot occur as all of our properties + // are set internally by int -> Integer.toString. + assert false : "Bad portNumber:-"+ propValue; + } + } + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.exiting(getClassNameLogging(), "get"+propKey, new Integer(value)); + return value; + } + + // Set a boolean property value. + // Caller will always supply a non-null props and propKey. + private void setBooleanProperty(Properties props, String propKey, boolean propValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "set"+propKey, Boolean.valueOf(propValue)); + props.setProperty(propKey, (propValue) ? "true" : "false" ); + loggerExternal.exiting(getClassNameLogging(), "set"+propKey); + } + + // Reads a property value in boolean format. + // Caller will always supply a non-null props and propKey. + // Returns defaultValue if the specific property value is not set. + private boolean getBooleanProperty(Properties props, String propKey, boolean defaultValue) + { + if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) + loggerExternal.entering(getClassNameLogging(), "get"+propKey); + String propValue = props.getProperty(propKey); + Boolean value; + if (null==propValue) + { + value = defaultValue; + } + else + { + // Since we set the value of the String property ourselves to + // "true" or "false", we can do this. + value = Boolean.valueOf(propValue); + } + loggerExternal.exiting(getClassNameLogging(), "get"+propKey, value); + return value.booleanValue(); + } + + + // Returns a SQLServerConnection given username, password, and pooledConnection. + // Note that the DataSource properties set to connectionProps are used when creating + // the connection. + + // Both username and password can be null. + + // If pooledConnection is not null, then connection returned is attached to the pooledConnection + // and participates in connection pooling. + SQLServerConnection getConnectionInternal(String username, String password, + SQLServerPooledConnection pooledConnection) throws SQLServerException + { + Properties userSuppliedProps = null; + Properties mergedProps = null; + // Trust store password stripped and this object got created via Objectfactory referencing. + if(trustStorePasswordStripped) + SQLServerException.makeFromDriverError(null, null, + SQLServerException.getErrString("R_referencingFailedTSP"), null, true); + + // If username or password is passed in, clone the property set so we + // don't alter original connectionProps. + if (null != username || null != password) + { + userSuppliedProps = (Properties)this.connectionProps.clone(); + + // Remove user and password from connectionProps if set. + // We want the user supplied user+password to replace + // whatever is set in connectionProps. + userSuppliedProps.remove(SQLServerDriverStringProperty.USER.toString()); + userSuppliedProps.remove(SQLServerDriverStringProperty.PASSWORD.toString()); + + if (null != username) + userSuppliedProps.put(SQLServerDriverStringProperty.USER.toString(), username); + if (null != password) + userSuppliedProps.put(SQLServerDriverStringProperty.PASSWORD.toString(), password); + } + else + { + userSuppliedProps = connectionProps; + } + + // Merge in URL properties into userSuppliedProps if URL is set. + if (null != dataSourceURL) + { + Properties urlProps = Util.parseUrl(dataSourceURL, dsLogger); + // null returned properties means that the passed in URL is not supported. + if(null == urlProps) + SQLServerException.makeFromDriverError(null, null, + SQLServerException.getErrString("R_errorConnectionString"), null, true); + // Manually merge URL props and user supplied props. + mergedProps = SQLServerDriver.mergeURLAndSuppliedProperties(urlProps, userSuppliedProps); + } + else + { + mergedProps = userSuppliedProps; + } + + // Create new connection and connect. + if (dsLogger.isLoggable(Level.FINER)) + dsLogger.finer(toString() + " Begin create new connection."); + SQLServerConnection result = new SQLServerConnection(toString()); + result.connect(mergedProps, pooledConnection); + if (dsLogger.isLoggable(Level.FINER)) + dsLogger.finer(toString() + " End create new connection " + result.toString()); + return result; + } + + // Implement javax.naming.Referenceable interface methods. + + public Reference getReference() + { + loggerExternal.entering(getClassNameLogging(), "getReference"); + Reference ref = getReferenceInternal("com.microsoft.sqlserver.jdbc.SQLServerDataSource"); + loggerExternal.exiting(getClassNameLogging(), "getReference", ref); + return ref; + } + + Reference getReferenceInternal(String dataSourceClassString) + { + if (dsLogger.isLoggable(Level.FINER)) + dsLogger.finer(toString() + " creating reference for " + dataSourceClassString + "."); + + Reference ref = new Reference(this.getClass().getName(), + "com.microsoft.sqlserver.jdbc.SQLServerDataSourceObjectFactory", null); + if(null != dataSourceClassString) + ref.add(new StringRefAddr("class", dataSourceClassString)); + + if(trustStorePasswordStripped) + ref.add(new StringRefAddr("trustStorePasswordStripped", "true")); + + // Add each property name+value pair found in connectionProps. + Enumeration e = connectionProps.keys(); + while (e.hasMoreElements()) + { + String propertyName = (String)e.nextElement(); + // If a trustStore password is set, it is omitted and a trustStorePasswordSet flag is set. + if(propertyName.equals(SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString())) + { + // The property set and the variable set at the same time is not possible + assert trustStorePasswordStripped == false; + ref.add(new StringRefAddr("trustStorePasswordStripped", "true")); + } + else + { + // do not add passwords to the collection. we have normal password + if (!propertyName.contains(SQLServerDriverStringProperty.PASSWORD.toString())) + ref.add(new StringRefAddr(propertyName, connectionProps.getProperty(propertyName))); + } + } + + // Add dataSourceURL and dataSourceDescription as these will not appear in connectionProps. + if (null != dataSourceURL) + ref.add(new StringRefAddr("dataSourceURL", dataSourceURL)); + + if (null != dataSourceDescription) + ref.add(new StringRefAddr("dataSourceDescription", dataSourceDescription)); + + return ref; + } + + // Initialize this datasource from properties found inside the reference ref. + // Called by SQLServerDataSourceObjectFactory to initialize new DataSource instance. + void initializeFromReference(javax.naming.Reference ref) + { + // Enumerate all the StringRefAddr objects in the Reference and assign properties appropriately. + Enumeration e = ref.getAll(); + while (e.hasMoreElements()) + { + StringRefAddr addr = (StringRefAddr) e.nextElement(); + String propertyName = addr.getType(); + String propertyValue = (String) addr.getContent(); + + // Special case dataSourceURL and dataSourceDescription. + if (propertyName.equals("dataSourceURL")) + { + dataSourceURL = propertyValue; + } + else if (propertyName.equals("dataSourceDescription")) + { + dataSourceDescription = propertyValue; + } + else if (propertyName.equals("trustStorePasswordStripped")) + { + trustStorePasswordStripped = true; + } + // Just skip "class" StringRefAddr, it does not go into connectionProps + else if (false == propertyName.equals("class")) + { + + connectionProps.setProperty(propertyName, propertyValue); + } + } + } + + public boolean isWrapperFor(Class iface) throws SQLException + { + loggerExternal.entering(getClassNameLogging(), "isWrapperFor", iface ); + DriverJDBCVersion.checkSupportsJDBC4(); + boolean f = iface.isInstance(this); + loggerExternal.exiting(getClassNameLogging(), "isWrapperFor", Boolean.valueOf(f)); + return f; + } + + public T unwrap(Class iface) throws SQLException + { + loggerExternal.entering(getClassNameLogging(), "unwrap", iface); + DriverJDBCVersion.checkSupportsJDBC4(); + + T t; + try + { + t = iface.cast(this); + } + catch (ClassCastException e) + { + throw new SQLServerException(e.getMessage(), e); + } + loggerExternal.exiting(getClassNameLogging(), "unwrap", t); + return t; + } + + // Returns unique id for each DataSource instance. + private synchronized static int nextDataSourceID() + { + baseDataSourceID++; + return baseDataSourceID; + } + private Object writeReplace() throws java.io.ObjectStreamException + { + return new SerializationProxy(this); + } + private void readObject(java.io.ObjectInputStream stream) throws java.io.InvalidObjectException + { + // For added security/robustness, the only way to rehydrate a serialized SQLServerDataSource + // is to use a SerializationProxy. Direct use of readObject() is not supported. + throw new java.io.InvalidObjectException(""); + } + + // This code is duplicated in pooled and XA datasource classes. + private static class SerializationProxy + implements java.io.Serializable + { + private final Reference ref; + private static final long serialVersionUID = 654661379542314226L; + + SerializationProxy (SQLServerDataSource ds) + { + // We do not need the class name so pass null, serialization mechanism + // stores the class info. + ref = ds.getReferenceInternal(null); + } + private Object readResolve() + { + SQLServerDataSource ds = new SQLServerDataSource(); + ds.initializeFromReference(ref); + return ds; + } + } +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java index d42a9d664..f49c48dcd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java @@ -1,264 +1,264 @@ -//--------------------------------------------------------------------------------------------------------------------------------- -// File: SQLServerPooledConnection.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), -// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//--------------------------------------------------------------------------------------------------------------------------------- - - -package com.microsoft.sqlserver.jdbc; - -import javax.sql.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; - -/** - * SQLServerPooledConnection represents a database physical connection in a connection pool. If provides - * methods for the connection pool manager to manage the connection pool. Applications typically - * do not instantiate these connections directly. - */ - -public class SQLServerPooledConnection implements PooledConnection { - private final Vector listeners; - private SQLServerDataSource factoryDataSource; - private SQLServerConnection physicalConnection; - private SQLServerConnectionPoolProxy lastProxyConnection; - private String factoryUser, factoryPassword; - private java.util.logging.Logger pcLogger; - static private int basePooledConnectionID = 0; // Unique id generator for each PooledConnection instance (used for logging). - private final String traceID; - - - SQLServerPooledConnection(SQLServerDataSource ds, String user, String password) throws SQLException - { - listeners = new Vector(); - // Piggyback SQLServerDataSource logger for now. - pcLogger = SQLServerDataSource.dsLogger; - - // Create the physical connection. - factoryDataSource = ds; - factoryUser = user; - factoryPassword = password; - - if (pcLogger.isLoggable(Level.FINER)) - pcLogger.finer(toString()+ " Start create new connection for pool."); - - physicalConnection = createNewConnection(); - String nameL = getClass().getName(); - traceID = nameL.substring(1 + nameL.lastIndexOf('.')) + ":" +nextPooledConnectionID(); - if (pcLogger.isLoggable(Level.FINE)) - pcLogger.fine(toString() + " created by (" + ds.toString() +")" +" Physical connection " + safeCID() + ", End create new connection for pool"); - } - - /** - * This is a helper function to provide an ID string suitable for tracing. - */ - public String toString() - { - return traceID; - } - - // Helper function to create a new connection for the pool. - private SQLServerConnection createNewConnection() throws SQLException - { - return factoryDataSource.getConnectionInternal(factoryUser, factoryPassword, this); - } - - /** - * Creates an object handle for the physical connection that this PooledConnection object represents. - * @throws SQLException - */ - public Connection getConnection() throws SQLException { - if (pcLogger.isLoggable(Level.FINER)) - pcLogger.finer(toString() + " user:(default)."); - synchronized(this) - { - // If physical connection is closed, throw exception per spec, this PooledConnection is dead. - if (physicalConnection == null) - { - SQLServerException.makeFromDriverError(null, this, - SQLServerException.getErrString("R_physicalConnectionIsClosed"), - "", true); - } - // Check with security manager to insure caller has rights to connect. - // This will throw a SecurityException if the caller does not have proper rights. - physicalConnection.doSecurityCheck(); - if (pcLogger.isLoggable(Level.FINE)) - pcLogger.fine(toString() + " Physical connection, " + safeCID()); - - if(null != physicalConnection.getAuthenticationResult()){ - if(Util.checkIfNeedNewAccessToken(physicalConnection)) - { - physicalConnection = createNewConnection(); - } - } - - // The last proxy connection handle returned will be invalidated (moved to closed state) - // when getConnection is called. - if(null != lastProxyConnection ) - { - // if there was a last proxy connection send reset - physicalConnection.resetPooledConnection(); - if (pcLogger.isLoggable(Level.FINE)&& !lastProxyConnection.isClosed()) - pcLogger.fine(toString() + "proxy " + lastProxyConnection.toString()+ " is not closed before getting the connection."); - // use internal close so there wont be an event due to us closing the connection, if not closed already. - lastProxyConnection.internalClose(); - } - - lastProxyConnection = new SQLServerConnectionPoolProxy(physicalConnection); - if (pcLogger.isLoggable(Level.FINE)&& !lastProxyConnection.isClosed()) - pcLogger.fine(toString() + " proxy " +lastProxyConnection.toString()+ " is returned."); - - return lastProxyConnection; - } - } - - // Notify any interested parties (e.g. pooling managers) of a ConnectionEvent activity - // on the connection. Calling notifyEvent with null event will place the - // connection back in the pool. Calling notifyEvent with a non-null event is - // used to notify the pooling manager that the connection is bad and should be removed - // from the pool. - void notifyEvent(SQLServerException e) - { - if (pcLogger.isLoggable(Level.FINER)) - pcLogger.finer(toString() + " Exception:" + e + safeCID()); - - // close the proxy on fatal error event. Note exception is null then the event comes from the proxy close. - if(null != e) - { - synchronized(this) - { - if( null != lastProxyConnection) - { - lastProxyConnection.internalClose(); - lastProxyConnection = null; - } - } - } - - // A connection handle issued from this pooled connection is closing or an error occurred in the connection - synchronized(listeners) - { - for (int i=0; i listeners; + private SQLServerDataSource factoryDataSource; + private SQLServerConnection physicalConnection; + private SQLServerConnectionPoolProxy lastProxyConnection; + private String factoryUser, factoryPassword; + private java.util.logging.Logger pcLogger; + static private int basePooledConnectionID = 0; // Unique id generator for each PooledConnection instance (used for logging). + private final String traceID; + + + SQLServerPooledConnection(SQLServerDataSource ds, String user, String password) throws SQLException + { + listeners = new Vector(); + // Piggyback SQLServerDataSource logger for now. + pcLogger = SQLServerDataSource.dsLogger; + + // Create the physical connection. + factoryDataSource = ds; + factoryUser = user; + factoryPassword = password; + + if (pcLogger.isLoggable(Level.FINER)) + pcLogger.finer(toString()+ " Start create new connection for pool."); + + physicalConnection = createNewConnection(); + String nameL = getClass().getName(); + traceID = nameL.substring(1 + nameL.lastIndexOf('.')) + ":" +nextPooledConnectionID(); + if (pcLogger.isLoggable(Level.FINE)) + pcLogger.fine(toString() + " created by (" + ds.toString() +")" +" Physical connection " + safeCID() + ", End create new connection for pool"); + } + + /** + * This is a helper function to provide an ID string suitable for tracing. + */ + public String toString() + { + return traceID; + } + + // Helper function to create a new connection for the pool. + private SQLServerConnection createNewConnection() throws SQLException + { + return factoryDataSource.getConnectionInternal(factoryUser, factoryPassword, this); + } + + /** + * Creates an object handle for the physical connection that this PooledConnection object represents. + * @throws SQLException + */ + public Connection getConnection() throws SQLException { + if (pcLogger.isLoggable(Level.FINER)) + pcLogger.finer(toString() + " user:(default)."); + synchronized(this) + { + // If physical connection is closed, throw exception per spec, this PooledConnection is dead. + if (physicalConnection == null) + { + SQLServerException.makeFromDriverError(null, this, + SQLServerException.getErrString("R_physicalConnectionIsClosed"), + "", true); + } + // Check with security manager to insure caller has rights to connect. + // This will throw a SecurityException if the caller does not have proper rights. + physicalConnection.doSecurityCheck(); + if (pcLogger.isLoggable(Level.FINE)) + pcLogger.fine(toString() + " Physical connection, " + safeCID()); + + if(null != physicalConnection.getAuthenticationResult()){ + if(Util.checkIfNeedNewAccessToken(physicalConnection)) + { + physicalConnection = createNewConnection(); + } + } + + // The last proxy connection handle returned will be invalidated (moved to closed state) + // when getConnection is called. + if(null != lastProxyConnection ) + { + // if there was a last proxy connection send reset + physicalConnection.resetPooledConnection(); + if (pcLogger.isLoggable(Level.FINE)&& !lastProxyConnection.isClosed()) + pcLogger.fine(toString() + "proxy " + lastProxyConnection.toString()+ " is not closed before getting the connection."); + // use internal close so there wont be an event due to us closing the connection, if not closed already. + lastProxyConnection.internalClose(); + } + + lastProxyConnection = new SQLServerConnectionPoolProxy(physicalConnection); + if (pcLogger.isLoggable(Level.FINE)&& !lastProxyConnection.isClosed()) + pcLogger.fine(toString() + " proxy " +lastProxyConnection.toString()+ " is returned."); + + return lastProxyConnection; + } + } + + // Notify any interested parties (e.g. pooling managers) of a ConnectionEvent activity + // on the connection. Calling notifyEvent with null event will place the + // connection back in the pool. Calling notifyEvent with a non-null event is + // used to notify the pooling manager that the connection is bad and should be removed + // from the pool. + void notifyEvent(SQLServerException e) + { + if (pcLogger.isLoggable(Level.FINER)) + pcLogger.finer(toString() + " Exception:" + e + safeCID()); + + // close the proxy on fatal error event. Note exception is null then the event comes from the proxy close. + if(null != e) + { + synchronized(this) + { + if( null != lastProxyConnection) + { + lastProxyConnection.internalClose(); + lastProxyConnection = null; + } + } + } + + // A connection handle issued from this pooled connection is closing or an error occurred in the connection + synchronized(listeners) + { + for (int i=0; i Date: Fri, 25 Nov 2016 16:05:41 -0800 Subject: [PATCH 21/42] fix inaccurate comments about JDBC APIs --- .../microsoft/sqlserver/jdbc/SQLServerCallableStatement.java | 4 ++-- .../sqlserver/jdbc/SQLServerConnectionPoolProxy.java | 4 ++-- .../java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index aec394ef9..14a7ecea6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -729,7 +729,7 @@ public T getObject(int index, Class type) throws SQLException { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } @@ -750,7 +750,7 @@ public T getObject(String sCol, Class type) throws SQLException { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java index 13992a77b..0655caade 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java @@ -429,7 +429,7 @@ public int getNetworkTimeout() throws SQLException { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } @@ -437,7 +437,7 @@ public void setNetworkTimeout(Executor executor, int timeout) throws SQLExceptio { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 5db0bb8f8..1891b3482 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -2380,7 +2380,7 @@ public T getObject(int columnIndex, Class type) throws SQLException { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } @@ -2397,7 +2397,7 @@ public T getObject(String columnName, Class type) throws SQLException { DriverJDBCVersion.checkSupportsJDBC41(); - // The driver currently does not implement JDDBC 4.1 APIs + // The driver currently does not implement the optional JDBC APIs throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported")); } From 5b3138db1918010e0bc3a96be5025af800d6158e Mon Sep 17 00:00:00 2001 From: v-ahibr Date: Mon, 28 Nov 2016 15:11:25 -0800 Subject: [PATCH 22/42] Correct the byte order of version number in login7 packet --- .../sqlserver/jdbc/SQLServerConnection.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 8d08e67de..2c855c958 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -4153,7 +4153,7 @@ else if (serverMajorVersion >= 10) //Katmai (10.0) & later 7.3B tdsWriter.writeInt(len2); tdsWriter.writeInt(tdsVersion); tdsWriter.writeInt(requestedPacketSize); - tdsWriter.writeBytes(interfaceLibVersionBytes); + tdsWriter.writeBytes(interfaceLibVersionBytes); //writeBytes() is little endian tdsWriter.writeInt(0); // Client process ID (0 = ??) tdsWriter.writeInt(0); // Primary server connection ID @@ -4361,37 +4361,37 @@ private String generateInterfaceLibVersion() { // build the interface lib name - // 2 characters reserved for major - // 2 characters reserved for minor - // 2 characters reserved for patch // 2 characters reserved for build + // 2 characters reserved for patch + // 2 characters reserved for minor + // 2 characters reserved for major if(2 == interfaceLibMajor.length()){ - outputInterfaceLibVersion.append(interfaceLibMajor); + outputInterfaceLibVersion.append(interfaceLibBuild); } else{ outputInterfaceLibVersion.append("0"); - outputInterfaceLibVersion.append(interfaceLibMajor); + outputInterfaceLibVersion.append(interfaceLibBuild); } if(2 == interfaceLibMinor.length()){ - outputInterfaceLibVersion.append(interfaceLibMinor); + outputInterfaceLibVersion.append(interfaceLibPatch); } else{ outputInterfaceLibVersion.append("0"); - outputInterfaceLibVersion.append(interfaceLibMinor); + outputInterfaceLibVersion.append(interfaceLibPatch); } if(2 == interfaceLibPatch.length()){ - outputInterfaceLibVersion.append(interfaceLibPatch); + outputInterfaceLibVersion.append(interfaceLibMinor); } else{ outputInterfaceLibVersion.append("0"); - outputInterfaceLibVersion.append(interfaceLibPatch); + outputInterfaceLibVersion.append(interfaceLibMinor); } if(2 == interfaceLibBuild.length()){ - outputInterfaceLibVersion.append(interfaceLibBuild); + outputInterfaceLibVersion.append(interfaceLibMajor); } else{ outputInterfaceLibVersion.append("0"); - outputInterfaceLibVersion.append(interfaceLibBuild); + outputInterfaceLibVersion.append(interfaceLibMajor); } return outputInterfaceLibVersion.toString(); From 317d1b5bb1850f88eacc9414fecbec6b2984b92a Mon Sep 17 00:00:00 2001 From: Mike Friesen Date: Mon, 28 Nov 2016 19:11:07 -0600 Subject: [PATCH 23/42] added queryTimeout connection parameter --- .../sqlserver/jdbc/SQLServerDriver.java | 2 ++ .../sqlserver/jdbc/SQLServerResource.java | 1 + .../sqlserver/jdbc/SQLServerStatement.java | 14 +++++++++++ .../microsoft/sqlserver/jdbc/bvt/bvtTest.java | 25 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 05272f9cb..79fef2116 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -889,6 +889,7 @@ enum SQLServerDriverIntProperty PACKET_SIZE("packetSize", TDS.DEFAULT_PACKET_SIZE), LOCK_TIMEOUT("lockTimeout", -1), LOGIN_TIMEOUT("loginTimeout", 15), + QUERY_TIMEOUT("queryTimeout", -1), PORT_NUMBER("portNumber", 1433); private String name; @@ -975,6 +976,7 @@ public final class SQLServerDriver implements java.sql.Driver new SQLServerDriverPropertyInfo(SQLServerDriverIntProperty.PACKET_SIZE.toString(), Integer.toString(SQLServerDriverIntProperty.PACKET_SIZE.getDefaultValue()), false, null), new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.PASSWORD.toString(), SQLServerDriverStringProperty.PASSWORD.getDefaultValue(), true, null), new SQLServerDriverPropertyInfo(SQLServerDriverIntProperty.PORT_NUMBER.toString(), Integer.toString(SQLServerDriverIntProperty.PORT_NUMBER.getDefaultValue()), false, null), + new SQLServerDriverPropertyInfo(SQLServerDriverIntProperty.QUERY_TIMEOUT.toString(), Integer.toString(SQLServerDriverIntProperty.QUERY_TIMEOUT.getDefaultValue()), false, null), new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.RESPONSE_BUFFERING.toString(), SQLServerDriverStringProperty.RESPONSE_BUFFERING.getDefaultValue(), false, new String[] {"adaptive", "full"}), new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.SELECT_METHOD.toString(), SQLServerDriverStringProperty.SELECT_METHOD.getDefaultValue(), false, new String[] {"direct", "cursor"}), new SQLServerDriverPropertyInfo(SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), Boolean.toString(SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue()), false, TRUE_FALSE), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java index 776b6f184..59b5adf9a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java @@ -199,6 +199,7 @@ protected Object[][] getContents() {"R_hostNameInCertificatePropertyDescription", "The host name to be used when validating the SQL Server Secure Sockets Layer (SSL) certificate."}, {"R_sendTimeAsDatetimePropertyDescription", "Determines whether to use the SQL Server datetime data type to send java.sql.Time values to the database."}, {"R_TransparentNetworkIPResolutionPropertyDescription", "Determines whether to use the Transparent Network IP Resolution feature."}, + {"R_queryTimeoutPropertyDescription", "The number of seconds to wait before the database reports a query time-out."}, {"R_noParserSupport", "An error occurred while instantiating the required parser. Error: \"{0}\""}, {"R_writeOnlyXML", "Cannot read from this SQLXML instance. This instance is for writing data only."}, {"R_dataHasBeenReadXML", "Cannot read from this SQLXML instance. The data has already been read."}, diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 9426f3d6c..2621b208a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -602,6 +602,7 @@ else if (ResultSet.TYPE_SCROLL_SENSITIVE == nType) // All result set types other than firehose (SQL Server default) use server side cursors. setResponseBuffering(connection.getResponseBuffering()); + setDefaultQueryTimeout(); if(stmtlogger.isLoggable(java.util.logging.Level.FINER)) { @@ -619,6 +620,19 @@ else if (ResultSet.TYPE_SCROLL_SENSITIVE == nType) } } + // add query timeout to statement + private void setDefaultQueryTimeout() { + + String sPropValue = this.connection.activeConnectionProperties.getProperty(SQLServerDriverIntProperty.QUERY_TIMEOUT.toString()); + + if (null != sPropValue && sPropValue.length() > 0) { + int queryTimeoutSeconds = Integer.parseInt(sPropValue); + if (queryTimeoutSeconds > 0) { + this.queryTimeout = queryTimeoutSeconds; + } + } + } + final java.util.logging.Logger getStatementLogger() { return stmtlogger; diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java index 64e5276b1..eef521e2b 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java @@ -35,6 +35,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of public class bvtTest { private static boolean cursor = false; + private static boolean querytimeout = false; private static String connectionUrl = ""; private static Connection con; private static String driverNamePattern = "Microsoft JDBC Driver \\d.\\d for SQL Server"; @@ -137,6 +138,26 @@ public void testCreateStatement() throws SQLException { } } + /////////////////////////////////////////////////////////////////// + // Create a statement with a query timeout + // ResultSet.Type_forward_only, + // ResultSet.CONCUR_READ_ONLY, executeQuery + // verify cursor by using next and previous and verify data + /////////////////////////////////////////////////////////////////// + @Test + public void testCreateStatementWithQueryTimeout() throws SQLException { + + querytimeout = true; + + try { + stmt = conn().createStatement(); + assertEquals(10, stmt.getQueryTimeout()); + } finally { + terminateVariation(); + querytimeout = false; + } + } + /////////////////////////////////////////////////////////////////// // Create a statement // ResultSet.Type_forward_only, @@ -617,6 +638,10 @@ public static String getConnectionURL() { connectionUrl += ";selectMethod=cursor;"; } + if (querytimeout){ + connectionUrl += "queryTimeout=10"; + } + return connectionUrl; } From 1e4a61a4558b27783103dbae756237779499649c Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Mon, 28 Nov 2016 17:50:58 -0800 Subject: [PATCH 24/42] Updated Scope Updated Scope. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0bf8c9bf..7a4eebed6 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ If you wish to limit the number of run-time dependencies, and your project does com.microsoft.sqlserver mssql-jdbc 6.1.0.jre8 - runtime + compile com.microsoft.azure From b4658912702442205a60a27a895daeb657f3200a Mon Sep 17 00:00:00 2001 From: Mike Friesen Date: Tue, 29 Nov 2016 08:32:38 -0600 Subject: [PATCH 25/42] Update bvtTest.java added missing ';' to queryTimeout --- src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java index eef521e2b..c925a654d 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java @@ -639,7 +639,7 @@ public static String getConnectionURL() { } if (querytimeout){ - connectionUrl += "queryTimeout=10"; + connectionUrl += ";queryTimeout=10"; } return connectionUrl; From aed6d9593751a99fbbbe7e7115eefaa4bd05b72a Mon Sep 17 00:00:00 2001 From: v-ahibr Date: Wed, 30 Nov 2016 11:19:00 -0800 Subject: [PATCH 26/42] Fixing Javadocs This adds javadocs to public methods and fixes incorrect javadocs --- .../java/com/microsoft/sqlserver/jdbc/AE.java | 2 +- .../sqlserver/jdbc/ActivityCorrelator.java | 2 +- .../sqlserver/jdbc/AuthenticationJNI.java | 9 +- .../com/microsoft/sqlserver/jdbc/Column.java | 2 +- .../com/microsoft/sqlserver/jdbc/DDC.java | 14 +- .../sqlserver/jdbc/DLLException.java | 10 +- .../microsoft/sqlserver/jdbc/DataTypes.java | 6 +- .../sqlserver/jdbc/FailOverInfo.java | 2 +- .../sqlserver/jdbc/FailOverMapSingleton.java | 2 +- .../microsoft/sqlserver/jdbc/IOBuffer.java | 27 +- .../sqlserver/jdbc/ISQLServerBulkRecord.java | 5 +- .../jdbc/ISQLServerCallableStatement.java | 35 +- .../jdbc/ISQLServerCallableStatement42.java | 34 +- .../sqlserver/jdbc/ISQLServerConnection.java | 12 +- .../sqlserver/jdbc/ISQLServerDataRecord.java | 8 +- .../sqlserver/jdbc/ISQLServerDataSource.java | 277 ++++- .../jdbc/ISQLServerPreparedStatement.java | 11 +- .../jdbc/ISQLServerPreparedStatement42.java | 40 +- .../sqlserver/jdbc/ISQLServerResultSet.java | 31 +- .../sqlserver/jdbc/ISQLServerResultSet42.java | 37 +- .../sqlserver/jdbc/ISQLServerStatement.java | 21 +- .../sqlserver/jdbc/KerbAuthentication.java | 2 +- .../jdbc/KeyStoreProviderCommon.java | 2 +- .../sqlserver/jdbc/KeyVaultCredential.java | 13 +- .../sqlserver/jdbc/PLPInputStream.java | 16 +- .../microsoft/sqlserver/jdbc/Parameter.java | 2 +- .../sqlserver/jdbc/ParameterUtils.java | 2 +- .../sqlserver/jdbc/ReaderInputStream.java | 2 +- .../sqlserver/jdbc/SQLCollation.java | 2 +- ...QLServerAeadAes256CbcHmac256Algorithm.java | 2 +- ...rverAeadAes256CbcHmac256EncryptionKey.java | 2 +- .../SQLServerAeadAes256CbcHmac256Factory.java | 2 +- .../sqlserver/jdbc/SQLServerBlob.java | 27 +- .../jdbc/SQLServerBulkCSVFileRecord.java | 32 +- .../sqlserver/jdbc/SQLServerBulkCopy.java | 4 +- .../jdbc/SQLServerBulkCopy42Helper.java | 2 +- .../jdbc/SQLServerBulkCopyOptions.java | 18 +- .../jdbc/SQLServerCallableStatement.java | 681 ++++++++++++- .../jdbc/SQLServerCallableStatement42.java | 2 +- .../sqlserver/jdbc/SQLServerClob.java | 23 +- ...ColumnEncryptionAzureKeyVaultProvider.java | 8 +- ...umnEncryptionCertificateStoreProvider.java | 7 +- ...rColumnEncryptionJavaKeyStoreProvider.java | 13 +- ...erverColumnEncryptionKeyStoreProvider.java | 35 +- .../sqlserver/jdbc/SQLServerConnection.java | 280 ++++- .../SQLServerConnectionPoolDataSource.java | 2 +- .../jdbc/SQLServerConnectionPoolProxy.java | 278 ++++- .../sqlserver/jdbc/SQLServerDataColumn.java | 18 +- .../sqlserver/jdbc/SQLServerDataSource.java | 85 +- .../SQLServerDataSourceObjectFactory.java | 6 +- .../sqlserver/jdbc/SQLServerDataTable.java | 31 +- .../jdbc/SQLServerDatabaseMetaData.java | 7 +- .../sqlserver/jdbc/SQLServerDriver.java | 621 +---------- .../jdbc/SQLServerEncryptionAlgorithm.java | 6 +- .../SQLServerEncryptionAlgorithmFactory.java | 4 +- ...LServerEncryptionAlgorithmFactoryList.java | 2 +- .../jdbc/SQLServerEncryptionType.java | 2 +- .../sqlserver/jdbc/SQLServerException.java | 2 +- .../sqlserver/jdbc/SQLServerJdbc41.java | 2 +- .../sqlserver/jdbc/SQLServerJdbc42.java | 2 +- ...LServerKeyVaultAuthenticationCallback.java | 2 +- .../sqlserver/jdbc/SQLServerMetaData.java | 67 +- .../sqlserver/jdbc/SQLServerNClob.java | 2 +- .../jdbc/SQLServerParameterMetaData.java | 9 +- .../jdbc/SQLServerPooledConnection.java | 16 +- .../jdbc/SQLServerPreparedStatement.java | 444 +++++++- .../jdbc/SQLServerPreparedStatement42.java | 2 +- .../SQLServerPreparedStatement42Helper.java | 2 +- .../sqlserver/jdbc/SQLServerResource.java | 5 +- .../sqlserver/jdbc/SQLServerResultSet.java | 963 +++++++++++++++++- .../sqlserver/jdbc/SQLServerResultSet42.java | 7 +- .../jdbc/SQLServerResultSetMetaData.java | 5 +- .../sqlserver/jdbc/SQLServerSQLXML.java | 7 +- .../sqlserver/jdbc/SQLServerSavepoint.java | 8 +- .../jdbc/SQLServerSecurityUtility.java | 7 +- .../sqlserver/jdbc/SQLServerSortOrder.java | 7 +- .../sqlserver/jdbc/SQLServerStatement.java | 22 +- ...erverStatementColumnEncryptionSetting.java | 9 +- .../sqlserver/jdbc/SQLServerSymmetricKey.java | 2 +- .../jdbc/SQLServerSymmetricKeyCache.java | 2 +- .../sqlserver/jdbc/SQLServerXAConnection.java | 2 +- .../sqlserver/jdbc/SQLServerXADataSource.java | 6 +- .../sqlserver/jdbc/SQLServerXAResource.java | 7 +- .../sqlserver/jdbc/SSPIAuthentication.java | 2 +- .../sqlserver/jdbc/ScrollWindow.java | 2 +- .../sqlserver/jdbc/SimpleInputStream.java | 4 +- .../sqlserver/jdbc/StreamColInfo.java | 2 +- .../sqlserver/jdbc/StreamColumns.java | 2 +- .../microsoft/sqlserver/jdbc/StreamDone.java | 2 +- .../microsoft/sqlserver/jdbc/StreamError.java | 2 +- .../microsoft/sqlserver/jdbc/StreamInfo.java | 2 +- .../sqlserver/jdbc/StreamLoginAck.java | 2 +- .../sqlserver/jdbc/StreamPacket.java | 2 +- .../sqlserver/jdbc/StreamRetStatus.java | 2 +- .../sqlserver/jdbc/StreamRetValue.java | 2 +- .../microsoft/sqlserver/jdbc/StreamSSPI.java | 2 +- .../sqlserver/jdbc/StreamTabName.java | 2 +- .../com/microsoft/sqlserver/jdbc/TVP.java | 15 +- .../sqlserver/jdbc/UDTTDSHeader.java | 2 +- .../com/microsoft/sqlserver/jdbc/Util.java | 4 +- .../sqlserver/jdbc/XMLTDSHeader.java | 2 +- .../com/microsoft/sqlserver/jdbc/dtv.java | 127 ++- .../microsoft/sqlserver/jdbc/tdsparser.java | 2 +- .../java/microsoft/sql/DateTimeOffset.java | 14 +- src/main/java/microsoft/sql/Types.java | 29 +- 105 files changed, 3777 insertions(+), 885 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/AE.java b/src/main/java/com/microsoft/sqlserver/jdbc/AE.java index f26d9dae8..d24f6fe8e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/AE.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/AE.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ActivityCorrelator.java b/src/main/java/com/microsoft/sqlserver/jdbc/ActivityCorrelator.java index 148e48fc3..184bb4153 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ActivityCorrelator.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ActivityCorrelator.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/AuthenticationJNI.java b/src/main/java/com/microsoft/sqlserver/jdbc/AuthenticationJNI.java index 63bc80934..f63f960c8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/AuthenticationJNI.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/AuthenticationJNI.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -19,10 +19,6 @@ package com.microsoft.sqlserver.jdbc; -/** - * Encapsulation of the JNI native calls for trusted authentication. - */ - class FedAuthDllInfo{ byte[] accessTokenBytes = null; long expiresIn = 0; @@ -33,6 +29,9 @@ class FedAuthDllInfo{ } } +/** + * Encapsulation of the JNI native calls for trusted authentication. + */ final class AuthenticationJNI extends SSPIAuthentication { private final static int maximumpointersize = 128; // we keep the SNI_Sec pointer diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java index 087b5df56..35b22ec70 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java index d8b702291..3cf9fe55f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -355,6 +355,14 @@ static final Object convertBigDecimalToObject(BigDecimal bigDecimalVal, JDBCType } } + /** + * Convert a Money object to desired target user type. + * @param bigDecimalVal the value to convert. + * @param jdbcType the jdbc type required. + * @param streamType the stream type. + * @param numberOfBytes the number of bytes to convert + * @return the required object. + */ static final Object convertMoneyToObject(BigDecimal bigDecimalVal, JDBCType jdbcType, StreamType streamType, int numberOfBytes) { switch (jdbcType) @@ -386,7 +394,7 @@ static final Object convertMoneyToObject(BigDecimal bigDecimalVal, JDBCType jdbc } } - //this is how fx framework converts big decimal to money and smallmoney + //converts big decimal to money and smallmoney private static byte[] convertToBytes(BigDecimal value, int scale, int numBytes) { boolean isNeg = value.signum() < 0; @@ -419,7 +427,7 @@ private static byte[] convertToBytes(BigDecimal value, int scale, int numBytes) * @param jdbcType the jdbc type required. * @param baseTypeInfo the type information associated with bytesValue. * @return the required object. - * @throws SQLServerException + * @throws SQLServerException when an error occurs. */ static final Object convertBytesToObject(byte[] bytesValue, JDBCType jdbcType, TypeInfo baseTypeInfo) throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java index 54da6af2d..ff6328f77 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -21,9 +21,15 @@ import java.text.MessageFormat; - +/** + * + * This class is used to handle exceptions that may be recieved from + * sqljdbc_auth.dll and sqljdbc_xa.dll + * + */ class DLLException extends Exception { + private static final long serialVersionUID = -4498171382218222079L; // category status and state are always either -1 or a positive number // Internal Adal error category used in retry logic and building error message in managed code private int category = -9; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java index 052b1a3f7..3c60dc157 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java @@ -7,7 +7,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -886,6 +886,10 @@ private JDBCType(Category category, int intValue, String className) this.className = className; } + /** + * Gets the integer value of JDBCType + * @return integer representation of JDBCType + */ public int getIntValue() { return this.intValue; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java index 40540643e..c9afc8acf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java index 9b7473724..e9d593551 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java @@ -7,7 +7,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index b176601c9..6f0d7e1df 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -2865,13 +2865,20 @@ void updateResult(Socket socket, IOException exception, String threadId) } - //Updates the selectedException if - //a) selectedException is null - //b) ex is a non-socketTimeoutException and selectedException is a socketTimeoutException - //If there are multiple exceptions, that are not related to socketTimeout - //the first non-socketTimeout exception is picked. - //If all exceptions are related to socketTimeout, the first exception is picked. - //Note: This method is not thread safe. The caller should ensure thread safety. + /** + * Updates the selectedException if + *

    + * a) selectedException is null + *

    + * b) ex is a non-socketTimeoutException and selectedException is a socketTimeoutException + *

    + * If there are multiple exceptions, that are not related to socketTimeout + * the first non-socketTimeout exception is picked. + * If all exceptions are related to socketTimeout, the first exception is picked. + * Note: This method is not thread safe. The caller should ensure thread safety. + * @param ex the IOException + * @param traceId the traceId of the thread + */ public void updateSelectedException(IOException ex, String traceId) { boolean updatedException = false; @@ -2898,7 +2905,8 @@ else if((!(ex instanceof SocketTimeoutException)) && (selectedException instance } /** - * Used for tracing + * Used fof tracing + * @return traceID string */ public String toString() { @@ -2994,6 +3002,7 @@ public void run() /** * Used for tracing + * @return traceID string */ public String toString() { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java index a9caf4827..f94f2d16d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -82,6 +82,7 @@ public interface ISQLServerBulkRecord * '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; @@ -89,7 +90,7 @@ public interface ISQLServerBulkRecord * 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 obtaining the data. + * @throws SQLServerException If there are any errors in advancing to the next row. */ public boolean next() throws SQLServerException; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java index c208b0561..04fc3f00a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -20,10 +20,43 @@ package com.microsoft.sqlserver.jdbc; import java.sql.*; + +/** + * + * This interface is implemented by SQLServerCallableStatement Class. + * + */ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, ISQLServerPreparedStatement { + /** + * Sets parameter parameterName to DateTimeOffset x + * @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 + */ public void setDateTimeOffset(String parameterName, microsoft.sql.DateTimeOffset x) throws SQLException; + + /** + * 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 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; + + /** + * Gets the DateTimeOffset value of parameter with name parameterName + * @param parameterName the name of the parameter + * @return DateTimeOffset value + * @throws SQLException 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 SQLException; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java index 37cc3b4b2..ef7bd215f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -33,18 +33,50 @@ public interface ISQLServerCallableStatement42 extends ISQLServerCallableStateme 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 2531287ae..29c9d33a7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -23,14 +23,20 @@ /** * -* ALL THE non JDBC public methods of SQLServerConnection in should be defined here. +* 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; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index a27705bcc..8c35f5fa3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -28,6 +28,11 @@ 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); /** @@ -52,7 +57,6 @@ public interface ISQLServerDataRecord * 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 obtaining the data. */ 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 80d991b9f..e921948ef 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -22,63 +22,334 @@ /** -* This datasource lists properties specific for the SQLServerConnection class. +* A factory to create connections to the data source represented by this object. This interface was added in SQL Server JDBC Driver 3.0. */ public interface ISQLServerDataSource extends CommonDataSource { + /** + * Sets the application intent. + * @param applicationIntent A String that contains the application intent. + */ public void setApplicationIntent(String applicationIntent); + + /** + * Returns the application intent. + * @return A String that contains the application intent. + */ public String getApplicationIntent(); + + /** + * Sets the application name. + * @param applicationName A String that contains the name of the application. + */ public void setApplicationName(String applicationName); + + /** + * Returns the application name. + * @return A String that contains the application name, or "Microsoft JDBC Driver for SQL Server" if no value is set. + */ public String getApplicationName(); + + /** + * Sets the database name to connect to. + * @param databaseName A String that contains the database name. + */ public void setDatabaseName(String databaseName); + + /** + * Returns the database name. + * @return A String that contains the database name or null if no value is set. + */ public String getDatabaseName(); + + /** + * Sets the SQL Server instance name. + * @param instanceName A String that contains the instance name. + */ public void setInstanceName(String instanceName); + + /** + * Returns the SQL Server instance name. + * @return A String that contains the instance name, or null if no value is set. + */ public String getInstanceName(); + + /** + * Sets a Boolean value that indicates if the integratedSecurity property is enabled. + * @param enable true if integratedSecurity is enabled. Otherwise, false. + */ public void setIntegratedSecurity(boolean enable); + + /** + * Sets a Boolean value that indicates if the lastUpdateCount property is enabled. + * @param lastUpdateCount true if lastUpdateCount is enabled. Otherwise, false. + */ public void setLastUpdateCount(boolean lastUpdateCount); + + /** + * Returns a Boolean value that indicates if the lastUpdateCount property is enabled. + * @return true if lastUpdateCount is enabled. Otherwise, false. + */ public boolean getLastUpdateCount(); + + /** + * Sets a Boolean value that indicates if the encrypt property is enabled. + * @param encrypt true if the Secure Sockets Layer (SSL) encryption is enabled between the client and the SQL Server. Otherwise, false. + */ public void setEncrypt(boolean encrypt); + + /** + * Returns a Boolean value that indicates if the encrypt property is enabled. + * @return true if encrypt is enabled. Otherwise, false. + */ public boolean getEncrypt(); + + /** + * 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 using SSL. Otherwise, false. + */ public void setTrustServerCertificate(boolean e); + + /** + * Returns a Boolean value that indicates if the trustServerCertificate property is enabled. + * @return true if trustServerCertificate is enabled. Otherwise, false. + */ public boolean getTrustServerCertificate(); + + /** + * Sets the path (including file name) to the certificate trustStore file. + * @param st A String that contains the path (including file name) to the certificate trustStore file. + */ public void setTrustStore(String st); + + /** + * 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. + */ public String getTrustStore(); + + /** + * Sets the password that is used to check the integrity of the trustStore data. + * @param p A String that contains the password that is used to check the integrity of the trustStore data. + */ public void setTrustStorePassword(String p); + + /** + * Sets the host name to be used in validating the SQL Server Secure Sockets Layer (SSL) certificate. + * @param host A String that contains the host name. + */ public void setHostNameInCertificate(String host); + + /** + * Returns the host name used in validating the SQL Server Secure Sockets Layer (SSL) certificate. + * @return A String that contains the host name, or null if no value is set. + */ public String getHostNameInCertificate(); + + /** + * Sets an int value that indicates the number of milliseconds to wait before the database reports a lock time out. + * @param lockTimeout An int value that contains the number of milliseconds to wait. + */ public void setLockTimeout(int lockTimeout); + + /** + * Returns an int value that indicates the number of milliseconds that the database will wait before reporting a lock time out. + * @return An int value that contains the number of milliseconds that the database will wait. + */ public int getLockTimeout(); + + /** + * Sets the password that will be used to connect to SQL Server. + * @param password A String that contains the password. + */ public void setPassword(String password); + + /** + * Sets the port number to be used to communicate with SQL Server. + * @param portNumber An int value that contains the port number. + */ public void setPortNumber(int portNumber); + + /** + * Returns the current port number that is used to communicate with SQL Server. + * @return An int value that contains the current port number. + */ public int getPortNumber(); + + /** + * Sets the default cursor type that is used for all result sets that are created by using this SQLServerDataSource object. + * @param selectMethod A String value that contains the default cursor type. + */ public void setSelectMethod(String selectMethod); + + /** + * Returns the default cursor type used for all result sets that are created by using this SQLServerDataSource object. + * @return A String value that contains the default cursor type. + */ public String getSelectMethod(); + + /** + * Sets the response buffering mode for connections created by using this SQLServerDataSource object. + * @param respo 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); + + /** + * Returns the response buffering mode for this SQLServerDataSource object. + * @return A String that contains a lower-case full or adaptive. + */ public String getResponseBuffering(); + + /** + * Modifies the setting of the sendTimeAsDatetime connection property. + * @param sendTimeAsDatetime A Boolean value. When true, causes java.sql.Time values to be sent to the server as SQL Server datetime types. + * When false, causes java.sql.Time values to be sent to the server as SQL Server time types. + */ public void setSendTimeAsDatetime(boolean sendTimeAsDatetime); + + /** + * This method was added in SQL Server JDBC Driver 3.0. Returns the setting of the sendTimeAsDatetime connection property. + * @return true if java.sql.Time values will be sent to the server as a SQL Server datetime type. false if java.sql.Time values will be sent + * to the server as a SQL Server time type. + */ public boolean getSendTimeAsDatetime(); + + /** + * Sets a boolean value that indicates if sending string parameters to the server in UNICODE format is enabled. + * @param sendStringParametersAsUnicode true if string parameters are sent to the server in UNICODE format. Otherwise, false. + */ public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode); + + /** + * Returns a boolean value that indicates if sending string parameters to the server in UNICODE format is enabled. + * @return true if string parameters are sent to the server in UNICODE format. Otherwise, false. + */ public boolean getSendStringParametersAsUnicode(); + + /** + * Sets the name of the computer that is running SQL Server. + * @param serverName A String that contains the server name. + */ public void setServerName(String serverName); + + /** + * Returns the name of the SQL Server instance. + * @return A String that contains the server name or null if no value is set. + */ public String getServerName(); + + /** + * Sets the name of the failover server that is used in a database mirroring configuration. + * @param serverName A String that contains the failover server name. + */ public void setFailoverPartner(String serverName); + + /** + * Returns the name of the failover server that is used in a database mirroring configuration. + * @return A String that contains the name of the failover partner, or null if none is set. + */ public String getFailoverPartner(); + + /** + * Sets the value of the multiSubnetFailover connection property. + * @param multiSubnetFailover The new value of the multiSubnetFailover connection property. + */ public void setMultiSubnetFailover(boolean multiSubnetFailover); - public boolean getMultiSubnetFailover(); + + /** + * Returns the value of the multiSubnetFailover connection property. + * @return Returns true or false, depending on the current setting of the connection property. + */ + public boolean getMultiSubnetFailover(); + + /** + * Sets the user name that is used to connect the data source. + * @param user A String that contains the user name. + */ public void setUser(String user); + + /** + * Returns the user name that is used to connect the data source. + * @return A String that contains the user name. + */ public String getUser(); + + /** + * Sets the name of the client computer name that is used to connect to the data source. + * @param workstationID A String that contains the client computer name. + */ public void setWorkstationID(String workstationID); + + /** + * Returns the name of the client computer name that is used to connect to the data source. + * @return A String that contains the client computer name. + */ public String getWorkstationID(); + + /** + * Sets a Boolean value that indicates if converting SQL states to XOPEN compliant states is enabled. + * @param xopenStates true if converting SQL states to XOPEN compliant states is enabled. Otherwise, false. + */ public void setXopenStates(boolean xopenStates); + + /** + * Returns a boolean value that indicates if converting SQL states to XOPEN compliant states is enabled. + * @return true if converting SQL states to XOPEN compliant states is enabled. Otherwise, false. + */ public boolean getXopenStates(); + + /** + * Sets the URL that is used to connect to the data source. + * @param url A String that contains the URL. + */ public void setURL(String url); + + /** + * Returns the URL that is used to connect to the data source. + * @return A String that contains the URL. + */ public String getURL(); + + /** + * Sets the description of the data source. + * @param description A String that contains the description. + */ public void setDescription(String description); + + /** + * Returns a description of the data source. + * @return A String that contains the data source description or null if no value is set. + */ public String getDescription(); + + /** + * Sets the current network packet size used to communicate with SQL Server, specified in bytes. + * @param packetSize An int value containing the network packet size. + */ public void setPacketSize(int packetSize); + + /** + * Returns the current network packet size used to communicate with SQL Server, specified in bytes. + * @return An int value containing the current network packet size. + */ public int getPacketSize(); + + /** + * Indicates the kind of integrated security you want your application to use. + * @param authenticationScheme Values are "JavaKerberos" and the default "NativeAuthentication". + */ public void setAuthenticationScheme(String authenticationScheme); + + /** + * Sets the server spn + * @param serverSpn A String that contains the server spn + */ public void setServerSpn(String serverSpn); + + /** + * Returns the server spn + * @return A String that contains the server spn + */ public String getServerSpn(); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java index 4571801b6..1712117d9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -23,6 +23,15 @@ public interface ISQLServerPreparedStatement extends java.sql.PreparedStatement, ISQLServerStatement { + /** + * 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 + * @throws SQLException 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; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java index b680d0fbe..55f448304 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -31,7 +31,45 @@ public interface ISQLServerPreparedStatement42 extends ISQLServerPreparedStateme 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 8450c2d1c..b53e2f311 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -35,9 +35,36 @@ 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 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 when an error occurs + */ public microsoft.sql.DateTimeOffset getDateTimeOffset(int columnIndex) throws SQLException; - public microsoft.sql.DateTimeOffset getDateTimeOffset(String columnName) throws SQLException; + + /** + * Retrieves the value of the column specified as a microsoft.sql.DateTimeOffset object, given a column name. + * @param columnName The name of a column. + * @return A DateTimeOffset Class object. + * @throws SQLException when an error occurs + */ + public microsoft.sql.DateTimeOffset getDateTimeOffset(String columnName) throws SQLException; + + /** + * 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. + * @throws SQLException when an error occurs + */ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x) throws SQLException; + + /** + * 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. + * @throws SQLException when an error occurs + */ public void updateDateTimeOffset(String columnName, microsoft.sql.DateTimeOffset x) throws SQLException; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java index 320bb0170..87bb7e088 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -31,10 +31,45 @@ public interface ISQLServerResultSet42 extends ISQLServerResultSet{ 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/ISQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java index 0bad183ae..3d102061d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -22,6 +22,25 @@ 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; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java index 06ee22124..cf4af0233 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java index 7cf0999c0..0050c6a61 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyStoreProviderCommon.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java index f7d0c915f..032b6db78 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -25,6 +25,11 @@ import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; import com.microsoft.windowsazure.core.pipeline.filter.ServiceRequestContext; +/** + * + * An implementation of ServiceClientCredentials that supports automatic bearer token refresh. + * + */ class KeyVaultCredential extends KeyVaultCredentials{ //this is the only supported access token type @@ -40,6 +45,12 @@ class KeyVaultCredential extends KeyVaultCredentials{ this.authenticationCallback = authenticationCallback; } + /** + * Authenticates the service request + * @param request the ServiceRequestContext + * @param challenge used to get the accessToken + * @return BasicHeader + */ @Override public Header doAuthenticate(ServiceRequestContext request, Map challenge) { assert null != challenge; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java index bdc1cdd25..9757ebe77 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -81,11 +81,13 @@ final static boolean isNull(TDSReader tdsReader) throws SQLServerException } /** - * Create a new input stream. - * @param tdsReader TDS reader pointing at the start of the PLP data - * @param discardValue - * @param dtv - */ + * Create a new input stream. + * @param tdsReader TDS reader pointing at the start of the PLP data + * @param discardValue boolean to represent if base input stream is adaptive and is streaming + * @param dtv DTV implementation for values set from the TDS response stream. + * @return PLPInputStream that is created + * @throws SQLServerException when an error occurs + */ final static PLPInputStream makeTempStream(TDSReader tdsReader, boolean discardValue, ServerDTVImpl dtv) throws SQLServerException { return makeStream(tdsReader, discardValue, discardValue, dtv); @@ -403,8 +405,10 @@ public void mark(int readLimit) setReadLimit(readLimit); } } + /** * Closes the stream releasing all resources held. + * @exception IOException if an I/O error occurs. */ public void close() throws IOException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java index e92ee9888..62c3de7a6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ParameterUtils.java b/src/main/java/com/microsoft/sqlserver/jdbc/ParameterUtils.java index 03eaaeae1..bfeeeb711 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ParameterUtils.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ParameterUtils.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java index 623ca9d88..f0dd4749f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java index 38ad09b05..76f1e79a9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java index b48fdc22d..2ef640f2b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java index d8b213aea..07a4bf92c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256EncryptionKey.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java index 94124ebd8..5fc02ca5f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java index 1698ec437..f405f9818 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -107,7 +107,7 @@ private synchronized static int nextInstanceID() /** * 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. @@ -154,11 +154,6 @@ private final void checkClosed() throws SQLServerException } } - /** - * Return an input stream to read data from this BLOB - * @throws SQLException - * @return the input stream to that contains the BLOB data - */ public InputStream getBinaryStream() throws SQLException { checkClosed(); @@ -232,7 +227,7 @@ public byte[] getBytes(long pos, int length) throws SQLException /** * Return the length of the BLOB - * @throws SQLException + * @throws SQLException when an error occurs * @return the data length */ public long length() throws SQLException @@ -321,7 +316,7 @@ public long position(byte[] bPattern, long start) throws SQLException /** * Truncate a BLOB * @param len the new length for the BLOB - * @throws SQLException + * @throws SQLException when an error occurs */ public void truncate(long len) throws SQLException { @@ -460,12 +455,14 @@ public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLExcep } -// SQLServerBlobOutputStream is a simple java.io.OutputStream interface implementing class that -// forwards all calls to SQLServerBlob.setBytes. This class is returned to caller by -// SQLServerBlob class when setBinaryStream is called. -// -// SQLServerBlobOutputStream starts writing at postion startPos and continues to write -// in a forward only manner. Reset/mark are not supported. +/** + * SQLServerBlobOutputStream is a simple java.io.OutputStream interface implementing class that + * forwards all calls to SQLServerBlob.setBytes. This class is returned to caller by + * SQLServerBlob class when setBinaryStream is called. + *

    + * SQLServerBlobOutputStream starts writing at postion startPos and continues to write + * in a forward only manner. Reset/mark are not supported. + */ final class SQLServerBlobOutputStream extends java.io.OutputStream { private SQLServerBlob parentBlob = null; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java index 8837e4255..5b04412b8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -196,11 +196,32 @@ public SQLServerBulkCSVFileRecord(String fileToParse, boolean firstLineIsColumnN 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); @@ -215,7 +236,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int * @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 + * @throws SQLServerException when an error occurs */ void addColumnMetadataInternal(int positionInFile, String name, int jdbcType, int precision, int scale, DateTimeFormatter dateTimeFormatter) throws SQLServerException { @@ -299,7 +320,7 @@ public void setTimestampWithTimezoneFormat(String dateTimeFormat) /** * Set the format for reading in dates from the file. - * @param dateTimeFormat format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE + * @param dateTimeFormatter format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE */ public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) { @@ -314,7 +335,7 @@ public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) /** * Set the format for reading in dates from the file. - * @param dateTimeFormat format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE + * @param timeFormat format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE */ public void setTimeWithTimezoneFormat(String timeFormat) { @@ -328,7 +349,7 @@ public void setTimeWithTimezoneFormat(String timeFormat) /** * Set the format for reading in dates from the file. - * @param dateTimeFormat format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE + * @param dateTimeFormatter format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE */ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) { @@ -342,6 +363,7 @@ public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter) /** * Releases any resources associated with the file reader. + * @throws SQLServerException when an error occurs */ public void close() throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index aaa1af0d1..d9f6b49d7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -600,7 +600,7 @@ public void writeToServer(RowSet sourceData) throws SQLServerException writeResultSet(sourceData, true); } - /* + /** * Copies all rows in the supplied ResultSet to a destination table specified by the destinationTableName property of the SQLServerBulkCopy object. * * @param sourceData ResultSet to read data rows from. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java index d965a0854..aa961ec8d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy42Helper.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java index 9da3582e0..3bce3908b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -293,11 +293,27 @@ public void setFireTriggers(boolean fireTriggers) this.fireTriggers = fireTriggers; } + /** + * Indicates if allowEncryptedValueModifications option is enabled or not + * @return True if allowEncryptedValueModification is set to true; false otherwise. + */ public boolean isAllowEncryptedValueModifications() { return allowEncryptedValueModifications; } + /** + * Sets whether the driver would send data as is or would decrypt the data and encrypt it again before sending to SQL Server + *

    + * Use caution when specifying allowEncryptedValueModifications as this may lead to corrupting the database + * because the driver does not check if the data is indeed encrypted, or if it is correctly encrypted using the + * same encryption type, algorithm and key as the target column. + * + * @param allowEncryptedValueModifications enables bulk copying of encrypted data between tables or databases, without + * decrypting the data. Typically, an application would select data from encrypted columns from one table without + * decrypting the data (the app would connect to the database with the column encryption setting keyword set to disabled) + * and then would use this option to bulk insert the data, which is still encrypted. + */ public void setAllowEncryptedValueModifications(boolean allowEncryptedValueModifications) { this.allowEncryptedValueModifications = allowEncryptedValueModifications; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index 14a7ecea6..98ce85512 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -35,7 +35,7 @@ * CallableStatement allows the caller to specify the procedure name to call along with input parameter * value and output parameter types. Callable statement also allows the return of a return status with * the ? = call( ?, ..) JDBC syntax -*

  • +*

    * 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. */ @@ -851,6 +851,12 @@ public Timestamp getTimestamp(String name, Calendar cal) throws SQLServerExcepti 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 + */ public Timestamp getDateTime(int index) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -861,6 +867,12 @@ 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); @@ -870,6 +882,14 @@ public Timestamp getDateTime(String sCol) 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. + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -880,6 +900,14 @@ public Timestamp getDateTime(int index, Calendar cal) 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. + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -890,6 +918,12 @@ public Timestamp getDateTime(String name, Calendar cal) throws SQLServerExceptio 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 + */ public Timestamp getSmallDateTime(int index) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -900,6 +934,12 @@ 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); @@ -909,6 +949,13 @@ public Timestamp getSmallDateTime(String sCol) 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 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -919,6 +966,13 @@ public Timestamp getSmallDateTime(int index, Calendar cal) throws SQLServerExcep 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 + */ public Timestamp getSmallDateTime(String name, Calendar cal) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -979,6 +1033,31 @@ 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); @@ -988,6 +1067,30 @@ public final java.io.InputStream getAsciiStream(int paramIndex) throws SQLServer 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); @@ -1015,6 +1118,12 @@ public BigDecimal getBigDecimal(String sCol) throws SQLServerException 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); @@ -1024,6 +1133,12 @@ public BigDecimal getMoney(int index) throws SQLServerException 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); @@ -1033,6 +1148,12 @@ public BigDecimal getMoney(String sCol) throws SQLServerException 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); @@ -1042,6 +1163,12 @@ public BigDecimal getSmallMoney(int index) throws SQLServerException 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); @@ -1051,6 +1178,29 @@ public BigDecimal getSmallMoney(String sCol) throws SQLServerException 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); @@ -1060,6 +1210,29 @@ public final java.io.InputStream getBinaryStream(int paramIndex) throws SQLServe 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); @@ -1219,7 +1392,7 @@ public NClob getNClob(String parameterName) throws SQLException /** * Find a column's index given its name. * @param columnName the name - * @throws SQLServerException + * @throws SQLServerException when an error occurs * @return the index */ /*L3*/ private int findColumn(String columnName) throws SQLServerException @@ -1411,6 +1584,22 @@ public void setTimestamp(String sCol, java.sql.Timestamp x, Calendar c) throws S 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1429,6 +1618,27 @@ public void setTime(String sCol, java.sql.Time x, Calendar c) throws SQLServerEx 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1447,6 +1657,27 @@ public void setDate(String sCol, java.sql.Date x, Calendar c) throws SQLServerEx 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1576,6 +1807,20 @@ public final void setNString(String parameterName, String value) throws SQLExcep 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 + */ public final void setNString(String parameterName, String value, boolean forceEncrypt) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); @@ -1632,6 +1877,40 @@ public void setObject(String sCol, Object o, int n, int m) throws SQLServerExcep 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1658,6 +1937,37 @@ public void setObject(String sCol, Object o, int n, int m, boolean forceEncrypt) 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, int targetSqlType, Integer precision, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1787,6 +2097,20 @@ public void setTimestamp(String sCol, java.sql.Timestamp t) throws SQLServerExce 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, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1796,6 +2120,22 @@ public void setTimestamp(String sCol, java.sql.Timestamp t, int scale) throws SQ 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, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1814,6 +2154,13 @@ public void setDateTimeOffset(String sCol, microsoft.sql.DateTimeOffset t) throw 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1823,6 +2170,15 @@ public void setDateTimeOffset(String sCol, microsoft.sql.DateTimeOffset t, int s 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, int scale, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1850,6 +2206,19 @@ public void setTime(String sCol, java.sql.Time t) throws SQLServerException 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, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1859,6 +2228,21 @@ public void setTime(String sCol, java.sql.Time t, int scale) throws SQLServerExc 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, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1867,6 +2251,18 @@ public void setTime(String sCol, java.sql.Time t, int scale, boolean forceEncryp setValue(findColumn(sCol), JDBCType.TIME, t, 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1876,6 +2272,19 @@ public void setDateTime(String sCol, java.sql.Timestamp x) throws SQLServerExce 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1885,6 +2294,17 @@ public void setDateTime(String sCol, java.sql.Timestamp x, boolean 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1894,6 +2314,19 @@ public void setSmallDateTime(String sCol, java.sql.Timestamp x) throws SQLServe 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1903,6 +2336,17 @@ public void setSmallDateTime(String sCol, java.sql.Timestamp x, boolean forceEnc 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, String guid) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1912,6 +2356,19 @@ public void setUniqueIdentifier(String sCol, String guid) throws SQLServerExcept 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, String guid, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1930,6 +2387,21 @@ public void setBytes(String sCol, byte[] b) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1948,6 +2420,19 @@ public void setByte(String sCol, byte b) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1966,6 +2451,22 @@ public void setString(String sCol, String s) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1975,6 +2476,16 @@ public void setString(String sCol, String s, boolean forceEncrypt) throws SQLSer 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1984,6 +2495,18 @@ public void setMoney(String sCol, BigDecimal bd) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1993,6 +2516,16 @@ public void setMoney(String sCol, BigDecimal bd, boolean forceEncrypt) throws SQ 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2002,6 +2535,18 @@ public void setSmallMoney(String sCol, BigDecimal bd) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2020,6 +2565,20 @@ public void setBigDecimal(String sCol, BigDecimal bd) throws SQLServerException 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, int precision, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2029,6 +2588,22 @@ public void setBigDecimal(String sCol, BigDecimal bd, int precision, int scale) 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, int precision, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2047,6 +2622,19 @@ public void setDouble(String sCol, double d) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2065,6 +2653,19 @@ public void setFloat(String sCol, float f) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2083,6 +2684,19 @@ public void setInt(String sCol, int i) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2101,6 +2715,19 @@ public void setLong(String sCol, long l) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2119,6 +2746,19 @@ public void setShort(String sCol, short s) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2137,6 +2777,19 @@ public void setBoolean(String sCol, boolean b) throws SQLServerException 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, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2172,6 +2825,13 @@ public void setURL(String sCol, URL u) throws SQLServerException 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, String tvpName, SQLServerDataTable tvpDataTable) throws SQLServerException { tvpName = getTVPNameIfNull(findColumn(sCol), tvpName); @@ -2182,6 +2842,13 @@ public final void setStructured(String sCol, String tvpName, SQLServerDataTable 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, String tvpName, ResultSet tvpResultSet) throws SQLServerException { tvpName = getTVPNameIfNull(findColumn(sCol), tvpName); @@ -2192,6 +2859,14 @@ public final void setStructured(String sCol, String tvpName, ResultSet tvpResult 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, String tvpName, ISQLServerDataRecord tvpDataRecord) throws SQLServerException { tvpName = getTVPNameIfNull(findColumn(sCol), tvpName); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java index 26e908420..a5892d6d2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java index dae0a2944..2b84098ff 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -133,6 +133,8 @@ private String getDisplayClassName() * 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. + * + * @throws SQLException when an error occurs */ public void free() throws SQLException { @@ -178,7 +180,7 @@ private final void checkClosed() throws SQLServerException /** * Materialize the CLOB as an ASCII stream. - * @throws SQLException + * @throws SQLException when an error occurs * @return the data as an input stream */ public InputStream getAsciiStream() throws SQLException @@ -210,6 +212,13 @@ public Reader getCharacterStream() throws SQLException return getterStream; } + /** + * Returns the Clob data as a java.io.Reader object or as a stream of characters with the specified position and length. + * @param pos A long that indicates the offset to the first character of the partial value to be retrieved. + * @param length A long that indicates the length in characters of the partial value to be retrieved. + * @return A Reader object that contains the Clob data. + * @throws SQLException when an error occurs. + */ public Reader getCharacterStream(long pos, long length) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); @@ -263,7 +272,7 @@ public String getSubString(long pos, int length) throws SQLException /** * Retrieves the number of characters in the CLOB value designated by this Clob object. - * @throws SQLException + * @throws SQLException when an error occurs * @return length of the CLOB in characters */ public long length() throws SQLException @@ -337,7 +346,7 @@ public long position(String searchstr, long start) throws SQLException /** * Truncates the CLOB value that this Clob designates to have a length of len characters. * @param len the length, in characters, to which the CLOB value should be truncated - * @throws SQLException + * @throws SQLException when an error occurs */ public void truncate(long len) throws SQLException { @@ -358,7 +367,7 @@ public void truncate(long len) throws SQLException * Retrieves a stream to be used to write Ascii characters to the CLOB value that * this Clob object represents, starting at position pos. * @param pos the position at which to start writing to this CLOB object - * @throws SQLException + * @throws SQLException when an error occurs * @return the stream to which ASCII encoded characters can be written */ public java.io.OutputStream setAsciiStream(long pos) throws SQLException @@ -379,7 +388,7 @@ public java.io.OutputStream setAsciiStream(long pos) throws SQLException * Retrieves a stream to be used to write a stream of Unicode characters to * the CLOB value that this Clob object represents, at position pos. * @param pos the position at which to start writing to the CLOB value - * @throws SQLException + * @throws SQLException when an error occurs * @return a stream to which Unicode encoded characters can be written */ public java.io.Writer setCharacterStream(long pos) throws SQLException @@ -401,7 +410,7 @@ public java.io.Writer setCharacterStream(long pos) throws SQLException * at the position pos. * @param pos the position at which to start writing to the CLOB * @param s the string to be written to the CLOB value that this Clob designates - * @throws SQLException + * @throws SQLException when an error occurs * @return the number of characters written */ public int setString(long pos, String s) throws SQLException diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index e3be179d3..6489bf9d0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -87,8 +87,8 @@ public String getName() * to authenticate to Azure Key Vault. * * @param authenticationCallback - Callback function used for authenticating to AAD. - * @param executorService - * @throws SQLServerException + * @param executorService - The ExecutorService used to create the keyVaultClient + * @throws SQLServerException when an error occurs */ public SQLServerColumnEncryptionAzureKeyVaultProvider(SQLServerKeyVaultAuthenticationCallback authenticationCallback, ExecutorService executorService) throws SQLServerException{ if(null == authenticationCallback){ @@ -555,7 +555,7 @@ private boolean AzureKeyVaultVerifySignature(byte[] dataToVerify, byte[] signatu * * @param masterKeyPath - Azure Key Vault Key path * @return Key size in bytes - * @throws SQLServerException + * @throws SQLServerException when an error occurs */ private int getAKVKeySize(String masterKeyPath) throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index f68388818..438623f3f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -42,7 +42,10 @@ import com.microsoft.sqlserver.jdbc.AuthenticationJNI; - +/** + * The implementation of the key store provider for the Windows Certificate Store. This class enables using keys stored in the Windows Certificate Store as column master keys. + * + */ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQLServerColumnEncryptionKeyStoreProvider { static final private java.util.logging.Logger windowsCertificateStoreLogger = diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index c94ea98bf..5818612d5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -47,6 +47,11 @@ import static java.nio.charset.StandardCharsets.UTF_16LE; +/** + * + * The implementation of the key store provider for Java Key Store. This class enables using certificates stored in the Java keystore as column master keys. + * + */ public class SQLServerColumnEncryptionJavaKeyStoreProvider extends SQLServerColumnEncryptionKeyStoreProvider { String name = "MSSQL_JAVA_KEYSTORE"; @@ -66,6 +71,12 @@ public String getName() return this.name; } + /** + * Key store provider for the Java Key Store. + * @param keyStoreLocation specifies the location of the keystore + * @param keyStoreSecret specifies the secret used for keystore + * @throws SQLServerException when an error occurs + */ public SQLServerColumnEncryptionJavaKeyStoreProvider(String keyStoreLocation, char[] keyStoreSecret) throws SQLServerException { javaKeyStoreLogger.entering(SQLServerColumnEncryptionJavaKeyStoreProvider.class.getName(), "SQLServerColumnEncryptionJavaKeyStoreProvider"); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java index aa1ed747b..094b93132 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -19,11 +19,44 @@ package com.microsoft.sqlserver.jdbc; +/** + * + * Extend this class to implement a custom key store provider. + * + */ public abstract class SQLServerColumnEncryptionKeyStoreProvider { + /** + * Sets the name of this key store provider. + * @param name value to be set for the key store provider. + */ public abstract void setName(String name); + + /** + * Retrieves the name of this key store provider. + * @return the name of this key store provider. + */ public abstract String getName(); + + /** + * Base class method for decrypting the specified encrypted value of a column encryption key. + * The encrypted value is expected to be encrypted using the column master key with the specified key path and using the specified algorithm. + * @param masterKeyPath The column master key path. + * @param encryptionAlgorithm the specific encryption algorithm. + * @param encryptedColumnEncryptionKey the encrypted column encryption key + * @return the decrypted value of column encryption key. + * @throws SQLServerException when an error occurs while decrypting the CEK + */ public abstract byte [] decryptColumnEncryptionKey(String masterKeyPath,String encryptionAlgorithm,byte [] encryptedColumnEncryptionKey) throws SQLServerException; + + /** + * Base class method for encrypting a column encryption key using the column master key with the specified key path and using the specified algorithm. + * @param masterKeyPath The column master key path. + * @param encryptionAlgorithm the specific encryption algorithm. + * @param columnEncryptionKey column encryption key to be encrypted. + * @return the encrypted column encryption key. + * @throws SQLServerException when an error occurs while encrypting the CEK + */ public abstract byte [] encryptColumnEncryptionKey(String masterKeyPath,String encryptionAlgorithm,byte [] columnEncryptionKey) throws SQLServerException; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 2c855c958..d7a9b4e5b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -38,23 +38,22 @@ * SQLServerConnection implements a JDBC connection to SQL Server. * SQLServerConnections support JDBC connection pooling and may be either physical JDBC connections * or logical JDBC connections. - *

  • + *

    * SQLServerConnection manages transaction control for all statements that were created from it. * SQLServerConnection may participate in XA distributed transactions managed via an XAResource adapter. - *

  • + *

    * SQLServerConnection instantiates a new TDSChannel object for use by itself and all statement objects that * are created under this connection. SQLServerConnection is thread safe. - *

  • + *

    * SQLServerConnection manages a pool of prepared statement handles. Prepared statements are prepared * once and typically executed many times with different data values for their parameters. * Prepared statements are also maintained across logical (pooled) connection closes. - *

  • + *

    * SQLServerConnection is not thread safe, however multiple statements created from a single * connection can be processing simultaneously in concurrent threads. - *

  • - *
  • + *

    * This class's public functions need to be kept identical to the SQLServerConnectionPoolProxy'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. */ @@ -223,6 +222,10 @@ final ApplicationIntent getApplicationIntent() private boolean sendTimeAsDatetime = SQLServerDriverBooleanProperty.SEND_TIME_AS_DATETIME.getDefaultValue(); + /** + * Checks the sendTimeAsDatetime property. + * @return boolean value of sendTimeAsDatetime + */ public synchronized final boolean getSendTimeAsDatetime() { return !isKatmaiOrLater() || sendTimeAsDatetime; @@ -289,6 +292,11 @@ boolean getServerSupportsColumnEncryption() { Map systemColumnEncryptionKeyStoreProvider = new HashMap(); + /** + * Registers key store providers in the globalCustomColumnEncryptionKeyStoreProviders. + * @param clientKeyStoreProviders a map containing the store providers information. + * @throws SQLServerException when an error occurs + */ public static synchronized void registerColumnEncryptionKeyStoreProviders( Map clientKeyStoreProviders) throws SQLServerException { @@ -389,6 +397,10 @@ synchronized SQLServerColumnEncryptionKeyStoreProvider getSystemColumnEncryption private String trustedServerNameAE = null; private static Map> columnEncryptionTrustedMasterKeyPaths=new HashMap>(); + /** + * Sets Trusted Master Key Paths in the columnEncryptionTrustedMasterKeyPaths. + * @param trustedKeyPaths all master key paths that are trusted + */ public static synchronized void setColumnEncryptionTrustedMasterKeyPaths(Map> trustedKeyPaths) { loggerExternal.entering(SQLServerConnection.class.getName(), "setColumnEncryptionTrustedMasterKeyPaths", "Setting Trusted Master Key Paths"); @@ -403,6 +415,11 @@ public static synchronized void setColumnEncryptionTrustedMasterKeyPaths(Map trustedKeyPaths) { loggerExternal.entering(SQLServerConnection.class.getName(), "updateColumnEncryptionTrustedMasterKeyPaths", "Updating Trusted Master Key Paths"); @@ -413,6 +430,10 @@ public static synchronized void updateColumnEncryptionTrustedMasterKeyPaths(Stri loggerExternal.exiting(SQLServerConnection.class.getName(), "updateColumnEncryptionTrustedMasterKeyPaths", "Number of Trusted Master Key Paths: " + columnEncryptionTrustedMasterKeyPaths.size()); } + /** + * Removes the trusted Master key Path from the columnEncryptionTrustedMasterKeyPaths. + * @param server String server name + */ public static synchronized void removeColumnEncryptionTrustedMasterKeyPaths(String server) { loggerExternal.entering(SQLServerConnection.class.getName(), "removeColumnEncryptionTrustedMasterKeyPaths", "Removing Trusted Master Key Paths"); @@ -423,6 +444,10 @@ public static synchronized void removeColumnEncryptionTrustedMasterKeyPaths(Stri loggerExternal.exiting(SQLServerConnection.class.getName(), "removeColumnEncryptionTrustedMasterKeyPaths", "Number of Trusted Master Key Paths: " + columnEncryptionTrustedMasterKeyPaths.size()); } + /** + * Retrieves the Trusted Master Key Paths. + * @return columnEncryptionTrustedMasterKeyPaths. + */ public static synchronized Map> getColumnEncryptionTrustedMasterKeyPaths() { loggerExternal.entering(SQLServerConnection.class.getName(), "getColumnEncryptionTrustedMasterKeyPaths", "Getting Trusted Master Key Paths"); @@ -601,6 +626,10 @@ int getServerMajorVersion(){ private UUID clientConnectionId = null; + /** + * Retrieves the clientConnectionID. + * @throws SQLServerException when an error occurs + */ public UUID getClientConnectionId() throws SQLServerException { // If the connection is closed, we do not allow external application to get @@ -4426,9 +4455,9 @@ private void checkValidHoldability(int holdability) throws SQLServerException * to check the holdability of ResultSets that would be created, and/or * ResultSet.getHoldability to check the holdability of an existing ResultSet. */ - private void checkMatchesCurrentHoldability(int statementHoldability) throws SQLServerException + private void checkMatchesCurrentHoldability(int resultSetHoldability) throws SQLServerException { - if (statementHoldability != this.holdability) + if (resultSetHoldability != this.holdability) { SQLServerException.makeFromDriverError( this, this, @@ -4437,44 +4466,79 @@ private void checkMatchesCurrentHoldability(int statementHoldability) throws SQL } } - public Statement createStatement(int nType, int nConcur, int statementHoldability) throws SQLServerException + public Statement createStatement(int nType, int nConcur, int resultSetHoldability) throws SQLServerException { - loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability}); - Statement st = createStatement(nType, nConcur, statementHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting); + loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability}); + Statement st = createStatement(nType, nConcur, resultSetHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting); loggerExternal.exiting(getClassNameLogging(), "createStatement", st); return st; } - public Statement createStatement(int nType, int nConcur, int statementHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException + public Statement createStatement(int nType, int nConcur, int resultSetHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException { - loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability, stmtColEncSetting}); + loggerExternal.entering(getClassNameLogging(), "createStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability, stmtColEncSetting}); checkClosed(); - checkValidHoldability(statementHoldability); - checkMatchesCurrentHoldability(statementHoldability); + checkValidHoldability(resultSetHoldability); + checkMatchesCurrentHoldability(resultSetHoldability); Statement st = new SQLServerStatement(this, nType, nConcur, stmtColEncSetting); loggerExternal.exiting(getClassNameLogging(), "createStatement", st); return st; } - /*L3*/ public PreparedStatement prepareStatement(java.lang.String sql, int nType, int nConcur, int statementHoldability) throws SQLServerException + /*L3*/ public PreparedStatement prepareStatement(java.lang.String sql, int nType, int nConcur, int resultSetHoldability) throws SQLServerException { - loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability}); + loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability}); PreparedStatement st = prepareStatement( sql, nType, nConcur, - statementHoldability, + resultSetHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting); loggerExternal.exiting(getClassNameLogging(), "prepareStatement", st); return st; } - public PreparedStatement prepareStatement(java.lang.String sql, int nType, int nConcur, int statementHoldability, 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 { - loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability, stmtColEncSetting}); + loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability, stmtColEncSetting}); checkClosed(); - checkValidHoldability(statementHoldability); - checkMatchesCurrentHoldability(statementHoldability); + checkValidHoldability(resultSetHoldability); + checkMatchesCurrentHoldability(resultSetHoldability); PreparedStatement st = null; @@ -4499,20 +4563,20 @@ public PreparedStatement prepareStatement(java.lang.String sql, int nType, int n return st; } - /*L3*/ public CallableStatement prepareCall(String sql, int nType, int nConcur, int statementHoldability) throws SQLServerException + /*L3*/ public CallableStatement prepareCall(String sql, int nType, int nConcur, int resultSetHoldability) throws SQLServerException { - loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability}); - CallableStatement st = prepareCall(sql, nType, nConcur, statementHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting); + loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability}); + CallableStatement st = prepareCall(sql, nType, nConcur, resultSetHoldability, SQLServerStatementColumnEncryptionSetting.UseConnectionSetting); loggerExternal.exiting(getClassNameLogging(), "prepareCall", st); return st; } - public CallableStatement prepareCall(String sql, int nType, int nConcur, int statementHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetiing) throws SQLServerException + public CallableStatement prepareCall(String sql, int nType, int nConcur, int resultSetHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetiing) throws SQLServerException { - loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), statementHoldability, stmtColEncSetiing}); + loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{new Integer(nType), new Integer(nConcur), resultSetHoldability, stmtColEncSetiing}); checkClosed(); - checkValidHoldability(statementHoldability); - checkMatchesCurrentHoldability(statementHoldability); + checkValidHoldability(resultSetHoldability); + checkMatchesCurrentHoldability(resultSetHoldability); CallableStatement st = null; @@ -4549,6 +4613,46 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int sta 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 + */ public PreparedStatement prepareStatement(String sql, int flag, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{sql, new Integer(flag), stmtColEncSetting}); @@ -4568,6 +4672,48 @@ public PreparedStatement prepareStatement(String sql, int flag, SQLServerStateme 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 + */ public PreparedStatement prepareStatement(String sql, int[] columnIndexes, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{sql, columnIndexes, stmtColEncSetting}); @@ -4593,6 +4739,48 @@ public PreparedStatement prepareStatement(String sql, int[] columnIndexes, SQLSe 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 + */ public PreparedStatement prepareStatement(String sql, String[] columnNames, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "prepareStatement", new Object[]{sql, columnNames, stmtColEncSetting}); @@ -4812,6 +5000,16 @@ 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) { sendTimeAsDatetime = sendTimeAsDateTimeValue; @@ -5303,6 +5501,13 @@ void doSecurityCheck() // This variable holds the value in seconds. private static long columnEncryptionKeyCacheTtl = TimeUnit.SECONDS.convert(2, TimeUnit.HOURS); + /** + * Sets time-to-live for column encryption key entries in the column encryption key cache for the Always Encrypted feature. + * The default value is 2 hours. This variable holds the value in seconds. + * @param columnEncryptionKeyCacheTTL The timeunit in seconds + * @param unit The Timeunit. + * @throws SQLServerException when an error occurs + */ public static synchronized void setColumnEncryptionKeyCacheTtl (int columnEncryptionKeyCacheTTL, TimeUnit unit) throws SQLServerException { if (columnEncryptionKeyCacheTTL < 0 || unit.equals(TimeUnit.MILLISECONDS ) || unit.equals(TimeUnit.MICROSECONDS) || unit.equals(TimeUnit.NANOSECONDS ) ) @@ -5331,8 +5536,11 @@ final class SQLServerConnectionSecurityManager this.serverName = serverName; this.portNumber = portNumber; } - // checkConnect will throws a SecurityException if the calling thread is not - // allowed to open a socket connection to the specified serverName and portNumber. + + /** + * checkConnect will throws a SecurityException if the calling thread is not allowed to open a socket connection to the specified serverName and portNumber. + * @throws SecurityException when an error occurs + */ public void checkConnect() throws SecurityException { SecurityManager security = System.getSecurityManager(); @@ -5341,6 +5549,12 @@ public void checkConnect() throws SecurityException security.checkConnect(serverName, portNumber); } } + + /** + * Throws a SecurityException if the + * calling thread is not allowed to dynamic link the library code. + * @throws SecurityException when an error occurs + */ public void checkLink() throws SecurityException { SecurityManager security = System.getSecurityManager(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java index 32cf12b21..d5c174291 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java index 0655caade..58464dc02 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -27,23 +27,24 @@ /** * SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. * When returning a connection object from PooledConnection.getConnection we returnt 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, java.io.Serializable { - private SQLServerConnection wrappedConnection; - private boolean bIsOpen; - static private int baseConnectionID=0; //connection id dispenser - final private String traceID ; + private static final long serialVersionUID = -6412542417798843534L; + private SQLServerConnection wrappedConnection; + private boolean bIsOpen; + static private int baseConnectionID=0; //connection id dispenser + final private String traceID ; - // Permission targets - // currently only callAbort is implemented - private static final String callAbortPerm = "callAbort"; + // Permission targets + // currently only callAbort is implemented + private static final String callAbortPerm = "callAbort"; /** * Generate the next unique connection id. @@ -302,6 +303,39 @@ public java.util.Map> getTypeMap() throws SQLServerException 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, @@ -319,6 +353,44 @@ public Statement createStatement( 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, @@ -336,8 +408,43 @@ public PreparedStatement prepareStatement( checkClosed(); return wrappedConnection.prepareCall(sql, nType, nConcur, nHold); } - - public CallableStatement prepareCall( + + /** + * 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, @@ -356,7 +463,49 @@ public CallableStatement prepareCall( 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(); @@ -369,6 +518,50 @@ public PreparedStatement prepareStatement(String sql, int flag, SQLServerStateme 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(); @@ -381,6 +574,50 @@ public PreparedStatement prepareStatement(String sql, int[] columnIndexes, SQLSe 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(); @@ -579,12 +816,27 @@ public UUID getClientConnectionId() throws SQLServerException 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(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java index 9beb03a09..a665901a3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -27,6 +27,9 @@ import java.text.MessageFormat; import java.util.Map.Entry; +/** + * This class represents a column of the in-memory data table represented by SQLServerDataTable. + */ public final class SQLServerDataColumn { String columnName; @@ -34,17 +37,30 @@ public final class SQLServerDataColumn int precision = 0; int scale = 0; + /** + * Initializes a new instance of SQLServerDataColumn with the column name and type. + * @param columnName the name of the column + * @param sqlType the type of the column + */ public SQLServerDataColumn(String columnName, int sqlType) { this.columnName = columnName; this.javaSqlType = sqlType; } + /** + * Retrieves the column name. + * @return the name of the column. + */ public String getColumnName() { return columnName; } + /** + * Retrieves the column type. + * @return the column type. + */ public int getColumnType() { return javaSqlType; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index f379a43d1..cd0d34173 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -47,6 +47,9 @@ public class SQLServerDataSource implements ISQLServerDataSource, DataSource, ja static private int baseDataSourceID = 0; // Unique id generator for each DataSource instance (used for logging). final private String traceID; + /** + * Initializes a new instance of the SQLServerDataSource class. + */ public SQLServerDataSource() { connectionProps = new Properties(); @@ -166,20 +169,36 @@ public void setAuthenticationScheme(String authenticationScheme) setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION_SCHEME.toString(), authenticationScheme); } + /** + * sets the authentication mode + * @param authentication the authentication mode + */ public void setAuthentication(String authentication) { setStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), authentication); } + /** + * Retrieves the authentication mode + * @return the authentication value + */ public String getAuthentication(){ return getStringProperty(connectionProps, SQLServerDriverStringProperty.AUTHENTICATION.toString(), SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue()); } + /** + * Sets the access token. + * @param accessToken to be set in the string property. + */ public void setAccessToken(String accessToken) { setStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), accessToken); } + /** + * Retrieves the access token. + * @return the access token. + */ public String getAccessToken(){ return getStringProperty(connectionProps, SQLServerDriverStringProperty.ACCESS_TOKEN.toString(), null); } @@ -188,34 +207,66 @@ public String getAccessToken(){ // count from all the update counts returned by a batch. The default of false will // return all update counts. If lastUpdateCount is not set, getLastUpdateCount // returns the default value of false. - + /** + * 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) { setStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), 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() { return getStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), SQLServerDriverStringProperty.COLUMN_ENCRYPTION.getDefaultValue()); } + /** + * 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) { setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), 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() { return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.toString(), SQLServerDriverStringProperty.KEY_STORE_AUTHENTICATION.getDefaultValue()); } + /** + * 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) { setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_SECRET.toString(), 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) { setStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), keyStoreLocation); } + + /** + * Retrieves the keyStoreLocation for the Java Key Store. + * @return the keyStoreLocation for the Java Key Store. + */ public String getKeyStoreLocation() { return getStringProperty(connectionProps, SQLServerDriverStringProperty.KEY_STORE_LOCATION.toString(), SQLServerDriverStringProperty.KEY_STORE_LOCATION.getDefaultValue()); @@ -240,10 +291,29 @@ public boolean getEncrypt() return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.ENCRYPT.toString(), SQLServerDriverBooleanProperty.ENCRYPT.getDefaultValue()); } + /** + * 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) { setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), tnir); } + + /** + * Retrieves the TransparentNetworkIPResolution value. + * @return if enabled, returns true. Otherwise, false. + */ public boolean getTransparentNetworkIPResolution() { return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.toString(), SQLServerDriverBooleanProperty.TRANSPARENT_NETWORK_IP_RESOLUTION.getDefaultValue()); @@ -378,11 +448,20 @@ public boolean getSendStringParametersAsUnicode() { return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue()); } - // Translates the serverName from Unicode to ASCII Compatible Encoding (ACE) + + /** + * 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) { setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), 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() { return getBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.toString(), SQLServerDriverBooleanProperty.SERVER_NAME_AS_ACE.getDefaultValue()); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 0c81ba457..62f8ecaaf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -33,6 +33,10 @@ public final class SQLServerDataSourceObjectFactory implements ObjectFactory { // NOTE: Per ObjectFactory spec, the ObjectFactory class requires a public // class with public constructor. + + /** + * Initializes a new instance of the SQLServerDataSourceObjectFactory class. + */ public SQLServerDataSourceObjectFactory() {} // getObjectInstance is a factory for rehydrating references to SQLServerDataSource and its child classes. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index 1a360537e..2a08c62f1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -37,6 +37,8 @@ public final class SQLServerDataTable { /** * The constant in the Java programming language, sometimes referred to as a type code, * that identifies the type TVP. + * + * @throws SQLServerException when an error occurs */ // Name used in CREATE TYPE public SQLServerDataTable() throws SQLServerException @@ -45,6 +47,9 @@ public SQLServerDataTable() throws SQLServerException rows = new HashMap(); } + /** + * Clears this data table. + */ public synchronized void clear() { rowCount = 0; @@ -53,6 +58,10 @@ public synchronized void clear() rows.clear(); } + /** + * Retrieves an iterator on the rows of the data table. + * @return an iterator on the rows of the data table. + */ public synchronized Iterator> getIterator() { if ((null != rows) && (null != rows.entrySet())) @@ -62,6 +71,12 @@ public synchronized Iterator> getIterator() return null; } + /** + * Adds meta data for the specified column + * @param columnName the name of the column + * @param sqlType the sql type of the column + * @throws SQLServerException when an error occurs + */ public synchronized void addColumnMetadata(String columnName, int sqlType) throws SQLServerException { //column names must be unique @@ -69,6 +84,11 @@ public synchronized void addColumnMetadata(String columnName, int sqlType) throw columnMetadata.put(columnCount++, new SQLServerDataColumn(columnName,sqlType)); } + /** + * Adds meta data for the specified column + * @param column the name of the column + * @throws SQLServerException when an error occurs + */ public synchronized void addColumnMetadata(SQLServerDataColumn column) throws SQLServerException { //column names must be unique @@ -76,6 +96,11 @@ public synchronized void addColumnMetadata(SQLServerDataColumn column) throws SQ columnMetadata.put(columnCount++, column); } + /** + * Adds one row of data to the data table. + * @param values values to be added in one row of data to the data table. + * @throws SQLServerException when an error occurs + */ public synchronized void addRow(Object... values) throws SQLServerException { try @@ -241,6 +266,10 @@ public String getTvpName() return tvpName; } + /** + * Retrieves the column meta data of this data table. + * @return the column meta data of this data table. + */ public void setTvpName(String tvpName) { this.tvpName = tvpName; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 4c3b62d09..49f53e5e0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -104,6 +104,11 @@ private synchronized static int nextInstanceID() baseID++; return baseID; } + + /** + * This is a helper function to provide an ID string suitable for tracing. + * @return traceID string + */ final public String toString() { return traceID; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 05272f9cb..8e5b7c478 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -16,617 +16,6 @@ // IN THE SOFTWARE. //--------------------------------------------------------------------------------------------------------------------------------- - -/* -Version History - -18Aug2000 2.03 DPM First Release - -31Aug2000 2.04 - Reduced packet size to 512 for SQL Server 6.5 - this is the maxl - Log reports 2.04 not 2.4 - Log Write and stram made static - replace SQLException with SQLServerExceptions to make sure they are logged - -05Sep2000 DPM 2.05 - New types added to handled 6.5 CHAR() and BINARY() not null definitions - Columns.java ArrayIndexException deriveType() sent native type negative - Allow binary, varbinary, image to be returned as result set getString() - Use correct code page to build string in result set getString() - All datatypes converted from byte to integer to avoid issues with bytes creating -ve integers during conversion - All SQLExceptions are SQLServerExceptions which log the exception to the log file with a stack trace - Callable return values now convert V6 data types and derive data types based on length - Switch to allow operations with new and old tds comms modules - Modified processing of return values for SQL 6.5 for StreamRetValue - -05Sep2000 DPM 2.06 - More work on new IO architecture and performance - Used SQL pieces to do prepared statements - Handle quotes correctly in prepared Statement setString() - Changed all public classes to SQLServer* otherwise ambiguity compile errors with Optional API - Dates before 1901 displayed as year 2037 - Property logfile now is independent log file than the one control by the driver manager - (which does not log multiple connections) - -14Sep2000 DPM 2.07 - Prepared stmd and select with a singe ' in SQL executed with createStatement(type, conc) got syntax error - must replace ' with " - Before first now sets rowset row = -1 and rowset.rows to 0 to force a rowset refresh. The previous setPostions were overwriting the contents of the rowset - Stmt default fetch size set to 20 (from 2000) since its only used bringing server side rowsets into memory. 2000 is way to high - Prefix N'..' to sp_cursoropen SQL stmts for V7 - Native type uniqueidentifier could not be returned via result set getXXX() - -19Sep2000 DPM 2.08 - Implement connection setCatalog - Allow TDS_ENV_CHG messages in getMoreResults loop for setCatalog. Just eat them.. - Any messages in getMoreResults are just logged. Previoulsy caused a bad packet error. - Clear in stream when the last packet of a command is sent out. Set in buffer len and index to 0. Previously this was not being done correctly everywhere - Dump in buffer when get bad packets - Removed warning message re JDK 1.2 required - -21Sep2000 DPM 2.09 - Finsihed replacement of original IO system. - Null TEXT, NTEXT and IMAGE in result set were reporting wasNull() as false - Callable statements did not return any null param back right. Driver hung for char() or varchar() - Fixed index errors when calling app set and registered out of range callable statment params - Checked for nulls returning params from callable statments - Logging moved back to driver since >1 connection needs to write to single log file - Connection passed into everything so SQLServerException can log the connection ID - Handle callable syntax like ?=Callxxx(?..) - Changed server side cursors to manage result set calls to sp_xxx() with JDBC callable statements - All callable statement output returned as result sets, not return value packets (SQL 2000 does not appear to write them) - -02Oct2000 DPM 2.10 - Changed connection pool to not use static vectors. Previously pool returned connections to DB2 from pool2 - Set resultset to null for every doExecute. Previously s1 doing a select then update would report result set generated on the executeUpdate() - Check NRSType and RSConcur not null in call to stmt.getResultSetType and Concurrency - Return false for scrolling specified if both concur and type are specified but specified as the default values - If a command other than select is issued with a statment that specifies concurrency and type then execute it normally - IE not via a cursor_open - Implemenet stmt.setMaxRows as pre and post append to the sql statement sent. SET ROWCOUNT=x - -18Oct2000 DPM 2.11 - PreparedStmt.setNull() and ResultSet.updateString() allow string of null. If so call setNull(), updateNull etc - Statment.getWarnings() now does not throw not implemented exception, just returns null - Fixed bug causing invalid packet header. Previously the code tried to form the packet size before it had read enough bytes - -31Oct2000 DPM 2.12 - Check all DONE packets for valid hasPacket() status before returning the row count from the packet - If no result set and no update count is available from getMoreResults set update count to -1 in accordance with JDBC spec - Support getErrorCode and getSQLState for SQLException - Support for BLOB and CLOB - Now deployed obfuscated and in one JAR file (removed 2nd Optional API JAR file) - Fixed updatable result set meta data returning a column count including the rowstat column. - Support BIGINT in SQL 2000 - Support Result Set refresh row - Once the input buffer exceeds its initial size increase it in big chunks to avoid excessive extensions of it for large result sets - -27Nov2000 DPM 2.13 - Max concurrent connections for unpaid licenses is down from 2 to 1. - Rowset Support - Distributed XA support - -01Dec2000 DPM 2.14 - 2.13 went out with 2.12 as the embedded version number.. - Used DONEINPROC transaction state flag to correctly handle combinations of result sets and update counts generated from a stored procedure - Generally reduced number of objects created for many operations. This reduces time to alloc object and garbage collect them. This gave ~15% speed gain. Use OptimizeIt. - Removed finalizers that only set variables to null. These take time to register and fire and do nothing useful - IO buffers for input and output merged as one buffer - An object can specify its original IOBuffer size. Connections required less than statements. - IOBuffer - Removed temporary char[] used to send commands - IOBuffer - reduced temporary byte[] used to build StreamXXX packets - Reduce result set IOBuffer extension size for first extension but then double buffer extension size each time an extension is required. Better for large result sets - getRowsetField returns Strings, not StringBuffers now. - Building the String to send for a prepared statement is now done with a common StringBuffer rather than concatenating may strings - Fixed bug where number of columns returned in ResultSetMetaData was one too few for server side cursors - -09Dec2000 DPM 2.15 - Removed indexing of whole result set when it is first read. Now index the current row only - Upped default fetch size for server side cursors 20->100 - Allow client side cursors to scroll. - Fix bug where negative shorts were returned positive. - If a stored proc returns update counts before a result set skip them if the app called executeQuery() - -20Dec2000-29Dec2000 DPM 2.16 - Drop the 'N' national character prefix when the length of data > 4000 chars. Else get //More than this get error - 'Error converting data type ntext to text' - Statement parameters - handle single quote in LONGVARCHAR (CLOB) as well as CHAR (String). - Prepared params for large binary object - ensure statment string has extra 1K of bytes to avoid realloc of string buffer during conversion to hex - When sending string command (IE not login) send from the command string itself rather than copying the string into the extendable IO buffer. Previously attempted inserts of >5MB images failed - Version V7 flag was not propagated to cloned connections during pooling. This caused pooling to SQL 6.5 db's to fail - -04Jan2001- DPM 2.17 - Catch no such method on DBComms.setReceiveBufferSize since it fails on some JVM 1.2's - Result set insert row, update row and delete row now read for TDS_DONEPROC to check successful operation or else throw SQLException - EG data too long - Obey setMaxRows() for server side cursors in addition to client side cursors. - Fixed bug that reported zero length TEXT, NTEXT or IMAGE as null - Make data source property names consistent with JDBC spec serverName instead of host etc. - Start of JDBC 3.0 features - Savepoints - Close server cursors - server side cursors were never being closed. - -24Jan2001 - DPM 2.18 - Moved command logging to IOBuffer.sendCommand to get log of everything sent - When get 'exhausted input ..' exception dump the in buffer. - For output params: if app specifies registerOutParam(CHAR) register it as VARCHAR instead. Its hard to think of cases where this would not be correct and it takes the onus off the app to specify VARCHAR instead of char - Made connection thread safe. Database comms now synchronized between >1 statement on the connection. NOTE * Result set and statement are not thread safe. - Fixed rs.getBinaryStream & getAsciiStream which generated a null pointer exception if the column data was null. - -5Feb2001 - 20Feb01 DPM 2.19 - For versions >= 7.0 use 'SID', not 'SUID' in schema queries in db meta data. SQL 2000 deprecated SUID. - Fixed bug returning datetimes's out by an hour in daylight savings hours. - Fixed bug where a pending transaction on the previous use of a pooled connection handle propagated to the next use of the connection handle - -22Feb01 - DPM 2.20 - If a client side cursor hit end with a next() then any subsequent next() must return false - Stored procs returning multiple result sets. If one of the results sets has 0 rows got 'input exhausted' message. Need to search for DONEINPROC as well as DONEPROC to mark end of result set - -07Mar2001 - DPM 2.21 - Datasource setSqlversion changed to setSqlVersion(). Added setDatabase() and getDatabase() - Support setURL() and getURL() in datasources. Popular (but not mandatory) property.. - Remove parsing for escape '\'. Parsing a constant string in a prepare() or prepareCall() threw a count parameters exception - Implemenent JDBC 3.0 pool management in SQLServerPoolingDataSource - serverName and portNumber were not processed by SQLServerDriver. Previously only worked for data sources, now work via driver manager - Support setObject(o) where o is a Short. - getObject() for a smallint should return object type Short. integerToObject returns short for short and tiny types - Added support for cancel a statement and query timeouts - Support for Driver Manager and Data source connection login timeout - Changed Datasource setPort(String) to setPort(int) - Added support for getInt, Long, Float() etc where the source column is CHAR or VARCHAR - -22Mar2001 - DPM 2.22 - Changed sp_cursor to allow update of null on updatable result sets. Now this call uses declare @param=value etc. From SQL 7.0 SP2 and SQL 2000 on, the syntax exec sp_cursor ..., @column1 = null gives 'Incorrect syntax near type' - Allow result sets from callable statements to use absolute positioning. IE make them not "serverSide()=true" - Another attempt at getting datestamps to return correctly. Datetimes out by 1 hours as daylight savings changed in some time zones. Use complained some time stamps still out by 60 minutes - JDBC 3.0 Connector code - start. - Ensure new JDBC 3.0 connector code does not ship in 2.0 and then get class not found errors at runtime. - -03Apr2001 - DPM 2.23 - Fixes to run JDBCCTS certification tests :- - DBMeta - attempt to change to different catalog if its specified in the call. - DBMeta - return a non null, empty result instead of null for no tables, columns etc calls - DBMeta - make connection.getCatalog and dbmeta.getCatalogs() return upper case to match between them - ResultSet - throw exception for negative setFetchSize. - ResultSet - allow char to timestamp and char to bit conversion for reads. - BatchUpdate - If the batch is cleared should return result int[0] to caller, dont throw exception - BatchUpdate - Propagate the result int[] to any BatchUpdateException - BatchUpdate - disallow select in batch - throw BatchUpdateException - EscapeSyntax- return "" to query for functions supported. - Stmt - throw exceptions for -ve set of query timeout, max column size or max rows - Stmt - Fix for empty result set generated followed by call to getMoreResults() - - Changed checkLicense - previous method of selecting connections from DB was not thread safe for many threads starting up connections simulataneously - Bugs in precsion and scale - reviewed and corrected for all data types - -19Apr2001 - DPM 2.24 - Renamed SQLServerPoolingDataSource to SQLServerConnectionPool. This class is no longer derived from datasource - Positions indexes in Blob and CLob must start at 1, not 0 - see JDBC spec - If auto commit is on and the app calls commit() dont execute a begin transaction. - Remove difference in logic callable statement vs prepared stmt in getNextResult(). - This is required to ensure update counts are correctly returned for stored procedures executed via a prepared stmt with an "EXEC" - Summary: 2.23 allows exec via prepared statements, 2.24 returns correct update counts for exec - DBMeta.getMaxStatements() changed to return 0 unlimited not 1 - Fix 'DBComms.negative data length'. Sometimes SQL Server does not return the full packet length for packets before the last packet - Licenses are now version specific. IE a 2.x license will fail in a 3.x driver - -04May2001 - DPM 2.25 - A single space from a char() column was returned as null. This behaviour should only be true in SQL 6.5 mode - If updateByte(n) and n is < 0 make n = 256+n. Required to pass inet performance test - Allow situation with no actual column updates. Required to pass inet performance test - stmt.indexRow() - fixed bug where a prepared statement was executed with some params to create a result set with rows, then executed with new params which returned a null result set. However the 2nd row of the first result set was returned in error. checked indexRow does not go beyond end of receieved data from dbms. - CallableStatement.getObject did not use correct index to retrieve the parameters type if some input only params were in the param list before the out params - Added new property to specify character set for single byte columns. 'codepage' - License check for 2.x driver incorrectly checked if the license is version specific. USers installing old licenses (before version aware) into current releases failed the check - Performance analysis again : - - make most classes final, those not finalizable - make most methods final - - replace use of Vector with ArrayList - - use RPC to execute all sp_cursors to insert, update and delete from server side cursors - - rewrote the building of SQL cmds to send to db. Minimized use of string concatenation to expand prepared statements. USed global char[] buffer instead - Catch SocketException if setTcpNoDelay fails on socket creation - this is not supported in Oracle App Server - Try to set socket KeepAlive on to resolve the numerous reports of 'connection reset by peer' - Updates to result sets now done with a new temporary statement from the result set. Previously the building of the sp_cursor call and subsequent packets back from the db corrupted the original result set which was using the same io buffer - -30May2001 - DPM 2.251 - 2.25 was corrupting the result of rs.getString(n) with the value of rs.getString(n-1). Caused read corruption with VARCHAR - -30May2001 - DPM 2.26 - Use sp_prepare, column parsing and sp_execute to handle prepared statements - Generate correct call stmt params numbers for param count 1->99, 2.25 created a syntax error if the param number was > 30 - Setting the "portNumber" via connection properties (therefore datasources etc) was ignored - Execute callable statements with RPC. Rewrite of large parts of stored procedures - TDS_DONE and DONEPROC are returned only if they contain an update count or are final. Removed more convoluted logic for processing these packets - DbComms.receive could read some of the packet's data bytes if it had to read the packet header in >1 chunk. Code was changed to stop this - Connection setCatalog changed the database but did not set sCatalog that is used to return connection.getCatalog(). Also getTables gave error if the user was connected to any database, EG none specified on the connect URL - ResultSet.Close() no longer sets its stmt to null. The statement is still required because the result set's statement needs to be able to move to the end of the result set to retrieve more results. Previoulsy application received a null pointer using absolute to move to the end of the result set if the user app closed the result set. See test ResultSetMoreAfterClose. - Added optimized handling of result set getString() if the default encoding is US Ascii - Database meta data now creates a new statement and result set instance to handle nested calling of result set functions. Eg get all columns of all tables in the database. User reported this failed with IDE Forte's capture database schema feature. - Ensure logon failure exceptions contain the specific SQL Server error code and state. - Codepage setting was not being propagated to pooled connections. - Allow datasource setXXX() properties to override the values set in datasource.setURL(). Previously if setURL() was used, no other property set with setXXX() was examined - Commit/Rollback and start new transaction now separate methods. - XADataSource does not begin a transaction now, XAResource.start begins the transaction since for 'never' setting of container managed transactions app server will never start a transaction. In that case the app server will never call XAResource.start() - Add JDBC 3.0 pooling parameters to data source and connection pool. Doc with JAva doc for user HTML - If executeUpdate generates a result set thow the exception but do not display it to System.out - When a paramter is set clear its bNull flag. Websphere resues prepared statements across bean activations and clears their params after each execute - -30May2001 - DPM 2.261 - Converting timestamps to datetime for dates < 1970 created incorrect dates and times since the ms values was < 0 - Allow prepared insert expressions with mixed constants and ? to pass parsing. EG INSERT INTO TABLE (COL1, COL2) VALUES (1, ?) - Ensure '?' embedded in literals do not get replaced with parameter markers when preparing statements - Use a smaller char[] to expand parameter markers for long sql statements. Previously the expanded statement was x4 the original which caused SQL Server to close the connection socket. - ALlow Types.NUMERIC as a type for registering out params with RPC. - -24Jul2001 - DPM 2.262 - Connection property "disablePrePrepare" to disable use of new pre preparation of prepared statements. - Statement.sendParamsByRPC did not include switch for all the java.sql.Types.* possibly registered with registerOutParam - registerOutPram now maps them to types suported ty preparedStatment.setXXX() -26Jul2001 - DPM 2.263 - Disable sp_prepare until statement pooling is implemented to reduce memory usage - Add N prefix to char data > 4000 characters for text mode parameter expansion. Previously CHAR or VARCHAR params were sent to DBMS without the N national character prefix when the data was > 4000 chars due to reported "'Error converting data type ntext to text'". Customer complained wrong unicode > 4000 chars and this convert error cannot be recreated..so N is prefixed to all char data now -26Jul2001 - DPM 2.264 - Moved prepared statement preparation to connection for prepared handle pooling - Ensure all java.sql.Types.* can be set using prepStmt.setNull(n, *); -30Jul2001 - DPM 2.265 - Do not search for TDS_DONE when bOnlyResultSets is true (for executeQuery()) -30Jul2001 - DPM 2.266 - Correct 0 index in prepared statement setClob() and setBlob() - If string data length is > 4000 (not 8000) send as LONGCHAR data -07Aug2001 - DPM 2.267 - Fix fatal comms errors notifications. Previously a connection pool was not notified about a fatal comms error on a connection. - When a pooled connection is closed only reset it to CLOSED (available) if errors occurred on the connection - Prepared and callable statement setNull(n, Types.BIGINT) resulted in 0 , not null being passed. - Pooled connections that have experienced fatal IO errors removed from pool list - Renamed disablePrePrepare property to disableStatementPooling - New IOBuffer method to try to extend the buffer (by disk file) in low memory conditions - -10Aug 2001 - DPM 2.268 - Dont allow setAutoCommit() to generate more than one level of transaction since a single rollback will leave the transaction uncomitted. IE @@TRANCOUNT should never be > 1 - Leave Debug.class obfuscated in build. - Allow SQLServerConnectionPool to pool connections for a SQLServerXADataSource, not just SQLServerConnectionPoolDataSource - Non XA pooled connections now issue a rollback when the connection is closed to dispose of any uncommited transactions - The use of DBComms.LAST_PKT_NO caused index of out bounds exceptions - Logging for RPC throws out of bounds exception if the log is on when sending a binary stream (or other large data) whereby the logging expected the length of the procedure name in the first 2 bytes but the 1st packet of the command has already be sent - Catch a security exception if we cannot read the JVM's character encoding to set bCp1252. - -10Aug2001 - DPM 2.269 - Blob.getBinaryStream issued a call for Blob.getBytes with a zero index (the index of the first byte is 1). Ditto for Clob. - Expand propertyInfo in getPropertyInfo from size 7 to 9. Previously an array index exception was thrown just by calling this method. - Remove all explicit calls to Runtime garbage collection - Timeout thread now uses interrupt (not stop) to end a timeout thread. Stop is deprecated because its not threadsafe - Added SQL_UNICODE_VARCHAR (-96) as a valid type for a null RPC paramter. IBM Persistence builder uses setNull(n, -96). Reported by HP - -22Aug2001 - DPM 2.2610 - Dont attempt to send stored procedure calls with static parameters via RPC, send by batch instead. RPC can only be used if all parameters are set by setXXX() - Connection.getCatalog should not return the db name in upper case. Ensure that if the cat was never set its returned as "master" - -23Aug2001 - DPM 2.2611 - Timestamps with >0 times before 1970 were stored wrongly with RPC prepared statements. EG 12/20/1969 13:08:52 was stored 12/21/1969 13:08:52 - Database meta data buildColumns() returned non java.sql.Types values for the data type (col5) for NCHAR, NVARCHAR and NTEXT - Prepared batch statement with setLong(). The long value was not copied to each batch param set. - Sending a stream (binary or char/ text or RPC) now checks if less than the requested number bytes was read from the stream. Previously the code expected that all bytes requested were read. IE now the stream may provide the requested number of bytes in chunks - -23Aug2001 - DPM 2.2612 - The call to callableStatement.execute() had the static param/output param check commented? The comment was removed. An attempt to call a stored procedure with static params mixed with output params now throws an exception. Static params cannot be sent via RPC and output params cannot be processed via non-RPC stored proc calls. That is because the required RET_VAL's do not appear before the final DONEPROC that the code uses to identify the end of the procedure - If the file name is null or zero length do not attempt to set the custom log file in logger.setCustomLogger() - If an unknown column type is reported in connection.buildParamDefinitions abort the preparation of the statement. If the showParseErrors is on display the text of the 'unknown type' exception - Handle DataTypes.BIT1 (bit not null) when building the parameter types string for the sp_prepare in prepared statement preparation - If an attempt is made to use setNull with jdbcType 0, use the jdbc type Types.CHAR - If an attempt is made to set parameters on a closed prepared statement, throw the exception "stmt is closed", dont generate a null pointer exception - -10Sep2001 - DPM 2.2613 - Non CallableStatements should not process DONEINPROC's since they may be generated from triggers etc. If the DONEINPROC is processed (rather than the final DONE) we loose the update count in the DONE. - dbMetaData.getSystemFunctions() reinstated after CTS certification complete. The CTS certification tried to exercise them if they were returned as supported. - Dont process DONEINPROC for non prepared statements - see code comments. This partially fixes a customer problem getting wrong update counts when triggers are fired. - Datasource - dont override any username, password set via setURL() if the username/password was not set with setUsername, setPassword etc. Previoulsy a username/pass set in the URL would be overidden with "" if setUsername was not called. - -170Sep2001 - DPM 2.2614 - Statement.cancel() did not work. - Stored procedure that returns say 2 resultsets, the first of which has 0 rows. The first row of the 2nd result set is returned then we get an unknown packet error - The variable userSQL was moved from PreparedStatement to Statement. Its now used by cachedResultSet to obtain the table name if the rowset is populated by a resultset - ResultSet.getCharacterStream() - if the data is null return null, dont allow the null pointer exception of the previous version - -02Oct2001 - DPM 2.2615 - Revised detection of DONEINPROCs again to allow correct operation of a prepared statement that executes a "execute procname" - IE a prepared statement that cannot be executed with sp_prepare, sp_execute - Statment.targetColumnType() did not consider the case where the updating statement was a callable statement - attempts to set stored procedure params >4000 chars failed - Cloning parameters for batcing prepared statements did not copy the values of any binary or character streams, byte arrays or big decimals - -10Oct2001 - DPM 2.2616 - BLOB/CLOB and referenced classes Connection, IOBuffer, Packet Requestor etc) all made serializable or included constructors to make them serializalbe. Requested via Thought Inc Coco Base - RPCAppendDouble did not allocate extend the out buffer by enough bytes for the 8 byte bit pattern. Caused an index out of bounds exception - Support setObject using java.util.Date as well as java.sql.Date. - -15Oct2001 - DPM 2.2617 - Cached rowset - Only report the inability to determine the underlying table name when updating it. For example, the rowset may have been populated from a callable statement and the user just wants to browser (not update) it. - Prepared Stmt.setObject(timestamp). Move the timestamp test before the java.util.Date test. Timestamps are java.util.Dates but must be processed with timestamp specific code to retain the HH:mm:SS -16Oct2001 - DPM 2.2618 - statement.getMoreResults() call after no result set returned and updatecount=-1 returned caused a "No TDS_RET_STATUS found for stored procedure output params". - If the syntax for a callable statement is invalid try to execute it as a preparedStatement call. This is the way 2.25 used to work - Statement.getNextResult() - set update count to -1 if we go beyond the end of the receive buffer - closeAllConnections() - new API added to connection pool to close connections before the pool is finalized. - -16Oct2001 - DPM 2.2619 - StreamError - new mapping of some specific error numbers to state strings. -13Nov2001 - DPM 2.2620 - Some conditional code to allow compile/operation with JDK 1.1.8 -27Nov2001 - DPM 2.2621 - Changed rounding arithmetic for sending timestamp paramters via RPC to avoid rounding errors -19Nov2001 - DPM 2.2622 - Changed PreparedStatement.setTimestamp. timestamp.getTime() did not include the millisecs of the timestamp for JDK <= 1.3 - For RPC for < SQL 7.0 send byte array correct tds 6.5 protocol - datatypes, data length size etc. - Send RPC String params with maximum target type column size, not the size of the actual target column in the table - For SQLServerJDBCRowset if the username/passw are not set for the rowset use any username/pass specified for the rowset's datasource -13Dec2001 - DPM 2.2623 - Cached rowset - when populating the rowset with a result set rewind the result set before populating the rowset in case the use app was laready at the end of the result set -19Dec2001 - DPM 2.2624 - Propagate the statement's QueryTimeout (if set) to any statements used to fetch result set cursors for server side result sets - Handle exception if app if driver cannot call System.getProperties() to get the JDK version -02Jan2002 - DPM 2.2625 - Support the setMaxRows() call if the statement is a callable statement. This stopped working when the move was made to RPC for callable statements -07Jan2002 - DPM 2.2626 - Add support for SQLWarnings - CallableStatement - Allow case where no parenthesis are around the callable statement params, Previously got procedure not found xxx ?,?,? - Added calendar support for get/set timezone, time and date - If a decimal is returned as long drop any decimal places, dont throw a number format exception - -18Jan2002 - DPM 2.27 - Remove connection finalizer. See notes in code - Support for JTA via MS DTC - Handles the use of "{call" escape sequence using a non callable statment. - -24Jan2002 - DPM 2.2701 - Corrected count of parameters with an escape sequence in a string -29Jan2002 - DPM 2.2702 - Send prepared stmts > 4000 chars via long strings in RPC - Dont try to close the connection's prepared handles if the finalizer thread has closed the socket already -06Feb2002 - DPM 2.2703 - Dont use zSQL to build sp_prepare for prepared statements. Previously syntax that could not be parsed was execute as non-prepared. - Dont close prepared handles when the connection is closed. SQL Server will do it automatically. - Dont read the entire BLOB/CLOB in PreparedStatement.setBlob/Clob() - SQLServerDataSourceObjectFactory.stringToBoolean had thrown invalid index exception. - Calls to SQLServerConnectConnectionPoolDataSource.setManagementCycleTime() now call setPropertyCycle(). THe SQLServerConnect pool is now driven by the propertyCycleTime, not the ManagementCycleTime -06Feb2002 - DPM 2.2704 - Change message when a param value for a prepared stmt is not set. This is generated now by Connection.buildParamTypeDefinitions() - If the prepared stmt parameter definition > 4000 send it as long text. - Generate a connection pool notfiy error if there are packet errors in the db comms. Tell the pool to remove the physical connection -06Feb2002 - DPM 2.2705 - If there a >1 LONGVARCHAR (or CLOB) in a single row for insert/update dealy between sending the data for each to the DB - SQLServerException now serializable - Added some new state codes mappings for SQL exceptions -06Feb2002 - DPM 3.2706 - Changes to allow JDBC 3 mulitple open result sets - New connection property to control lock timeouts 'lockTimeout'. - ResultSet.last() now uses LAST (not absolute) for server side cursors since absolute -1 failed on dynamic cursors. - Data source support various flavours of setProperty(String, value) - ResultSet.isLast() caused the field offset tables to be replaced with the value for the last row - ';' is a connection preoperty delimiter - String (not byte[]) is now the type returned by getObject() for GUIDs. Required for GUID reading in cached rowsets - Implemeted connection Failover -20Mar2002 - DPM 3.2707 - Added state code for network failure based exceptions -20Mar2002 - DPM 3.2708 - After ResultSet.updateRow() set all column params to PARAM_NOT_SET so previous row parram values are not applied to the current row to be updated (if they are not explicitly set for that row) -20Mar2002 - DPM 3.2709 - Subtle changes in thread timeout handling, suggested by customer. - Changed ResultSet.updatedTimestamp. timestamp.getTime() did not include the millisecs of the timestamp for JDK <= 1.3 -20Mar2002 - DPM 3.2710 - Reprepare stmt if the execute params values are incompatible with the prepared stmt. EG A long string needs to inserted with a prpeared stmt prepared for a short string - Once memory is exhausted on receiving large result sets send all subsequent db input to a file buffer. - Avoid creating another byte[] when reading large BLOBs. Memory saving. - Check for null stmt in dbmeta.getTables() - Support property sendStringParametersAsUnicode to allow string params to be sent in native TDS collation format, not UNICODE for performance - Support all numeric database names by adding single quotes in its "USE" statement -30May2002 - DPM 3.2711 - Map "FOR UPDATE" to HOLDLOCK in a select. This option will lock the select rows - Report state "08S01" when connection fails because db not up -30May2002 - DPM 3.2712 - SQLServerConnectionPool cycled thru all physical connections in the pool, pinging each one when it should have issued the first eligible connection - SQLServerConnectionPool did not ping conncections automatically created by the connection pool (EG intial connection or top up connections) - Detect auto-increment on numerics as well as integer columns -18Jul2002 - DPM 3.2713 - Dont override cached rowset command if its been previously set - ALlow >1 space between 'call' and procedure name, previously this sytnax caused the call stmt to be sent as batch, not RPC - Remove attempted mapping of "FOR UPDATE". This generates incorrect syntax if there is a WHERE CLAUSE. SELECT * FROM TEST WHERE COl0 then return it as big decimal, not bigint - Stmt.initRowset initialize index tables each call, customer reports null ptr exception in this code but cannot recreate it - Resultset.insert and update row. Check result set is updatable. Dont throw 'The cursor identifier value provided (0) is not valid' - Add new test to detected end of resultset for server side cursor. See notes in code - -08Oct2002 - DPM 3.2721 - New 7.0 logon packet - New connection property applicationName - Allow setDate value to be a null date in cachedrowset - -09Dec2002 - DPM 3.3000 - Support for NT Authentication - Implement TDS 0x71 protocol - Change BIGINT, NUMERIC, DECIMAL to use TDS protocol 0x71 type values - connection pre-verify implemented in connection pools - Datasource print writer can now be enabled and disabled (set to null) during the application running. - setTransactionIsolation - check connection and socket not closed already. - Allow prepStmt.setObject(obj) where obj is an input stream - Add connection/thread context to DBComms network exceptions - All getObject() now return Long (not BIGINT) for BIGINT db column types. Also applies to any data conversion that previoulsy returned BIGINTs - -13Jan2003 - DPM 3.3001 - Must map user's sql to use (case col=null else..) to distinguish null values using textptr's - Further changes to sending RPC streams to ensure no interim short packets are generated -21Jan2003 - DPM 3.3002 - Change to textptr syntax for Cognos -05Feb2003 - DPM 3.3003 - Discard any result set updates not applied with ResultSet.updateRow() when the application moves off the row. - Enforce single machine name check. License handled is now version 'A' of license - An expired license still allowed unlimited connections since the SQL to check existing connections used the wrong 'program name' -24Feb2003 - DPM 3.3004 - Flush db network send for statement cancel API call - SQLServerLicense.class now required instead of License.class. Required to allow >1 Microsoft product to exist in a JVM without tripping over each others licenses (and failing on license product ID) - If a TDS_ERR is present at the end of a result set (instead of TDS_DONE) throw the exception. Customer (Nobilis) reported that a deadlock was not reported - ResultSet getString() from a BIGINT threw a Long() class cast exception. - DBComms.eatCancel added to remove unprocessed cancelled packets -24Feb2003 - DPM 3.3005 - SQL Type uniqueidentifier (GUID) now returned as a String from getObject(). Previously was byte[]. - ResultSetMetaData and DatabaseMetaData returns GUID column type as Types.CHAR. - Allow port numbers larger than short() number value. -11Mar2003 - DPM 3.3006 - DBComms.eatCancel() must wait in some cases for arrival of cancel packet. - Authentication listener now listens on port 1533 - Lookup for named instance port for a specified named instance - commit/rollback the current trans and start the new one in one (not 2) db round trips - Added compile time option to synchronize setting of auto commit, see notes in code. BEA project -18Mar2003 - DPM 3.3007 - IoBuffer.bufferAppendRPCInputStream -01Apr2003 - DPM 3.3008 - Trusted connections are now closed via OleDB DLL, not the java socket level. This is required to avoid depletion of network resources ultimately causing a failure to connect. -01Apr2003 - DPM 3.3009 - Trusted connections are now implemented using ODBC. The permanent proxy socket listnener was replaced by a temporary listener on the same thread as the connection attempt -10Apr2003 - 30Apr03 DPM 3.3010 - SQLServerException handling changed to centralize errNum->state mapping - Support for con property XOPENStates=true - Check for and throw exception for a statement that is zero length. EG stmt.executeUpdate(""); This causes the recv from the db to wait forever. - Disabled autoCommit optimization that was added for the BEA transaction tests. - Trusted authentication reverted back to use OleDB since ODBC did not improve the BMC stability problems - Trusted connection now made by calling the DLL on the main thread (not a new thread) since BMC changes the credentials of the main thread only -01May2003 - DPM 3.3011 - Password encryption on SQL Server authentication corrected to handle unicode characters - Allow trusted authetnication with SQL 7.0 which requires two connections to connect. The first is rejected to downstep the TDS version -14May2003 - DPM 3.3012 - notifyEventMethod in connection changed from static to non static. If there are >1 connection objects they may have come from different BasePooledConnections - notifyEventMethod must be propagated in connection cloning. -21May2003 - DPM 3.3013 - Connection.getTypeMap must not throw exception for WAS 5.0 - Map the "FOR UPDATE" syntax to use an updatable cursor (using sp_cursoropen) -21May2003 - DPM 3.3014 - Ensure that a prepared statement reprepares if a decimal parameter is encounted with a higher scale than the value the statement was prepared with - Numerous changes to improve efficiency of how a prepared statement can access the original parameters it was prepared with - Ensure translateBooleanLiterals works with stmt.executeUpdate(). Test for syntax translation was not present in this method - Boolean literal processing did not correctly handle >1 boolean literal in the SQL syntax. Replace the logic -24Jun2003 - DPM 3.3015 - Only attempt InetAddress.getLocalHost() call if the license specifies a specific machine name. This call has failed with an internal NPE at a customers site -01Jul2003 - DPM 3.3016 - Do not attempt to use server side cursors if the statement is prepared with specifc Result set type and concurrency but the application does not ultimately execute a SELECT. This fix required for use with KODO JDO -01Jul2003 - DPM 3.3017 - Calendar was ignored by some changed code to convert date, timestamp etc to/from MS SQL format. -04Aug2003 - DPM 3.3018 - Start work to handle data type SQL_VARIANT string values EG generated from a EXEC sp_executesql 'some command' within a stored procedure - Correct database IO bug where the database's packet size is set to a high value EG 32K. -08Aug2003 - DPM 3.3019 - GetPropertyInfo generated an arrayIndex exception. The array must be expanded as new properties are added. - Changes to cancel logic to avoid driver waiting forever when a statement on a connection was cancelled and that connection was later reissued from the connection pool -03Oct2003 - DPM 3.3020 - Add a connection property to enable failover support. Previously the driver interpreted '%' in a connection propery (eg pwd) as a failover sequence (BMC reported issue) -06Nov2003 - DPM 3.3021 - New licensing structure specifies machine name, max connections and license mode (client or server). - Discontinue old single connection mode after trial expires. Once trial expires product is now no longer usable. - -29Jan2004 - DPM 3.3022 KR - Code checked into CVS - -03Feb2004 - DPM 3.3023 KR - ProductName- instead of just ProductName. The previous version would have failed if multiple - Group Licenses will try to connect to the same SQLServer. - -09 April2004 - 4.0000 KR - Create a new Driver property called "selectMethod". - Full support for Blob/Clob classes. - Improved performance for BatchUpdates -- both Statement and PreparedStatement. - Changes made in 3.3023 have been reverted back. The new licensing scheme will take - care of the bug. - No more SQLServerConnect 2.0 and SQLServerConnect 3.0 -- Just one product with both drivers JDBC 2.0 - and JDBC 3.0 Compliant. - New Documentation -- All old logos replaced. - -23 April2004 - 4.0100 KR - New property 'iterativeBatching' to support batchUpdate backward compatibility. - -27 May2004 - 4.0200 KR - Fixed a bug for SET Statements.The isSelect() method in SQLServerStatement used to - determine if a statement is Select or not just by the first letter of the query. Thus - a set command would be assumed to be a select query. This has caused problems internally where - isSelect() method is used. Fixed to look for the whole "select" word. - New Batch implementation never cleared the statements in batch after processing them. Fixed. - -18 Jun2004 - 4.0300 KR - Removed Upper() function in DatabaseMetaData.getCatalogs(). Now return the original case. Refer Bugz-416 - -29 Oct2004 - 4.0300 DPM - -Added new properties to allow connection retries. This is introduced to try to solve SBC very rapid creation of connections issue - -Ensure connection IDs issued in a thread safe manner. - -Have all log entries show the connection instance ID. Previously connection attempts did not. - setCursorName. Allow a null value to be compliant with WAS 5.0 adapter com.ibm.websphere.rsadapter.ConnectJDBCDataStoreHelper - -Added datasource property maxConnectionBacklog to limit the number of concurrent connections in progress. Resolves an SBC issue where many connections where created in a short time period. Typically only used when a server is under very heavy load - -09 Nov2004 - 4.0400 DPM - Comments Added by KR - -Code changed in AuthenticationProcessor run() method and the JDBC3.0 driver will use the - methods available in JDK 1.4 and up for reusing the ServerSockets that were closed recently. - -Reusing recently closed sockets by the authentication proxy avoids depletion of the socket pool - -Added case for error code to state mapping. Error 2627 maps to SQL 92 state "23000" (Violation of primary key constraint) - -retryConnectionCount > 0 caused >1 connection to be created in error. Now when a connection is made successfully the retry loop exits. - - A connection thread is now guaranteed to not start a new trusted connection proxy listener before - Reusing recently closed sockets by the authentication proxy avoids depletion of the socket pool - the proxy instance thread of a previous connection exits - New property trustedAuthenticationPort was added to enable the trusted authentication proxy to - listen on a unique port for every JVM instance on a single machine. Otherwise the proxy listener - is not multi process safe on >1 JVM on a single machine - -08 Dec 04 - 4.50 KR - Got J2EE 1.4 Certified. NTLM code changes have been merged but not made public. Will be made - public in the next major version. - Fixed a bug in CallableStatement and removed stack trace outputs left uncommented inadvertently. - -01 Jan 05 - 4.51 KR - NTLM Authentication implemented.New Connection properties "ntlmAuthentication" and "domain" have been - added. "domain" property is required whenever ntlmAuthentication is turned on. - NOTE :- THE SETTERS AND GETTERS IN SQLServerDataSource for these properties are PRIVATE, as they are - not supposed to be made public in 4.50. AT THE RELEASE OF 5.0 MAKE SURE TO MAKE THEM PUBLIC. - Added case for error code to state mapping. Error 2627 maps to SQL 92 state "23000" (Violation of primary key constraint) - retryConnectionCount > 0 caused >1 connection to be created in error. Now when a connection is made successfully the retry loop exits. - -02 Feb 05 - 4.52 DPM - Provide ability to return prepared statement meta data prior to the execution of the statement - Driver must use max precision of 38 for all decimals for SQL 2000, previously was hard coded to 28. - prepStmt.setObject(type) added additional code to convert data to target type before sending to db - A db datetime returned as a JDBC time now has the date component zeroed - A callable statement param used for IN and OUT may have a different type registered for output versus the input data type supplied by a setXXX(). - DATETIME output params from a stored proc must be converted to the user's registered out type - Prep statements sp_prepare datatype NTEXT must be modified to TEXT when using ascii string parameters property - IOBuffer.bufferAppendRPCStringAscii did not preallocate enough bytes causing an IndexArrayOutOfBounds exception periodically - Added 3 new classes to begin support for SSL via SQLServerConnect. - For logging of RPC data convert the binary data to hex representation. Existing code could throw a NegativeArrayIndex exception - -02 Mar 05 - 4.53 DPM - Have the SQLServerNTAuthentication.dll issue a unique authentication proxy listening port for the driver in each JVM instance. This is required since there is no inter-JVM synchronization. -*/ package com.microsoft.sqlserver.jdbc; import java.sql.*; @@ -743,8 +132,6 @@ else if (value.toLowerCase(Locale.US).equalsIgnoreCase(ColumnEncryptionSetting.D enum KeyStoreAuthentication { JavaKeyStorePassword; - // CertificateStore is not supported for the 6.0 release. - //CertificateStore; static KeyStoreAuthentication valueOfString(String value) throws SQLServerException { @@ -754,10 +141,6 @@ static KeyStoreAuthentication valueOfString(String value) throws SQLServerExcept { method = KeyStoreAuthentication.JavaKeyStorePassword; } -// else if (value.toLowerCase(Locale.US).equalsIgnoreCase(KeyStoreAuthentication.CertificateStore.toString())) -// { -// method = KeyStoreAuthentication.CertificateStore; -// } else { MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidConnectionSetting")); @@ -990,7 +373,7 @@ public final class SQLServerDriver implements java.sql.Driver new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.WORKSTATION_ID.toString(), SQLServerDriverStringProperty.WORKSTATION_ID.getDefaultValue(), false, null), new SQLServerDriverPropertyInfo(SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), Boolean.toString(SQLServerDriverBooleanProperty.XOPEN_STATES.getDefaultValue()), false, TRUE_FALSE), new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.AUTHENTICATION_SCHEME.toString(), SQLServerDriverStringProperty.AUTHENTICATION_SCHEME.getDefaultValue(), false, new String[] {AuthenticationScheme.javaKerberos.toString(),AuthenticationScheme.nativeAuthentication.toString()}), - new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.AUTHENTICATION.toString(), SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue(), false, new String[] {SqlAuthentication.NotSpecified.toString(),SqlAuthentication.SqlPassword.toString(),SqlAuthentication.ActiveDirectoryPassword.toString(),SqlAuthentication.ActiveDirectoryIntegrated.toString()}), + new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.AUTHENTICATION.toString(), SQLServerDriverStringProperty.AUTHENTICATION.getDefaultValue(), false, new String[] {SqlAuthentication.NotSpecified.toString(),SqlAuthentication.SqlPassword.toString(),SqlAuthentication.ActiveDirectoryPassword.toString(),SqlAuthentication.ActiveDirectoryIntegrated.toString()}), }; //Properties that can only be set by using Properties. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithm.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithm.java index 540d72db1..3a6af227d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithm.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithm.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -29,13 +29,13 @@ abstract class SQLServerEncryptionAlgorithm { /** * Perform encryption of the plain text * @param plainText data to be encrypted - * @return cipher text + * @return cipher text after encryption */ abstract byte [] encryptData(byte [] plainText) throws SQLServerException; /** * Decrypt cipher text to plain text - * @param cipherText + * @param cipherText data to be decrypted * @return plain text after decryption */ abstract byte [] decryptData(byte [] cipherText) throws SQLServerException; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactory.java index f916f1228..e4ac50a39 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactory.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -32,7 +32,7 @@ abstract class SQLServerEncryptionAlgorithmFactory { * @param encryptionType specifies kind of encryption * @param encryptionAlgorithm name of encryption algorithm * @return created SQLServerEncryptionAlgorithm instance - * @throws SQLServerException + * @throws SQLServerException when an error occurs */ abstract SQLServerEncryptionAlgorithm create (SQLServerSymmetricKey columnEncryptionKey,SQLServerEncryptionType encryptionType,String encryptionAlgorithm) throws SQLServerException; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java index b1b87aac0..8527d288c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java index b6c5fe258..886c064ef 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java index 0b8f0fb2f..c8390dc9d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java index 5ab7c3738..5a428e5a4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java index 649feeda1..fbebd8965 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java index a8f15b0b2..844d6ec8e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java index 0a0c97d5f..d95d7ead2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -21,6 +21,11 @@ import java.text.MessageFormat; +/** + * + * This class represents metadata for a column. It is used in the ISQLServerDataRecord interface to pass column metadata to the table-valued parameter. + * + */ public class SQLServerMetaData { String columnName = null; @@ -34,6 +39,11 @@ public class SQLServerMetaData { static final int defaultSortOrdinal = -1; + /** + * Creates a new SQLServerMetaData + * @param columnName the name of the column + * @param sqlType the SQL type of the column + */ public SQLServerMetaData( String columnName, int sqlType) @@ -42,6 +52,13 @@ public SQLServerMetaData( this.javaSqlType = sqlType; } + /** + * creates a new SQLServerMetaData + * @param columnName the name of the column + * @param sqlType the SQL type of the column + * @param precision the precision of the column + * @param scale the scale of the column + */ public SQLServerMetaData( String columnName, int sqlType, @@ -54,6 +71,18 @@ public SQLServerMetaData( this.scale = scale; } + /** + * Creates a new SQLServerMetaData + * @param columnName the name of the column + * @param sqlType the sql type of the column + * @param precision the precision of the column + * @param scale the scale of the column + * @param useServerDefault specifies if this column should use the default server value; Default value is false. + * @param isUniqueKey indicates if the column in the table-valued parameter is unique; Default value is false. + * @param sortOrder indicates the sort order for a column; Default value is SQLServerSortOrder.Unspecified. + * @param sortOrdinal specifies ordinal of the sort column; sortOrdinal starts from 0; Default value is -1. + * @throws SQLServerException when an error occurs + */ public SQLServerMetaData( String columnName, int sqlType, @@ -75,6 +104,10 @@ public SQLServerMetaData( validateSortOrder(); } + /** + * Initializes a new instance of SQLServerMetaData from another SQLServerMetaData object. + * @param sqlServerMetaData the object passed to initialize a new instance of SQLServerMetaData + */ public SQLServerMetaData(SQLServerMetaData sqlServerMetaData) { this.columnName = sqlServerMetaData.columnName; @@ -87,41 +120,73 @@ public SQLServerMetaData(SQLServerMetaData sqlServerMetaData) this.sortOrdinal = sqlServerMetaData.sortOrdinal; } + /** + * + * @return Retrieves the column name. + */ public String getColumName() { return columnName; } + /** + * + * @return Retrieves the java sql type. + */ public int getSqlType() { return javaSqlType; } + /** + * + * @return retrieves the precision of the type passed to the column. + */ public int getPrecision() { return precision; } + /** + * + * @return retrieves the scale of the type passed to the column. + */ public int getScale() { return scale; } + /** + * + * @return returns whether the column uses the default server value. + */ public boolean useServerDefault() { return useServerDefault; } + /** + * + * @return retrieves the whether the column is unique. + */ public boolean isUniqueKey() { return isUniqueKey; } + /** + * + * @return retrieves the sort order. + */ public SQLServerSortOrder getSortOrder() { return sortOrder; } + /** + * + * @return retrieves the sort ordinal. + */ public int getSortOrdinal() { return sortOrdinal; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java index 74993d214..9f357ddd9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 7f4a33032..160f19b5c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -62,6 +62,11 @@ private synchronized static int nextInstanceID() baseID++; return baseID; } + + /** + * This is a helper function to provide an ID string suitable for tracing. + * @return traceID string + */ final public String toString() { return traceID; @@ -869,7 +874,7 @@ public T unwrap(Class iface) throws SQLException /** * Verify a supplied parameter index is valid * @param param the param index - * @throws SQLServerException + * @throws SQLServerException when an error occurs * @return boolean */ /*L2*/ public boolean isSigned(int param) throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java index f49c48dcd..9ef8c50fb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -64,6 +64,7 @@ public class SQLServerPooledConnection implements PooledConnection { /** * This is a helper function to provide an ID string suitable for tracing. + * @return traceID String */ public String toString() { @@ -78,7 +79,8 @@ private SQLServerConnection createNewConnection() throws SQLException /** * Creates an object handle for the physical connection that this PooledConnection object represents. - * @throws SQLException + * @throws SQLException when an error occurs + * @return a Connection object that is a handle to this PooledConnection object */ public Connection getConnection() throws SQLException { if (pcLogger.isLoggable(Level.FINER)) @@ -174,10 +176,6 @@ void notifyEvent(SQLServerException e) } } - /** - * Registers the given event listener so that it will be notified when an event occurs on this - * PooledConnection object. - */ public void addConnectionEventListener(ConnectionEventListener listener) { if (pcLogger.isLoggable(Level.FINER)) pcLogger.finer(toString() + safeCID()); @@ -187,9 +185,6 @@ public void addConnectionEventListener(ConnectionEventListener listener) { } } - /** - * Closes the physical connection that this PooledConnection object represents. - */ public void close() throws SQLException { if (pcLogger.isLoggable(Level.FINER)) pcLogger.finer(toString() + " Closing physical connection, " + safeCID()); @@ -213,9 +208,6 @@ public void close() throws SQLException { } - /** - * Remove a listener. - */ public void removeConnectionEventListener(ConnectionEventListener listener){ if (pcLogger.isLoggable(Level.FINER)) pcLogger.finer(toString() + safeCID()); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index dcda8af09..727edbc56 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -30,17 +30,17 @@ * SQLServerPreparedStatement provides JDBC prepared statement functionality. * SQLServerPreparedStatement provides methods for the user to supply parameters as any native * Java type and many Java object types. -*

  • +*

    * SQLServerPreparedStatement prepares a statement using SQL Server's sp_prepexec and re-uses the * returned statement handle for each subsequent execution of the statement (typically * using different parameters provided by the user) -*

  • +*

    * SQLServerPreparedStatement supports batching whereby a set of prepared statements are executed * in a single database round trip to improve runtime performance. -*

  • +*

    * 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. -*

  • +*

    */ public class SQLServerPreparedStatement extends SQLServerStatement implements ISQLServerPreparedStatement @@ -107,7 +107,7 @@ String getClassNameInternal() * @param nRSType the result set type * @param nRSConcur the result set concurrency * @param stmtColEncSetting the statement column encryption setting - * @throws SQLServerException + * @throws SQLServerException when an error occurs */ SQLServerPreparedStatement(SQLServerConnection conn, String sql, int nRSType, int nRSConcur, SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException @@ -261,8 +261,8 @@ private final boolean buildPreparedStrings(Parameter[] params, boolean renewDefi * Build the parameter type definitons for a JDBC prepared statement that will * be used to prepare the statement. * @param params the statement parameters - * @param renewDefinition - * @throws SQLServerException + * @param renewDefinition True if renewing parameter definition, False otherwise + * @throws SQLServerException when an error occurs. * @return the required data type defintions. */ private String buildParamTypeDefinitions(Parameter[] params, boolean renewDefinition) throws SQLServerException @@ -303,7 +303,7 @@ private String buildParamTypeDefinitions(Parameter[] params, boolean renewDefini /** * Execute a query. * - * @throws SQLServerException + * @throws SQLServerException when an error occurs * @return ResultSet */ public java.sql.ResultSet executeQuery() throws SQLServerException @@ -318,6 +318,7 @@ public java.sql.ResultSet executeQuery() throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "executeQuery"); return resultSet; } + /** * Execute a query without cursoring for metadata. * @@ -331,10 +332,6 @@ final java.sql.ResultSet executeQueryInternal() throws SQLServerException return resultSet; } - /** - * Execute a non query statement - * @return the update count of rows - */ public int executeUpdate() throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "executeUpdate"); @@ -373,7 +370,7 @@ public long executeLargeUpdate() throws SQLServerException /** * Execute a query or non query statement. - * @throws SQLServerException + * @throws SQLServerException when an error occurs * @return true if the statement returned a result set */ public boolean execute() throws SQLServerException @@ -1050,6 +1047,17 @@ public final void setBigDecimal(int n, BigDecimal x) throws SQLServerException 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 n 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 final void setBigDecimal(int n, BigDecimal x, int precision, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1059,6 +1067,19 @@ public final void setBigDecimal(int n, BigDecimal x, int precision, int scale) t 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 n 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 final void setBigDecimal(int n, BigDecimal x, int precision, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1068,6 +1089,15 @@ public final void setBigDecimal(int n, BigDecimal x, int precision, int scale, b 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 n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @throws SQLServerException when an error occurs + */ public final void setMoney(int n, BigDecimal x) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1077,6 +1107,17 @@ public final void setMoney(int n, BigDecimal x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "setMoney"); } + /** + * 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 n 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 final void setMoney(int n, BigDecimal x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1086,6 +1127,15 @@ public final void setMoney(int n, BigDecimal x, boolean forceEncrypt) throws SQL loggerExternal.exiting(getClassNameLogging(), "setMoney"); } + /** + * 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 n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @throws SQLServerException when an error occurs + */ public final void setSmallMoney(int n, BigDecimal x) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1095,6 +1145,17 @@ public final void setSmallMoney(int n, BigDecimal x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "setSmallMoney"); } + /** + * 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 n 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 final void setSmallMoney(int n, BigDecimal x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1142,6 +1203,17 @@ public final void setBoolean(int n, boolean x) throws SQLServerException 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 n 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 final void setBoolean(int n, boolean x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1160,6 +1232,17 @@ public final void setByte(int n, byte x) throws SQLServerException 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 n 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 final void setByte(int n, byte x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1178,6 +1261,18 @@ public final void setBytes(int n, byte x[]) throws SQLServerException 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 n 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 final void setBytes(int n, byte x[], boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1187,6 +1282,13 @@ public final void setBytes(int n, byte x[], boolean forceEncrypt) throws SQLServ loggerExternal.exiting(getClassNameLogging(), "setBytes"); } + /** + * Sets the designated parameter to the given String. The driver converts + * this to an SQL GUID + * @param index the first parameter is 1, the second is 2, ... + * @param guid string representation of the uniqueIdentifier value + * @throws SQLServerException when an error occurs + */ public final void setUniqueIdentifier(int index, String guid) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1196,6 +1298,15 @@ public final void setUniqueIdentifier(int index, String guid) throws SQLServerEx loggerExternal.exiting(getClassNameLogging(), "setUniqueIdentifier"); } + /** + * Sets the designated parameter to the given String. The driver converts + * this to an SQL GUID + * @param index 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 final void setUniqueIdentifier(int index, String guid, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1214,6 +1325,17 @@ public final void setDouble(int n, double x) throws SQLServerException 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 n 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 final void setDouble(int n, double x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1232,6 +1354,17 @@ public final void setFloat(int n, float x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "setFloat"); } + /** + * 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 n 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 final void setFloat(int n, float x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1250,6 +1383,17 @@ public final void setInt(int n, int value) throws SQLServerException 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 n 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 final void setInt(int n, int value, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1268,6 +1412,17 @@ public final void setLong(int n, long x) throws SQLServerException 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 n 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 final void setLong(int n, long x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1375,6 +1530,33 @@ public final void setObject(int parameterIndex, Object x, int targetSqlType, int 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 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 final void setObject(int parameterIndex, Object x, int targetSqlType, Integer precision, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1405,6 +1587,35 @@ public final void setObject(int parameterIndex, Object x, int targetSqlType, Int 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 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 final void setObject(int parameterIndex, Object x, int targetSqlType, Integer precision, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1515,6 +1726,17 @@ public final void setShort(int index, short x) throws SQLServerException 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 index 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 final void setShort(int index, short x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1533,6 +1755,20 @@ public final void setString(int index, String str) throws SQLServerException 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 index 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 final void setString(int index, String str, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1552,6 +1788,20 @@ public final void setNString(int parameterIndex, String value) throws SQLExcepti 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 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 SQLException when an error occurs + */ public final void setNString(int parameterIndex, String value, boolean forceEncrypt) throws SQLException { DriverJDBCVersion.checkSupportsJDBC4(); @@ -1571,6 +1821,14 @@ public final void setTime(int n, java.sql.Time x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "setTime"); } + /** + * Sets the designated parameter to the given java.sql.Time value + * + * @param n 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 final void setTime(int n, java.sql.Time x, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1580,6 +1838,16 @@ public final void setTime(int n, java.sql.Time x, int scale) throws SQLServerExc loggerExternal.exiting(getClassNameLogging(), "setTime"); } + /** + * Sets the designated parameter to the given java.sql.Time value + * + * @param n 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 final void setTime(int n, java.sql.Time x, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1598,6 +1866,14 @@ public final void setTimestamp(int n, java.sql.Timestamp x) throws SQLServerExc loggerExternal.exiting(getClassNameLogging(), "setTimestamp"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n 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 final void setTimestamp(int n, java.sql.Timestamp x, int scale) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1607,6 +1883,16 @@ public final void setTimestamp(int n, java.sql.Timestamp x, int scale) throws S loggerExternal.exiting(getClassNameLogging(), "setTimestamp"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n 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 final void setTimestamp(int n, java.sql.Timestamp x, int scale, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1616,6 +1902,13 @@ public final void setTimestamp(int n, java.sql.Timestamp x, int scale, boolean f loggerExternal.exiting(getClassNameLogging(), "setTimestamp"); } + /** + * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value + * + * @param n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @throws SQLException if an error occurs. + */ public final void setDateTimeOffset(int n, microsoft.sql.DateTimeOffset x) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1625,6 +1918,14 @@ public final void setDateTimeOffset(int n, microsoft.sql.DateTimeOffset x) thro loggerExternal.exiting(getClassNameLogging(), "setDateTimeOffset"); } + /** + * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value + * + * @param n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @param scale the scale of the column + * @throws SQLException when an error occurs + */ public final void setDateTimeOffset(int n, microsoft.sql.DateTimeOffset x, int scale) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1634,6 +1935,16 @@ public final void setDateTimeOffset(int n, microsoft.sql.DateTimeOffset x, int s loggerExternal.exiting(getClassNameLogging(), "setDateTimeOffset"); } + /** + * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value + * + * @param n 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 SQLException when an error occurs + */ public final void setDateTimeOffset(int n, microsoft.sql.DateTimeOffset x, int scale, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1652,6 +1963,13 @@ public final void setDate(int n, java.sql.Date x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "setDate"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @throws SQLServerException when an error occurs + */ public final void setDateTime(int n, java.sql.Timestamp x) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1661,6 +1979,15 @@ public final void setDateTime(int n, java.sql.Timestamp x) throws SQLServerExce loggerExternal.exiting(getClassNameLogging(), "setDateTime"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n 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 final void setDateTime(int n, java.sql.Timestamp x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1670,6 +1997,13 @@ public final void setDateTime(int n, java.sql.Timestamp x, boolean forceEncrypt) loggerExternal.exiting(getClassNameLogging(), "setDateTime"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n the first parameter is 1, the second is 2, ... + * @param x the parameter value + * @throws SQLServerException when an error occurs + */ public final void setSmallDateTime(int n, java.sql.Timestamp x) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1679,6 +2013,15 @@ public final void setSmallDateTime(int n, java.sql.Timestamp x) throws SQLServe loggerExternal.exiting(getClassNameLogging(), "setSmallDateTime"); } + /** + * Sets the designated parameter to the given java.sql.Timestamp value + * + * @param n 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 final void setSmallDateTime(int n, java.sql.Timestamp x, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -1688,16 +2031,32 @@ public final void setSmallDateTime(int n, java.sql.Timestamp x, boolean forceEnc loggerExternal.exiting(getClassNameLogging(), "setSmallDateTime"); } - public final void setStructured(int n, String tvpName, SQLServerDataTable tvpDataTbale) throws SQLServerException + /** + * Populates a table valued parameter with a data table + * + * @param n 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 final void setStructured(int n, String tvpName, SQLServerDataTable tvpDataTable) throws SQLServerException { tvpName = getTVPNameIfNull (n, tvpName); if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) - loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[]{n, tvpName, tvpDataTbale}); + loggerExternal.entering(getClassNameLogging(), "setStructured", new Object[]{n, tvpName, tvpDataTable}); checkClosed(); - setValue(n, JDBCType.TVP, tvpDataTbale, JavaType.TVP, tvpName); + setValue(n, JDBCType.TVP, tvpDataTable, JavaType.TVP, tvpName); loggerExternal.exiting(getClassNameLogging(), "setStructured"); } + /** + * Populates a table valued parameter with a data table + * + * @param n 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 final void setStructured(int n, String tvpName, ResultSet tvpResultSet) throws SQLServerException { tvpName = getTVPNameIfNull (n, tvpName); @@ -1708,6 +2067,14 @@ public final void setStructured(int n, String tvpName, ResultSet tvpResultSet) t loggerExternal.exiting(getClassNameLogging(), "setStructured"); } + /** + * Populates a table valued parameter with a data table + * + * @param n 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 final void setStructured(int n, String tvpName, ISQLServerDataRecord tvpBulkRecord) throws SQLServerException { tvpName = getTVPNameIfNull (n, tvpName); @@ -2238,6 +2605,24 @@ public final void setDate(int n, java.sql.Date x, java.util.Calendar cal) throws 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 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 n 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 final void setDate(int n, java.sql.Date x, java.util.Calendar cal, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2256,6 +2641,18 @@ public final void setTime(int n, java.sql.Time x, java.util.Calendar cal) throws 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 n 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 final void setTime(int n, java.sql.Time x, java.util.Calendar cal, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2274,6 +2671,19 @@ public final void setTimestamp(int n, java.sql.Timestamp x, java.util.Calendar c 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 n 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 final void setTimestamp(int n, java.sql.Timestamp x, java.util.Calendar cal, boolean forceEncrypt) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42.java index ce99fa33e..8b9c5b2c0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42Helper.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42Helper.java index 902b80057..5867bfd18 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42Helper.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement42Helper.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java index 776b6f184..0d41dcf36 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -377,9 +377,6 @@ protected Object[][] getContents() {"R_certificateStorePlatformInvalid", "Cannot set \"keyStoreAuthentication=CertificateStore\" on a Windows operating system."}, {"R_invalidKeyStoreFile", "Cannot parse \"{0}\". Either the file format is not valid or the password is not correct."}, // for JKS/PKCS {"R_invalidCEKCacheTtl", "Invalid column encryption key cache time-to-live specified. The columnEncryptionKeyCacheTtl value cannot be negative and timeUnit can only be DAYS, HOURS, MINUTES or SECONDS."}, - - // END OF MATERIAL TO LOCALIZE - {"R_sendTimeAsDateTimeForAE", "Use sendTimeAsDateTime=false with Always Encrypted."}, {"R_invalidServerCursorForTVP" , "Use different Connection for source ResultSet and prepared query, if selectMethod is set to cursor for Table-Valued Parameter."}, diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 1891b3482..8def1cbad 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -630,8 +630,8 @@ public void close() throws SQLServerException /** * Find a column index given a column name - * @param columnName the name - * @throws SQLServerException + * @param columnName the name of the column + * @throws SQLServerException If any errors occur. * @return the column index */ public int findColumn(String columnName) throws SQLServerException @@ -783,7 +783,7 @@ private final Column loadColumn(int index) throws SQLServerException /** * Clear result set warnings - * @throws SQLServerException + * @throws SQLServerException when an error occurs */ /*L0*/ public void clearWarnings() throws SQLServerException { @@ -2467,6 +2467,12 @@ public String getNString(String columnLabel) throws SQLException return value; } + /** + * Retrieves the value of the designated column in the current row of this ResultSet object as a microsoft.sql.datetimeoffset 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 SQLException when an error occurs + */ public String getUniqueIdentifier(int columnIndex) throws SQLException { loggerExternal.entering(getClassNameLogging(), "getUniqueIdentifier", columnIndex); @@ -2476,6 +2482,12 @@ public String getUniqueIdentifier(int columnIndex) throws SQLException return value; } + /** + * Retrieves the value of the designated column in the current row of this ResultSet object as a microsoft.sql.datetimeoffset 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 SQLException when an error occurs + */ public String getUniqueIdentifier(String columnLabel) throws SQLException { loggerExternal.entering(getClassNameLogging(), "getUniqueIdentifier", columnLabel); @@ -2561,6 +2573,12 @@ public java.sql.Timestamp getTimestamp(String colName, Calendar cal) throws SQLS 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 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 { loggerExternal.entering(getClassNameLogging(), "getDateTime", columnIndex); @@ -2570,6 +2588,12 @@ public java.sql.Timestamp getDateTime(int columnIndex) 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 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 { loggerExternal.entering(getClassNameLogging(), "getDateTime", columnName); @@ -2579,6 +2603,14 @@ public java.sql.Timestamp getDateTime(String columnName) throws SQLServerExcepti 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 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2589,6 +2621,14 @@ public java.sql.Timestamp getDateTime(int columnIndex, Calendar cal) throws SQLS 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 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2599,6 +2639,12 @@ public java.sql.Timestamp getDateTime(String colName, Calendar cal) throws SQLSe 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 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 { loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", columnIndex); @@ -2608,6 +2654,12 @@ public java.sql.Timestamp getSmallDateTime(int columnIndex) throws SQLServerExce 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 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 { loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", columnName); @@ -2617,6 +2669,13 @@ public java.sql.Timestamp getSmallDateTime(String columnName) throws SQLServerEx 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 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2627,6 +2686,13 @@ public java.sql.Timestamp getSmallDateTime(int columnIndex, Calendar cal) throws return value; } + /** + * + * @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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -2846,6 +2912,12 @@ public BigDecimal getBigDecimal(String columnName) throws SQLServerException return value; } + /** + * 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 BigDecimal getMoney(int columnIndex) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "getMoney", columnIndex); @@ -2855,6 +2927,12 @@ public BigDecimal getMoney(int columnIndex) throws SQLServerException return value; } + /** + * 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 { loggerExternal.entering(getClassNameLogging(), "getMoney", columnName); @@ -2864,6 +2942,12 @@ public BigDecimal getMoney(String columnName) throws SQLServerException return value; } + /** + * 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 { loggerExternal.entering(getClassNameLogging(), "getSmallMoney", columnIndex); @@ -2873,6 +2957,12 @@ public BigDecimal getSmallMoney(int columnIndex) throws SQLServerException return value; } + /** + * 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 { loggerExternal.entering(getClassNameLogging(), "getSmallMoney", columnName); @@ -3168,6 +3258,19 @@ public void updateBoolean(int index, boolean x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateBoolean"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3199,6 +3302,19 @@ public void updateByte(int index, byte x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateByte"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3231,6 +3347,19 @@ public void updateShort(int index, short x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateShort"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3263,6 +3392,19 @@ public void updateInt(int index, int x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateInt"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3295,6 +3437,19 @@ public void updateLong(int index, long x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateLong"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3327,6 +3482,19 @@ public void updateFloat(int index, float x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateFloat"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3359,6 +3527,19 @@ public void updateDouble(int index, double x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateDouble"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3375,6 +3556,17 @@ public void updateDouble(int index, double x, boolean forceEncrypt) throws SQLSe loggerExternal.exiting(getClassNameLogging(), "updateDouble"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3390,6 +3582,19 @@ public void updateMoney(int index, BigDecimal x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3405,6 +3610,17 @@ public void updateMoney(int index, BigDecimal x, boolean forceEncrypt) throws SQ loggerExternal.exiting(getClassNameLogging(), "updateMoney"); } + /** + * 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 is the column name + * @param x the new column value + * @throws SQLServerException If any errors occur. + */ public void updateMoney(String columnName, BigDecimal x) throws SQLServerException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3420,6 +3636,19 @@ public void updateMoney(String columnName, BigDecimal x) throws SQLServerExcepti loggerExternal.exiting(getClassNameLogging(), "updateMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3435,6 +3664,17 @@ public void updateMoney(String columnName, BigDecimal x, boolean forceEncrypt) t loggerExternal.exiting(getClassNameLogging(), "updateMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3450,6 +3690,19 @@ public void updateSmallMoney(int index, BigDecimal x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateSmallMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3465,6 +3718,17 @@ public void updateSmallMoney(int index, BigDecimal x, boolean forceEncrypt) thro loggerExternal.exiting(getClassNameLogging(), "updateSmallMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3480,6 +3744,19 @@ public void updateSmallMoney(String columnName, BigDecimal x) throws SQLServerEx loggerExternal.exiting(getClassNameLogging(), "updateSmallMoney"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3511,6 +3788,20 @@ public void updateBigDecimal(int index, BigDecimal x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateBigDecimal"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3529,6 +3820,22 @@ public void updateBigDecimal(int index, BigDecimal x, Integer precision, Integer loggerExternal.exiting(getClassNameLogging(), "updateBigDecimal"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3563,6 +3870,19 @@ public void updateString(int columnIndex, String stringValue) throws SQLServerEx loggerExternal.exiting(getClassNameLogging(), "updateString"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3596,6 +3916,21 @@ public void updateNString(int columnIndex, String nString) throws SQLException loggerExternal.exiting(getClassNameLogging(), "updateNString"); } + /** + * 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 SQLException when an error occurs + */ public void updateNString(int columnIndex, String nString, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3630,6 +3965,22 @@ public void updateNString(String columnLabel, String nString) throws SQLExceptio loggerExternal.exiting(getClassNameLogging(), "updateNString"); } + /** + * 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 SQLException when an error occurs + */ public void updateNString(String columnLabel, String nString, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3663,6 +4014,19 @@ public void updateBytes(int index, byte x[]) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateBytes"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3695,6 +4059,19 @@ public void updateDate(int index, java.sql.Date x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateDate"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3727,6 +4104,18 @@ public void updateTime(int index, java.sql.Time x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3745,6 +4134,20 @@ public void updateTime(int index, java.sql.Time x, Integer scale) throws SQLServ loggerExternal.exiting(getClassNameLogging(), "updateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3779,6 +4182,19 @@ public void updateTimestamp(int index, java.sql.Timestamp x) throws SQLServerExc loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3797,6 +4213,21 @@ public void updateTimestamp(int index, java.sql.Timestamp x, int scale) throws S loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3815,6 +4246,18 @@ public void updateTimestamp(int index, java.sql.Timestamp x, int scale, boolean loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3831,6 +4274,19 @@ public void updateDateTime(int index, java.sql.Timestamp x) throws SQLServerExce loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3849,6 +4305,21 @@ public void updateDateTime(int index, java.sql.Timestamp x, Integer scale) throw loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3867,6 +4338,18 @@ public void updateDateTime(int index, java.sql.Timestamp x, Integer scale, boole loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3883,6 +4366,19 @@ public void updateSmallDateTime(int index, java.sql.Timestamp x) throws SQLServe loggerExternal.exiting(getClassNameLogging(), "updateSmallDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3901,6 +4397,21 @@ public void updateSmallDateTime(int index, java.sql.Timestamp x, Integer scale) loggerExternal.exiting(getClassNameLogging(), "updateSmallDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3935,6 +4446,13 @@ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x) thro loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException when an error occurs + */ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x, Integer scale) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3953,6 +4471,15 @@ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x, Inte loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException when an error occurs + */ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x, Integer scale, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3971,6 +4498,17 @@ public void updateDateTimeOffset(int index, microsoft.sql.DateTimeOffset x, Inte loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException when an error occurs + */ public void updateUniqueIdentifier(int index, String x) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -3988,6 +4526,19 @@ public void updateUniqueIdentifier(int index, String x) throws SQLException loggerExternal.exiting(getClassNameLogging(), "updateUniqueIdentifier"); } + /** + * 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 SQLException when an error occurs + */ public void updateUniqueIdentifier(int index, String x, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4395,6 +4946,20 @@ public void updateObject(int index, Object x, int scale) throws SQLServerExcepti loggerExternal.exiting(getClassNameLogging(), "updateObject"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4406,6 +4971,22 @@ public void updateObject(int index, Object x, int precision, int scale) throws S loggerExternal.exiting(getClassNameLogging(), "updateObject"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4535,6 +5116,19 @@ public void updateBoolean(String columnName, boolean x) throws SQLServerExceptio loggerExternal.exiting(getClassNameLogging(), "updateBoolean"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4567,6 +5161,20 @@ public void updateByte(String columnName, byte x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateByte"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4599,6 +5207,19 @@ public void updateShort(String columnName, short x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateShort"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4631,6 +5252,19 @@ public void updateInt(String columnName, int x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateInt"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4663,6 +5297,19 @@ public void updateLong(String columnName, long x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateLong"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4695,6 +5342,19 @@ public void updateFloat(String columnName, float x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateFloat"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4727,6 +5387,19 @@ public void updateDouble(String columnName, double x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateDouble"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4759,6 +5432,20 @@ public void updateBigDecimal(String columnName, BigDecimal x) throws SQLServerEx loggerExternal.exiting(getClassNameLogging(), "updateBigDecimal"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4775,6 +5462,21 @@ public void updateBigDecimal(String columnName, BigDecimal x, boolean forceEncry loggerExternal.exiting(getClassNameLogging(), "updateBigDecimal"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4793,6 +5495,23 @@ public void updateBigDecimal(String columnName, BigDecimal x, Integer precision, loggerExternal.exiting(getClassNameLogging(), "updateBigDecimal"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4827,6 +5546,19 @@ public void updateString(String columnName, String x) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateString"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4859,6 +5591,20 @@ public void updateBytes(String columnName, byte x[]) throws SQLServerException loggerExternal.exiting(getClassNameLogging(), "updateBytes"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4891,6 +5637,19 @@ public void updateDate(String columnName, java.sql.Date x) throws SQLServerExcep loggerExternal.exiting(getClassNameLogging(), "updateDate"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4923,6 +5682,18 @@ public void updateTime(String columnName, java.sql.Time x) throws SQLServerExcep loggerExternal.exiting(getClassNameLogging(), "updateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4941,6 +5712,20 @@ public void updateTime(String columnName, java.sql.Time x, int scale) throws SQL loggerExternal.exiting(getClassNameLogging(), "updateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4975,6 +5760,19 @@ public void updateTimestamp(String columnName, java.sql.Timestamp x) throws SQLS loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -4993,6 +5791,21 @@ public void updateTimestamp(String columnName, java.sql.Timestamp x, int scale) loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5011,6 +5824,18 @@ public void updateTimestamp(String columnName, java.sql.Timestamp x, int scale, loggerExternal.exiting(getClassNameLogging(), "updateTimestamp"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5027,6 +5852,19 @@ public void updateDateTime(String columnName, java.sql.Timestamp x) throws SQLSe loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5045,6 +5883,21 @@ public void updateDateTime(String columnName, java.sql.Timestamp x, int scale) t loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5063,6 +5916,18 @@ public void updateDateTime(String columnName, java.sql.Timestamp x, int scale, b loggerExternal.exiting(getClassNameLogging(), "updateDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5079,6 +5944,19 @@ public void updateSmallDateTime(String columnName, java.sql.Timestamp x) throws loggerExternal.exiting(getClassNameLogging(), "updateSmallDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5097,6 +5975,21 @@ public void updateSmallDateTime(String columnName, java.sql.Timestamp x, int sca loggerExternal.exiting(getClassNameLogging(), "updateSmallDateTime"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5131,6 +6024,13 @@ public void updateDateTimeOffset(String columnName, microsoft.sql.DateTimeOffset loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5149,6 +6049,15 @@ public void updateDateTimeOffset(String columnName, microsoft.sql.DateTimeOffset loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException If any errors occur. + */ public void updateDateTimeOffset(String columnName, microsoft.sql.DateTimeOffset x, int scale, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5167,6 +6076,13 @@ public void updateDateTimeOffset(String columnName, microsoft.sql.DateTimeOffset loggerExternal.exiting(getClassNameLogging(), "updateDateTimeOffset"); } + /** + * 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 SQLException If any errors occur. + */ public void updateUniqueIdentifier(String columnName, String x) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5184,6 +6100,15 @@ public void updateUniqueIdentifier(String columnName, String x) throws SQLExcept loggerExternal.exiting(getClassNameLogging(), "updateUniqueIdentifier"); } + /** + * 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 SQLException If any errors occur. + */ public void updateUniqueIdentifier(String columnName, String x, boolean forceEncrypt) throws SQLException { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5218,6 +6143,20 @@ public void updateObject(String columnName, Object x, int scale) throws SQLServe loggerExternal.exiting(getClassNameLogging(), "updateObject"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) @@ -5235,6 +6174,22 @@ public void updateObject(String columnName, Object x, int precision, int scale) loggerExternal.exiting(getClassNameLogging(), "updateObject"); } + /** + * 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 { if(loggerExternal.isLoggable(java.util.logging.Level.FINER)) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet42.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet42.java index ef3884a8d..831aeeb47 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet42.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet42.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -31,6 +31,11 @@ */ public class SQLServerResultSet42 extends SQLServerResultSet implements ISQLServerResultSet42{ + /** + * Makes a new result set + * @param stmtIn the generating statement + * @throws SQLServerException when an error occurs + */ public SQLServerResultSet42(SQLServerStatement stmtIn) throws SQLServerException { super(stmtIn); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java index 86eb33c5d..65c14d2ba 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -347,7 +347,8 @@ public boolean isSigned(int column) throws SQLServerException /** * Returns true if the column is a SQLServer SparseColumnSet * @param column The column number - * @throws SQLServerException + * @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/SQLServerSQLXML.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java index c52fe1d75..3e74106ea 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -212,7 +212,7 @@ void checkWriteXML() throws SQLException /** * Return an input stream to read data from this SQLXML - * @throws SQLServerException + * @throws SQLException when an error occurs * @return the input stream to that contains the SQLXML data */ public InputStream getBinaryStream() throws SQLException @@ -226,8 +226,7 @@ public InputStream getBinaryStream() throws SQLException /** * Retrieves a stream that can be used to write to the SQLXML value that this SQLXML object represents * The user has to write the BOM for binary streams. - * @param pos the position in the SQLXML value at which to start writing - * @throws SQLException + * @throws SQLException when an error occurs * @return OutputStream */ public java.io.OutputStream setBinaryStream() throws SQLException diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java index b3746cf06..84ae775d1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -25,7 +25,7 @@ * SQLServerSavepoint implements JDBC 3.0 savepoints. A savepoint is checkpoint to * which a transaction can be rolled back. Savepoints are defined relative * to a connection. -*

  • +*

    * 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. */ @@ -72,6 +72,10 @@ public String getLabel() { return sName; } + /** + * Checks if the savepoint label is null + * @return true is the savepoint is named. Otherwise, false. + */ public boolean isNamed() { return sName!=null; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java index 9aa1633a9..52c09ee03 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -29,7 +29,10 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; - +/** + * Various SQLServer security utilities. + * + */ class SQLServerSecurityUtility { /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java index bb103a41d..d35a82e1f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -19,6 +19,11 @@ package com.microsoft.sqlserver.jdbc; +/** + * + * Specifies the sorting order + * + */ public enum SQLServerSortOrder { Ascending (0), Descending (1), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 9426f3d6c..835995069 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -36,15 +36,13 @@ * Documentation for specific public methods that are undocumented can be found under Sun's * standard JDBC documentation for class java.sql.Statement. Those methods are part of Sun's * standard JDBC documentation and therefore their documentation is not duplicated here. -*

  • - *
  • Implementation Notes - *
  • Fetching Result sets -*
  • + *

    Implementation Notes + *

    Fetching Result sets + *

    * The queries first rowset is available immediately after the executeQuery. The first rs.next() * does not make a server round trip. For non server side resultsets the entire result set is in * the rowset. For server side result sets the number of rows in the rowset is set with nFetchSize - *

  • - *
  • + *

    * 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. */ @@ -2023,11 +2021,11 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio } } // executeLargeBatch -/** - * Return the statement's connection - * @throws SQLServerException - * @return the connection - */ + /** + * Return the statement's connection + * @throws SQLServerException when an error occurs + * @return the connection + */ /*L0*/ public final java.sql.Connection getConnection() throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "getConnection"); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatementColumnEncryptionSetting.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatementColumnEncryptionSetting.java index f9ce5943f..4f317a45a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatementColumnEncryptionSetting.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatementColumnEncryptionSetting.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -19,9 +19,14 @@ package com.microsoft.sqlserver.jdbc; +/** + * Specifies how data will be sent and received when reading and writing encrypted columns. Depending on your specific query, performance impact + * may be reduced by bypassing the Always Encrypted driver processing when non-encrypted columns are being used. Note that these settings cannot + * be used to bypass encryption and gain access to plaintext data. + */ public enum SQLServerStatementColumnEncryptionSetting { /* - * if “Column Encryption Setting=Enabled” in the connection string, use Enabled. Otherwise, maps to Disabled. + * if "Column Encryption Setting=Enabled" in the connection string, use Enabled. Otherwise, maps to Disabled. */ UseConnectionSetting, diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKey.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKey.java index e4aba9f99..ddf81d399 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKey.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKey.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java index cadce87b9..bbac014af 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java index 6372d3a43..0f9d44327 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java index 671dbd557..de1d0ea06 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -35,12 +35,12 @@ * an XAResource object that can be used by a transaction manager to coordinate the work * done on this connection with the other participants in the distributed transaction. * - *

  • Because they extend the PooledConnection interface, XAConnection objects support all + *

    Because they extend the PooledConnection interface, XAConnection objects support all * the methods of PooledConnection objects. They are reusable physical connections to * an underlying data source and produce logical connection handles that can be passed * back to a JDBC application. * - *

  • XAConnection objects are produced by an XADataSource object. There is some similarity + *

    XAConnection objects are produced by an XADataSource object. There is some similarity * between ConnectionPoolDataSource objects and XADataSource objects in that they are * both implemented below a DataSource layer that is visible to the JDBC application. * This architecture allows sqlserver to support distributed transactions in a way diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java index 141e9c494..9d1671e9a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -75,6 +75,11 @@ final class XidImpl implements Xid { /*L0*/ public int getFormatId() { return formatId; } + + /** + * Used for tracing + * @return traceID string + */ public String toString() { return traceID; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SSPIAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/SSPIAuthentication.java index d128d5cf6..60eb80433 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SSPIAuthentication.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SSPIAuthentication.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ScrollWindow.java b/src/main/java/com/microsoft/sqlserver/jdbc/ScrollWindow.java index 330e3ca55..c524c4a57 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ScrollWindow.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ScrollWindow.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java index 406bdb54e..e9798ba16 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -161,6 +161,7 @@ final class SimpleInputStream extends BaseInputStream /** * Closes the stream releasing all resources held. + * @exception IOException if an I/O error occurs. */ public void close() throws IOException { @@ -181,6 +182,7 @@ public void close() throws IOException /** * Checks if we have EOS state. + * @exception IOException if an I/O error occurs. */ private final boolean isEOS() throws IOException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java index a233545e7..c24c26c21 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java index e4b66d239..ac4b52ac4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java index d57c2a6ad..d4d06881e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java index 1d7b34f18..fca4b22e4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java index 19a5f8741..1dd527712 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java index 800b4e99a..ef91c47f0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamPacket.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamPacket.java index ca74c7da6..ac7997895 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamPacket.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamPacket.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java index 432ccf294..dba94ce74 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java index 23cda8a81..86d442660 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java index a6e6e7b1a..89f0c3721 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java index 6831ccc06..d04d629d6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java index 0264d49fb..1869b2050 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -34,6 +34,19 @@ enum TVPType Null } +/** + * + * Implementation of Table-valued parameters which provide an easy way to marshal multiple rows of data from a client application to SQL Server + * without requiring multiple round trips or special server-side logic for processing the data. + *

    + * You can use table-valued parameters to encapsulate rows of data in a client application and send the data to the server in a single + * parameterized command. The incoming data rows are stored in a table variable that can then be operated on by using Transact-SQL. + *

    + * Column values in table-valued parameters can be accessed using standard Transact-SQL SELECT statements. Table-valued parameters are + * strongly typed and their structure is automatically validated. The size of table-valued parameters is limited only by server memory. + *

    + * You cannot return data in a table-valued parameter. Table-valued parameters are input-only; the OUTPUT keyword is not supported. + */ class TVP { String TVPName; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/UDTTDSHeader.java b/src/main/java/com/microsoft/sqlserver/jdbc/UDTTDSHeader.java index 09a77f8b0..9a1c89a8a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/UDTTDSHeader.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/UDTTDSHeader.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index 57e1d0c3d..8e090ea30 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -30,7 +30,7 @@ import java.io.*; /** - * Various driver utilites. + * Various driver utilities. * */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/XMLTDSHeader.java b/src/main/java/com/microsoft/sqlserver/jdbc/XMLTDSHeader.java index 023d2c95f..43c510b55 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/XMLTDSHeader.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/XMLTDSHeader.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java index f113a970c..b69aa4971 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java @@ -8,7 +8,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -2871,6 +2871,12 @@ enum Builder BITN (TDSType.BITN, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { if (1 != tdsReader.readUnsignedByte()) @@ -2883,6 +2889,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept INTN (TDSType.INTN, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { switch (tdsReader.readUnsignedByte()) @@ -2910,6 +2922,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept DATE (TDSType.DATEN, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssType = SSType.DATE; @@ -2921,6 +2939,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept BIGBINARY (TDSType.BIGBINARY, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.USHORTLENTYPE; @@ -2936,6 +2960,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept BIGVARBINARY (TDSType.BIGVARBINARY, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.maxLength = tdsReader.readUnsignedShort(); @@ -2961,6 +2991,12 @@ else if (typeInfo.maxLength <= DataTypes.SHORT_VARTYPE_MAX_BYTES)//for non-PLP t IMAGE (TDSType.IMAGE, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.LONGLENTYPE; @@ -2974,6 +3010,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept BIGCHAR (TDSType.BIGCHAR, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.USHORTLENTYPE; @@ -2989,6 +3031,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept BIGVARCHAR (TDSType.BIGVARCHAR, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.maxLength = tdsReader.readUnsignedShort(); @@ -3016,6 +3064,12 @@ else if (typeInfo.maxLength <= DataTypes.SHORT_VARTYPE_MAX_BYTES)//for non-PLP t TEXT (TDSType.TEXT, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.LONGLENTYPE; @@ -3031,6 +3085,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept NCHAR (TDSType.NCHAR, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.USHORTLENTYPE; @@ -3046,6 +3106,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept NVARCHAR (TDSType.NVARCHAR, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.maxLength = tdsReader.readUnsignedShort(); @@ -3072,6 +3138,12 @@ else if (typeInfo.maxLength <= DataTypes.SHORT_VARTYPE_MAX_BYTES && 0 == typeInf NTEXT (TDSType.NTEXT, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.ssLenType = SSLenType.LONGLENTYPE; @@ -3087,6 +3159,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept GUID (TDSType.GUID, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { int maxLength = tdsReader.readUnsignedByte(); @@ -3103,6 +3181,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept UDT (TDSType.UDT, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { UDTTDSHeader udtTDSHeader = new UDTTDSHeader(tdsReader); @@ -3134,6 +3218,12 @@ else if (typeInfo.maxLength <= DataTypes.SHORT_VARTYPE_MAX_BYTES) XML (TDSType.XML, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { XMLTDSHeader xmlTDSHeader = new XMLTDSHeader(tdsReader); @@ -3146,6 +3236,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept SQL_VARIANT(TDSType.SQL_VARIANT, new Strategy() { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { // Throw an exception and terminate the connection. Since we don't know @@ -3165,6 +3261,12 @@ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerExcept private interface Strategy { + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException; } @@ -3190,6 +3292,11 @@ private static final class FixedLenStrategy implements Strategy this.scale = scale; } + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) { typeInfo.ssLenType = SSLenType.FIXEDLENTYPE; @@ -3210,6 +3317,12 @@ private static final class DecimalNumericStrategy implements Strategy this.ssType = ssType; } + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { int maxLength = tdsReader.readUnsignedByte(); @@ -3239,6 +3352,12 @@ private static final class BigOrSmallByteLenStrategy implements Strategy this.smallBuilder = smallBuilder; } + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { switch (tdsReader.readUnsignedByte()) // maxLength @@ -3268,6 +3387,12 @@ private int getPrecision(String baseFormat, int scale) return baseFormat.length() + ((scale > 0) ? (1 + scale) : 0); } + /** + * Sets the fields of typeInfo to the correct values + * @param typeInfo the TypeInfo whos values are being corrected + * @param tdsReader the TDSReader used to set the fields of typeInfo to the correct values + * @throws SQLServerException when an error occurs + */ public void apply(TypeInfo typeInfo, TDSReader tdsReader) throws SQLServerException { typeInfo.scale = tdsReader.readUnsignedByte(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java index 37ba8149b..3c8091ec2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java @@ -14,7 +14,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/src/main/java/microsoft/sql/DateTimeOffset.java b/src/main/java/microsoft/sql/DateTimeOffset.java index 1b4619029..7eef9bbf8 100644 --- a/src/main/java/microsoft/sql/DateTimeOffset.java +++ b/src/main/java/microsoft/sql/DateTimeOffset.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -81,11 +81,23 @@ private DateTimeOffset(java.sql.Timestamp timestamp, int minutesOffset) assert 0 == this.utcMillis % 1000L : "utcMillis: " + this.utcMillis; } + /** + * Converts a java.sql.Timestamp value with an integer offset to the equivalent DateTimeOffset value + * @param timestamp A java.sql.Timestamp value + * @param minutesOffset An integer offset in minutes + * @return The DateTimeOffset value of the input timestamp and minutesOffset + */ public static DateTimeOffset valueOf(java.sql.Timestamp timestamp, int minutesOffset) { return new DateTimeOffset(timestamp, minutesOffset); } + /** + * Converts a java.sql.Timestamp value with a Calendar value to the equivalent DateTimeOffset value + * @param timestamp A java.sql.Timestamp value + * @param calendar A java.util.Calendar value + * @return The DateTimeOffset value of the input timestamp and calendar + */ public static DateTimeOffset valueOf(java.sql.Timestamp timestamp, Calendar calendar) { // (Re)Set the calendar's time to the value in the timestamp so that get(ZONE_OFFSET) and get(DST_OFFSET) report diff --git a/src/main/java/microsoft/sql/Types.java b/src/main/java/microsoft/sql/Types.java index a0db761e3..1553bce12 100644 --- a/src/main/java/microsoft/sql/Types.java +++ b/src/main/java/microsoft/sql/Types.java @@ -6,7 +6,7 @@ // Copyright(c) Microsoft Corporation // All rights reserved. // MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -37,13 +37,40 @@ private Types() * that identifies the Microsoft SQL type DATETIMEOFFSET. */ public static final int DATETIMEOFFSET = -155; + + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type STRUCTURED. + */ public static final int STRUCTURED = -153; + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type DATETIME. + */ public static final int DATETIME = -151; + + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type SMALLDATETIME. + */ public static final int SMALLDATETIME = -150; + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type MONEY. + */ public static final int MONEY = -148; + + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type SMALLMONEY. + */ public static final int SMALLMONEY = -146; + /* + * The constant in the Java programming language, sometimes referred to as a type code, + * that identifies the Microsoft SQL type GUID. + */ public static final int GUID = -145; } From e81e6ca5d1f5a3f6114d7c039f12dde19628345d Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Wed, 30 Nov 2016 14:22:02 -0800 Subject: [PATCH 27/42] when the TVP is used with stored procedure, this commit makes setObject() handle TVP with schema rather than [odb] --- .../sqlserver/jdbc/SQLServerParameterMetaData.java | 6 ++++++ .../sqlserver/jdbc/SQLServerPreparedStatement.java | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 160f19b5c..e37c08790 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -895,4 +895,10 @@ public T unwrap(Class iface) throws SQLException return false; } } + + String getTVPSchemaFromStoredProcedure(int param) throws SQLServerException{ + checkClosed(); + verifyParameterPosition(param); + return rsProcedureMeta.getString("SS_TYPE_SCHEMA_NAME"); + } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 727edbc56..a56c0239e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -2091,9 +2091,17 @@ String getTVPNameIfNull (int n, String tvpName) throws SQLServerException { if(this instanceof SQLServerCallableStatement) { - java.sql.ParameterMetaData pmd = this.getParameterMetaData(); + SQLServerParameterMetaData pmd = (SQLServerParameterMetaData) this.getParameterMetaData(); try { - tvpName = pmd.getParameterTypeName(n); + String tvpNameWithoutSchema = pmd.getParameterTypeName(n); + String tvpSchema = pmd.getTVPSchemaFromStoredProcedure(n); + + if (null != tvpSchema) { + tvpName = "[" + tvpSchema + "].[" + tvpNameWithoutSchema + "]"; + } + else { + tvpName = tvpNameWithoutSchema; + } } catch (SQLException e) { throw new SQLServerException(SQLServerException.getErrString("R_metaDataErrorForParameter"), null, 0 , e); } From 42b6547dd342b60c1d9e47c56aa35fd80fa97369 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Wed, 30 Nov 2016 17:44:58 -0800 Subject: [PATCH 28/42] make setObject() throw a clear exception for TVP when using with result set --- .../sqlserver/jdbc/SQLServerPreparedStatement.java | 11 +++++++++-- .../microsoft/sqlserver/jdbc/SQLServerResource.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index a56c0239e..a8daddd1e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -1461,9 +1461,16 @@ final void setObjectNoType(int index, Object obj, boolean forceEncrypt) throws S else { JavaType javaType = JavaType.of(obj); - if (JavaType.TVP == javaType) + if (JavaType.TVP == javaType){ tvpName = getTVPNameIfNull (index, null); //will return null if called from preparedStatement - targetJDBCType = javaType.getJDBCType(SSType.UNKNOWN, targetJDBCType); + + if((null == tvpName) && (obj instanceof ResultSet)){ + throw new SQLServerException( + SQLServerException.getErrString("R_TVPnotWorkWithSetObjectResultSet"), + null); + } + } + targetJDBCType = javaType.getJDBCType(SSType.UNKNOWN, targetJDBCType); if(JDBCType.UNKNOWN == targetJDBCType){ if(obj instanceof java.util.UUID){ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java index ce15e1e6b..c5820df7d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java @@ -380,7 +380,7 @@ protected Object[][] getContents() {"R_invalidCEKCacheTtl", "Invalid column encryption key cache time-to-live specified. The columnEncryptionKeyCacheTtl value cannot be negative and timeUnit can only be DAYS, HOURS, MINUTES or SECONDS."}, {"R_sendTimeAsDateTimeForAE", "Use sendTimeAsDateTime=false with Always Encrypted."}, {"R_invalidServerCursorForTVP" , "Use different Connection for source ResultSet and prepared query, if selectMethod is set to cursor for Table-Valued Parameter."}, - + {"R_TVPnotWorkWithSetObjectResultSet" , "setObject() with ResultSet is not supported for Table-Valued Parameter. Please use setStructured()"}, }; } From c9abbd889f3f3f61e27125ed5d066d0b7e750727 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Thu, 1 Dec 2016 14:30:18 +0100 Subject: [PATCH 29/42] Upgrade azure-keyvault to 0.9.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c2e57e571..996fcd037 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ com.microsoft.azure azure-keyvault - 0.9.3 + 0.9.7 From c6a054a3251d07e0d095a126445089510d68eccd Mon Sep 17 00:00:00 2001 From: v-afrafi Date: Thu, 1 Dec 2016 09:33:01 -0800 Subject: [PATCH 30/42] Removed unused imports and wildcards --- .../com/microsoft/sqlserver/jdbc/Column.java | 3 +- .../com/microsoft/sqlserver/jdbc/DDC.java | 27 ++++++-- .../microsoft/sqlserver/jdbc/DataTypes.java | 22 ++++-- .../sqlserver/jdbc/FailOverInfo.java | 4 +- .../sqlserver/jdbc/FailOverMapSingleton.java | 5 +- .../microsoft/sqlserver/jdbc/IOBuffer.java | 69 +++++++++++++++---- .../jdbc/ISQLServerCallableStatement.java | 2 +- .../sqlserver/jdbc/ISQLServerConnection.java | 2 +- .../sqlserver/jdbc/ISQLServerDataRecord.java | 2 - .../sqlserver/jdbc/ISQLServerDataSource.java | 2 +- .../jdbc/ISQLServerPreparedStatement.java | 2 +- .../sqlserver/jdbc/ISQLServerResultSet.java | 2 +- .../sqlserver/jdbc/KerbAuthentication.java | 26 +++++-- .../sqlserver/jdbc/KeyVaultCredential.java | 2 + .../sqlserver/jdbc/PLPInputStream.java | 3 +- .../microsoft/sqlserver/jdbc/Parameter.java | 20 ++++-- .../sqlserver/jdbc/ReaderInputStream.java | 9 ++- .../sqlserver/jdbc/SQLCollation.java | 6 +- .../sqlserver/jdbc/SQLServerBlob.java | 16 +++-- .../jdbc/SQLServerBulkCSVFileRecord.java | 5 +- .../jdbc/SQLServerCallableStatement.java | 29 ++++++-- .../sqlserver/jdbc/SQLServerClob.java | 22 ++++-- ...ColumnEncryptionAzureKeyVaultProvider.java | 5 +- ...umnEncryptionCertificateStoreProvider.java | 4 -- ...rColumnEncryptionJavaKeyStoreProvider.java | 6 +- .../sqlserver/jdbc/SQLServerConnection.java | 50 +++++++++++--- .../SQLServerConnectionPoolDataSource.java | 10 +-- .../jdbc/SQLServerConnectionPoolProxy.java | 23 +++++-- .../sqlserver/jdbc/SQLServerDataColumn.java | 8 --- .../sqlserver/jdbc/SQLServerDataSource.java | 18 +++-- .../SQLServerDataSourceObjectFactory.java | 9 +-- .../sqlserver/jdbc/SQLServerDataTable.java | 9 ++- .../jdbc/SQLServerDatabaseMetaData.java | 14 ++-- .../sqlserver/jdbc/SQLServerDriver.java | 15 ++-- ...LServerEncryptionAlgorithmFactoryList.java | 1 - .../sqlserver/jdbc/SQLServerException.java | 4 +- .../sqlserver/jdbc/SQLServerNClob.java | 6 +- .../jdbc/SQLServerParameterMetaData.java | 9 ++- .../jdbc/SQLServerPooledConnection.java | 13 ++-- .../jdbc/SQLServerPreparedStatement.java | 23 +++++-- .../sqlserver/jdbc/SQLServerResource.java | 2 +- .../sqlserver/jdbc/SQLServerResultSet.java | 26 +++++-- .../jdbc/SQLServerResultSetMetaData.java | 2 +- .../sqlserver/jdbc/SQLServerSQLXML.java | 46 ++++++++++--- .../sqlserver/jdbc/SQLServerSavepoint.java | 2 +- .../jdbc/SQLServerSecurityUtility.java | 4 -- .../sqlserver/jdbc/SQLServerStatement.java | 19 +++-- .../jdbc/SQLServerSymmetricKeyCache.java | 7 +- .../sqlserver/jdbc/SQLServerXAConnection.java | 10 +-- .../sqlserver/jdbc/SQLServerXADataSource.java | 11 +-- .../sqlserver/jdbc/SQLServerXAResource.java | 20 ++++-- .../sqlserver/jdbc/SimpleInputStream.java | 3 +- .../com/microsoft/sqlserver/jdbc/TVP.java | 6 +- .../com/microsoft/sqlserver/jdbc/Util.java | 20 ++++-- .../com/microsoft/sqlserver/jdbc/dtv.java | 35 ++++++++-- .../microsoft/sqlserver/jdbc/tdsparser.java | 3 +- 56 files changed, 503 insertions(+), 220 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java index 35b22ec70..75c1b6c72 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java @@ -19,9 +19,8 @@ package com.microsoft.sqlserver.jdbc; -import java.math.BigDecimal; import java.text.MessageFormat; -import java.util.*; +import java.util.Calendar; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java index 3cf9fe55f..e47e95307 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java @@ -18,15 +18,28 @@ package com.microsoft.sqlserver.jdbc; -import java.math.*; -import java.io.*; -import java.nio.charset.*; -import java.nio.*; -import java.text.*; -import java.util.*; - import static java.nio.charset.StandardCharsets.US_ASCII; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.RoundingMode; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.text.MessageFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + /** * Utility class for all Data Dependant Conversions (DDC). */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java index 3c60dc157..560ac5a6c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java @@ -19,12 +19,22 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.math.*; -import java.sql.*; -import java.text.*; -import java.util.*; -import java.time.*; +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.NClob; +import java.sql.ResultSet; +import java.text.MessageFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.util.EnumMap; +import java.util.EnumSet; enum TDSType diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java index c9afc8acf..772fecbd1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java @@ -18,8 +18,8 @@ package com.microsoft.sqlserver.jdbc; -import java.util.logging.*; -import java.text.*; +import java.text.MessageFormat; +import java.util.logging.Level; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java index e9d593551..a39e3dd96 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java @@ -19,9 +19,8 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; - -import java.util.logging.*; +import java.util.HashMap; +import java.util.logging.Level; final class FailoverMapSingleton diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 6f0d7e1df..cef731393 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -18,23 +18,66 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.nio.*; -import java.nio.channels.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.RoundingMode; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; import java.nio.charset.Charset; -import java.net.*; -import java.math.*; -import java.util.concurrent.*; -import java.util.*; -import java.util.logging.*; +import java.security.KeyStore; +import java.security.Provider; +import java.security.Security; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.sql.Timestamp; import java.text.MessageFormat; -import java.time.*; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.Map.Entry; -import javax.net.ssl.*; +import java.util.Set; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; import javax.xml.bind.DatatypeConverter; -import java.security.*; -import java.security.cert.*; -import java.sql.Timestamp; final class TDS { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java index 04fc3f00a..071cfeaa8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java @@ -19,7 +19,7 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.SQLException; /** * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java index 29c9d33a7..302ab941f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java @@ -18,8 +18,8 @@ package com.microsoft.sqlserver.jdbc; -import java.util.UUID; import java.sql.SQLException; +import java.util.UUID; /** * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index 8c35f5fa3..98c9ab1ce 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -19,8 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.util.Set; - /** * 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java index e921948ef..d6c7cf471 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java @@ -18,7 +18,7 @@ package com.microsoft.sqlserver.jdbc; -import javax.sql.*; +import javax.sql.CommonDataSource; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java index 1712117d9..b9ecf9d87 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java @@ -19,7 +19,7 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.SQLException; public interface ISQLServerPreparedStatement extends java.sql.PreparedStatement, ISQLServerStatement { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java index b53e2f311..edd6a725e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java @@ -19,7 +19,7 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.SQLException; public interface ISQLServerResultSet extends java.sql.ResultSet { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java index cf4af0233..2d3efdaf7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java @@ -18,13 +18,27 @@ package com.microsoft.sqlserver.jdbc; -import java.util.logging.*; -import org.ietf.jgss.*; -import javax.security.auth.Subject; -import java.util.*; -import javax.security.auth.login.*; import java.net.IDN; -import java.security.*; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; + +import javax.security.auth.Subject; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; + +import org.ietf.jgss.GSSContext; +import org.ietf.jgss.GSSCredential; +import org.ietf.jgss.GSSException; +import org.ietf.jgss.GSSManager; +import org.ietf.jgss.GSSName; +import org.ietf.jgss.Oid; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java index 032b6db78..690a7ee8f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultCredential.java @@ -20,8 +20,10 @@ package com.microsoft.sqlserver.jdbc; import java.util.Map; + import org.apache.http.Header; import org.apache.http.message.BasicHeader; + import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; import com.microsoft.windowsazure.core.pipeline.filter.ServiceRequestContext; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java index 9757ebe77..40902f5ea 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java @@ -19,7 +19,8 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; /** * PLPInputStream is an InputStream implementation that reads from a TDS PLP stream. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java index 62c3de7a6..e18407245 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java @@ -18,13 +18,23 @@ package com.microsoft.sqlserver.jdbc; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; import java.math.BigDecimal; -import java.io.*; -import java.sql.*; -import java.util.*; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.ResultSet; import java.text.MessageFormat; - -import java.time.*; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.util.Calendar; +import java.util.Locale; /** * Parameter represents a JDBC parameter value that is supplied with a prepared or callable diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java index f0dd4749f..431ca2374 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java @@ -18,9 +18,12 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.nio.charset.*; -import java.nio.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; import java.text.MessageFormat; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java index 76f1e79a9..1b4eb3f8d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java @@ -19,10 +19,12 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; +import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; -import java.util.*; import java.text.MessageFormat; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java index f405f9818..482e888fd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java @@ -18,11 +18,17 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.io.*; -import java.text.*; -import java.util.*; -import java.util.logging.*; +import java.io.ByteArrayInputStream; +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.logging.Level; +import java.util.logging.Logger; /** * SQLServerBlob represents a binary LOB object and implements a java.sql.Blob. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java index 5b04412b8..d7f97ba80 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java @@ -28,8 +28,9 @@ import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.MessageFormat; -import java.time.*; -import java.time.format.*; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Iterator; import java.util.Map; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index 98ce85512..05bf97273 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -19,15 +19,30 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; import java.math.BigDecimal; -import java.util.Calendar; -import java.util.UUID; -import java.io.*; -import java.net.*; -import java.util.ArrayList; +import java.net.URL; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLXML; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; import java.text.MessageFormat; -import java.util.regex.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java index 2b84098ff..b203802f8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java @@ -18,14 +18,24 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.io.*; -import java.text.*; -import java.util.*; -import java.util.logging.*; - import static java.nio.charset.StandardCharsets.US_ASCII; +import java.io.BufferedInputStream; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.Serializable; +import java.io.StringReader; +import java.io.UnsupportedEncodingException; +import java.sql.Clob; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * SQLServerClob represents a character LOB object and implements java.sql.Clob. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index 6489bf9d0..11ff89d84 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -19,6 +19,8 @@ package com.microsoft.sqlserver.jdbc; +import static java.nio.charset.StandardCharsets.UTF_16LE; + import java.net.URI; import java.net.URISyntaxException; import java.nio.ByteBuffer; @@ -29,9 +31,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; -import static java.nio.charset.StandardCharsets.UTF_16LE; - import org.apache.http.impl.client.HttpClientBuilder; + import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.KeyVaultClientImpl; import com.microsoft.azure.keyvault.models.KeyBundle; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index 438623f3f..d429baad1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -21,10 +21,8 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; @@ -40,8 +38,6 @@ import javax.xml.bind.DatatypeConverter; -import com.microsoft.sqlserver.jdbc.AuthenticationJNI; - /** * The implementation of the key store provider for the Windows Certificate Store. This class enables using keys stored in the Windows Certificate Store as column master keys. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index 5818612d5..df3b918af 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -20,6 +20,8 @@ package com.microsoft.sqlserver.jdbc; +import static java.nio.charset.StandardCharsets.UTF_16LE; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -43,10 +45,6 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import com.microsoft.sqlserver.jdbc.KeyStoreProviderCommon; - -import static java.nio.charset.StandardCharsets.UTF_16LE; - /** * * The implementation of the key store provider for Java Key Store. This class enables using certificates stored in the Java keystore as column master keys. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index d7a9b4e5b..a63966fd9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -18,21 +18,49 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.*; -import java.sql.*; -import java.util.*; +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.Date; -import javax.sql.*; -import javax.xml.bind.DatatypeConverter; -import java.util.logging.*; -import java.text.*; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; -import static java.nio.charset.StandardCharsets.UTF_16LE; +import javax.sql.XAConnection; +import javax.xml.bind.DatatypeConverter; /** * SQLServerConnection implements a JDBC connection to SQL Server. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java index d5c174291..574f2ea6e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java @@ -19,10 +19,12 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import javax.sql.*; -import javax.naming.*; -import java.util.logging.*; +import java.sql.SQLException; +import java.util.logging.Level; + +import javax.naming.Reference; +import javax.sql.ConnectionPoolDataSource; +import javax.sql.PooledConnection; /** * SQLServerConnectionPoolDataSource provides physical database connections for connection pool managers. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java index 58464dc02..aacc23b6b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java @@ -18,11 +18,26 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.util.*; -import java.util.logging.*; +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.text.*; +import java.util.logging.Level; /** * SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java index a665901a3..0f9d3ead2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java @@ -19,14 +19,6 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.text.MessageFormat; -import java.util.Map.Entry; - /** * This class represents a column of the in-memory data table represented by SQLServerDataTable. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index cd0d34173..646030fdb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -19,12 +19,18 @@ package com.microsoft.sqlserver.jdbc; -import javax.sql.*; -import java.sql.*; -import java.io.*; -import java.util.*; -import java.util.logging.*; -import javax.naming.*; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.Enumeration; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.naming.Reference; +import javax.naming.StringRefAddr; +import javax.sql.DataSource; /** * This datasource lists properties specific for the SQLServerConnection class. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 62f8ecaaf..c4207301d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -20,10 +20,11 @@ package com.microsoft.sqlserver.jdbc; -import javax.naming.*; -import javax.naming.spi.*; -import java.util.*; -import java.lang.reflect.*; +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.spi.ObjectFactory; /** * SQLServerDataSourceObjectFactory is an object factory to materialize datasources from JNDI. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index 2a08c62f1..dc9cc3525 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -19,11 +19,16 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; import java.math.BigDecimal; import java.text.MessageFormat; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Map.Entry; -import java.time.*; +import java.util.UUID; public final class SQLServerDataTable { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 49f53e5e0..f887cb57e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -19,10 +19,16 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.util.*; -import java.text.*; -import java.util.logging.*; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DriverPropertyInfo; +import java.sql.ResultSet; +import java.sql.RowIdLifetime; +import java.sql.SQLException; +import java.text.MessageFormat; +import java.util.EnumMap; +import java.util.Properties; +import java.util.logging.Level; /** * SQLServerDatabaseMetaData provides JDBC database meta data. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index e7ab36649..9213c677c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -18,11 +18,16 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.util.*; -import java.text.*; -import java.util.logging.*; -import java.net.IDN; +import java.sql.DriverManager; +import java.sql.DriverPropertyInfo; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.text.MessageFormat; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; /** * SQLServerDriver implements the java.sql.Driver for SQLServerConnect. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java index 8527d288c..cc8b79b71 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java @@ -21,7 +21,6 @@ import java.text.MessageFormat; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java index c8390dc9d..e6e2aa0e2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java @@ -19,8 +19,8 @@ package com.microsoft.sqlserver.jdbc; import java.text.MessageFormat; -import java.util.*; -import java.util.logging.*; +import java.util.UUID; +import java.util.logging.Level; /** * SQLServerException is thrown from any point in the driver that throws a java.sql.SQLException. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java index 9f357ddd9..594326a20 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java @@ -18,9 +18,9 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.io.*; -import java.util.logging.*; +import java.io.UnsupportedEncodingException; +import java.sql.NClob; +import java.util.logging.Logger; /** * SQLServerNClob represents a National Character Set LOB object and implements java.sql.NClob. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index e37c08790..f47423e32 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -18,15 +18,18 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.ParameterMetaData; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.text.*; - /** * SQLServerParameterMetaData provides JDBC 3.0 meta data for prepared statement parameters. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java index 9ef8c50fb..c090d0174 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java @@ -19,10 +19,15 @@ package com.microsoft.sqlserver.jdbc; -import javax.sql.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Vector; +import java.util.logging.Level; + +import javax.sql.ConnectionEvent; +import javax.sql.ConnectionEventListener; +import javax.sql.PooledConnection; +import javax.sql.StatementEventListener; /** * SQLServerPooledConnection represents a database physical connection in a connection pool. If provides diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index a56c0239e..b846905ad 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -19,12 +19,25 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.sql.BatchUpdateException; +import java.sql.NClob; +import java.sql.ParameterMetaData; +import java.sql.ResultSet; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLXML; +import java.sql.Statement; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; +import java.util.logging.Level; /** * SQLServerPreparedStatement provides JDBC prepared statement functionality. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java index ce15e1e6b..57817ba4e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java @@ -18,7 +18,7 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; +import java.util.ListResourceBundle; /** * A simple resource bundle containing the strings for localizing. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 8def1cbad..25132a809 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -19,12 +19,26 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; -import java.text.*; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.text.MessageFormat; +import java.util.Calendar; +import java.util.logging.Level; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java index 65c14d2ba..332e7fce6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java @@ -18,7 +18,7 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.SQLException; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java index 3e74106ea..b2451e991 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java @@ -18,21 +18,45 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.StringReader; +import java.sql.SQLException; +import java.text.MessageFormat; import javax.xml.XMLConstants; -import javax.xml.parsers.*; -import javax.xml.transform.dom.*; -import javax.xml.transform.sax.*; -import javax.xml.transform.*; -import org.w3c.dom.*; -import java.text.*; -import org.xml.sax.*; -import javax.xml.transform.stax.*; -import javax.xml.stream.*; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stax.StAXResult; +import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java index 84ae775d1..6ebee2e01 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java @@ -18,7 +18,7 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; +import java.sql.Savepoint; import java.text.MessageFormat; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java index 52c09ee03..bae31b07c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java @@ -20,11 +20,7 @@ package com.microsoft.sqlserver.jdbc; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.text.MessageFormat; -import java.util.Arrays; import java.util.Iterator; -import java.util.concurrent.TimeUnit; - import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 2f2a866d6..e2858f27d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -19,13 +19,20 @@ package com.microsoft.sqlserver.jdbc; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.sql.*; -import java.util.*; +import java.sql.BatchUpdateException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Statement; import java.text.MessageFormat; -import java.util.regex.*; -import java.util.logging.*; +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Stack; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * SQLServerStatment provides the basic implementation of JDBC statement functionality. It also diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java index bbac014af..a47f0bbfb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java @@ -19,6 +19,9 @@ package com.microsoft.sqlserver.jdbc; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.concurrent.TimeUnit.SECONDS; + import java.text.MessageFormat; import java.util.List; import java.util.concurrent.ConcurrentHashMap; @@ -26,10 +29,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; -import static java.nio.charset.StandardCharsets.UTF_8; - -import static java.util.concurrent.TimeUnit.*; - import javax.xml.bind.DatatypeConverter; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java index 0f9d44327..739da5bd8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java @@ -19,11 +19,13 @@ package com.microsoft.sqlserver.jdbc; -import javax.sql.*; -import java.sql.*; +import java.sql.SQLException; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.sql.XAConnection; import javax.transaction.xa.XAResource; -import java.util.logging.*; -import java.util.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java index de1d0ea06..48d9acbfd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java @@ -18,10 +18,13 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; -import javax.sql.*; -import java.util.logging.*; -import javax.naming.*; +import java.sql.SQLException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.naming.Reference; +import javax.sql.XAConnection; +import javax.sql.XADataSource; /** * SQLServerXADataSource provides database connections for use in distributed (XA) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java index 9d1671e9a..8dbaf3e2f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java @@ -18,14 +18,20 @@ package com.microsoft.sqlserver.jdbc; -import java.sql.*; - -import javax.transaction.xa.*; - -import java.util.Vector; -import java.util.Properties; -import java.util.logging.*; +import java.sql.CallableStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; import java.text.MessageFormat; +import java.util.Properties; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; /** * Transaction id implementation used to recover transactions. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java index e9798ba16..fa01452e1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SimpleInputStream.java @@ -19,7 +19,8 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; /** * SimpleInputStream is an InputStream implementation that reads from TDS. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java index 1869b2050..97b9f76d4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/TVP.java @@ -19,12 +19,14 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; -import java.util.Map.Entry; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.text.MessageFormat; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; enum TVPType { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index 8e090ea30..c720bc42d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -19,15 +19,21 @@ package com.microsoft.sqlserver.jdbc; -import java.util.*; -import java.text.DecimalFormat; -import java.util.Map.Entry; -import java.text.MessageFormat; import java.math.BigDecimal; import java.math.BigInteger; -import java.net.*; -import java.util.logging.*; -import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.DecimalFormat; +import java.text.MessageFormat; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.Logger; /** * Various driver utilities. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java index b69aa4971..d94a38c62 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java @@ -21,17 +21,38 @@ package com.microsoft.sqlserver.jdbc; -import java.io.*; -import java.util.*; -import java.math.*; +import static java.nio.charset.StandardCharsets.UTF_16LE; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.MathContext; +import java.math.RoundingMode; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; -import java.sql.*; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.SQLException; +import java.sql.Timestamp; import java.text.MessageFormat; -import java.time.*; - -import static java.nio.charset.StandardCharsets.UTF_16LE; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.util.Calendar; +import java.util.EnumMap; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.Map; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import java.util.UUID; import com.microsoft.sqlserver.jdbc.JavaType.SetterConversionAE; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java index 3c8091ec2..f958f288c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java @@ -26,7 +26,8 @@ package com.microsoft.sqlserver.jdbc; -import java.util.logging.*; +import java.util.logging.Level; +import java.util.logging.Logger; /** * The top level TDS parser class. From a10c556eced7e8650635467e044f0a0fa389b0aa Mon Sep 17 00:00:00 2001 From: v-afrafi Date: Thu, 1 Dec 2016 09:46:38 -0800 Subject: [PATCH 31/42] removed unused imports for DatetimeOffset Class --- src/main/java/microsoft/sql/DateTimeOffset.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/microsoft/sql/DateTimeOffset.java b/src/main/java/microsoft/sql/DateTimeOffset.java index 7eef9bbf8..455e3fac2 100644 --- a/src/main/java/microsoft/sql/DateTimeOffset.java +++ b/src/main/java/microsoft/sql/DateTimeOffset.java @@ -18,7 +18,9 @@ package microsoft.sql; -import java.util.*; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; /** * A Java class for accessing values of the SQL Server DATETIMEOFFSET data type. From bfbad5cc565bf7dc27591bf0b79019cbffd8d87e Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 1 Dec 2016 11:56:10 -0800 Subject: [PATCH 32/42] Upgrade azure-keyvault to 0.9.7 for ant --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index a6577750b..c2194d7b1 100644 --- a/build.xml +++ b/build.xml @@ -13,7 +13,7 @@ - + From acf4bb3eeb84bd92e1f9260dd268b8bd42ec8a40 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 1 Dec 2016 14:20:29 -0800 Subject: [PATCH 33/42] adds gradle build script and gradle section in README --- README.md | 8 ++++++- build.gradle | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 build.gradle diff --git a/README.md b/README.md index 7a4eebed6..025c86715 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,16 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. * Maven: 1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance. - 2. Run one of the commands below to build a JDBC 4.1 compliant jar or JDBC 4.2 compliant jar in the \build directory. + 2. Run one of the commands below to build a JDBC 4.1 compliant jar or JDBC 4.2 compliant jar in the \target directory. * Run `mvn install -Pbuild41`. This creates JDBC 4.1 compliant jar in \target directory * Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory +* Gradle: + 1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance. + 2. Run one of the commands below to build a JDBC 4.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 + ### AppVeyor Build Status [![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc) diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..9fdda615d --- /dev/null +++ b/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'java' + +archivesBaseName = 'mssql-jdbc' +version = '6.1.0' + +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" + excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java' + + sourceCompatibility = 1.7 + targetCompatibility = 1.7 +} + +if(build == "build42") { + jar.archiveName = "${archivesBaseName}-${version}.jre8.jar" + excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java' + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 +} + +jar { + manifest { + attributes 'Title': "Microsoft JDBC Driver ${version} for SQL Server", + 'Version': version, + 'Vendor': 'Microsoft Corporation' + } +} + +sourceSets { + main { + java { + srcDirs 'src/main/java' + exclude excludedFile + } + + resources { + srcDirs "$projectDir" + include 'META-INF/services/java.sql.Driver' + } + } +} + +//Get dependencies from Maven central repository +repositories { + mavenCentral() +} + +dependencies { + compile 'com.microsoft.azure:azure-keyvault:0.9.7', + 'junit:junit:4.12' +} + + From d4558017324c6ae8ae11345b5059aa021d5d05aa Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Thu, 1 Dec 2016 14:25:50 -0800 Subject: [PATCH 34/42] adds more information about Gradle in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 025c86715..d5d69022d 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ What's coming next? We will look into adding a more comprehensive set of tests, ## Build ### Prerequisites * Java 8 -* [Ant](http://ant.apache.org/manual/install.html) (with [Ivy](https://ant.apache.org/ivy/download.cgi)) or [Maven](http://maven.apache.org/download.cgi) +* [Ant](http://ant.apache.org/manual/install.html) (with [Ivy](https://ant.apache.org/ivy/download.cgi)), [Maven](http://maven.apache.org/download.cgi) or [Gradle](https://gradle.org/gradle-download/) * An instance of SQL Server or Azure SQL Database that you can connect to. ### Build the JAR files The build automatically triggers 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://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) for your SQL Server or Azure SQL Database instance. -To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. You can choose to build a JDBC 4.1 compliant jar file (for use with JRE 7) and/or a JDBC 4.2 compliant jar file (for use with JRE 8). +To build the jar files, you must use Java 8 with either Ant (with Ivy), Maven or Gradle. You can choose to build a JDBC 4.1 compliant jar file (for use with JRE 7) and/or a JDBC 4.2 compliant jar file (for use with JRE 8). * Ant: 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. From ae4a780e358e1dbdc242d5a8b661e3d53b50ed7f Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Fri, 2 Dec 2016 10:23:39 +0100 Subject: [PATCH 35/42] Update Maven plugins --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 996fcd037..c00e93b82 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ maven-compiler-plugin - 3.1 + 3.6.0 **/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java @@ -100,7 +100,7 @@ maven-compiler-plugin - 3.1 + 3.6.0 **/com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java @@ -144,7 +144,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.0.1 attach-sources From f5568223975b28aeabe2590e7bf16df06675cf63 Mon Sep 17 00:00:00 2001 From: Cosmo Frit Date: Fri, 2 Dec 2016 20:39:48 +1000 Subject: [PATCH 36/42] Revert "Removed unused imports" This reverts commit 1eeb465a38098bd62d710786f45042689cf7485e. --- src/main/java/com/microsoft/sqlserver/jdbc/Column.java | 1 + .../microsoft/sqlserver/jdbc/ISQLServerDataRecord.java | 2 ++ .../jdbc/SQLServerAeadAes256CbcHmac256Factory.java | 2 ++ .../sqlserver/jdbc/SQLServerCallableStatement.java | 1 + ...SQLServerColumnEncryptionCertificateStoreProvider.java | 2 ++ .../com/microsoft/sqlserver/jdbc/SQLServerConnection.java | 2 ++ .../com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java | 8 ++++++++ .../sqlserver/jdbc/SQLServerDataSourceObjectFactory.java | 1 + .../com/microsoft/sqlserver/jdbc/SQLServerDataTable.java | 3 +++ .../com/microsoft/sqlserver/jdbc/SQLServerDriver.java | 1 + .../jdbc/SQLServerEncryptionAlgorithmFactoryList.java | 1 + .../sqlserver/jdbc/SQLServerSecurityUtility.java | 3 +++ .../com/microsoft/sqlserver/jdbc/SQLServerStatement.java | 2 ++ 13 files changed, 29 insertions(+) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java index f811c9e39..087b5df56 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java @@ -19,6 +19,7 @@ package com.microsoft.sqlserver.jdbc; +import java.math.BigDecimal; import java.text.MessageFormat; import java.util.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index 838e0f217..a27705bcc 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -19,6 +19,8 @@ package com.microsoft.sqlserver.jdbc; +import java.util.Set; + /** * 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java index c239c1d84..f523c60c1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java @@ -20,7 +20,9 @@ package com.microsoft.sqlserver.jdbc; import java.io.UnsupportedEncodingException; +import java.sql.SQLException; import java.text.MessageFormat; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.xml.bind.DatatypeConverter; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index 52b50bb4c..aec394ef9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -22,6 +22,7 @@ import java.sql.*; import java.math.BigDecimal; import java.util.Calendar; +import java.util.UUID; import java.io.*; import java.net.*; import java.util.ArrayList; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index 942c2f999..f68388818 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -21,8 +21,10 @@ import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Path; +import java.nio.file.Paths; import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index b6cb7b02c..77a7cdf18 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -19,6 +19,8 @@ package com.microsoft.sqlserver.jdbc; import java.io.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.net.*; import java.sql.*; import java.util.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java index 999fda48e..9beb03a09 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java @@ -19,6 +19,14 @@ package com.microsoft.sqlserver.jdbc; +import java.util.*; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.text.MessageFormat; +import java.util.Map.Entry; + public final class SQLServerDataColumn { String columnName; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 643ef0fd1..0c81ba457 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -23,6 +23,7 @@ import javax.naming.*; import javax.naming.spi.*; import java.util.*; +import java.lang.reflect.*; /** * SQLServerDataSourceObjectFactory is an object factory to materialize datasources from JNDI. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index dc2a22e84..fef139b5a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -21,6 +21,9 @@ import java.util.*; import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.text.MessageFormat; import java.util.Map.Entry; import java.time.*; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 7456d9522..af2b7d771 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -633,6 +633,7 @@ A callable statement param used for IN and OUT may have a different type registe import java.util.*; import java.text.*; import java.util.logging.*; +import java.net.IDN; /** * SQLServerDriver implements the java.sql.Driver for SQLServerConnect. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java index 7b0367063..b1b87aac0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java @@ -21,6 +21,7 @@ import java.text.MessageFormat; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java index 406ae0189..9aa1633a9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java @@ -20,7 +20,10 @@ package com.microsoft.sqlserver.jdbc; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.text.MessageFormat; +import java.util.Arrays; import java.util.Iterator; +import java.util.concurrent.TimeUnit; import javax.crypto.Mac; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 24034d90d..32f40e200 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -19,6 +19,8 @@ package com.microsoft.sqlserver.jdbc; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.sql.*; import java.util.*; import java.text.MessageFormat; From 914203535967adce553e15118ef7524de60a0d05 Mon Sep 17 00:00:00 2001 From: v-xiangs Date: Fri, 2 Dec 2016 10:49:21 -0800 Subject: [PATCH 37/42] show CI platforms on ReadMe --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d5d69022d..da25f2790 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,15 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy), Maven or * 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 -### AppVeyor Build Status -[![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc) - -### Travis CI Build Status -[![Build Status](https://travis-ci.org/Microsoft/mssql-jdbc.svg?)](https://travis-ci.org/Microsoft/mssql-jdbc) +### Status of Most Recent Builds +| AppVeyor (Windows) | Travis CI (Linux) | +|--------------------------|--------------------------| +| [![av-image][]][av-site] | [![tv-image][]][tv-site] | + +[av-image]: https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3?svg=true +[av-site]: https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc +[tv-image]: https://travis-ci.org/Microsoft/mssql-jdbc.svg? +[tv-site]: https://travis-ci.org/Microsoft/mssql-jdbc ## Resources From e31ea3e5d51e54a266887e546972c3b5bfe0ef94 Mon Sep 17 00:00:00 2001 From: v-ahibr Date: Fri, 2 Dec 2016 15:08:44 -0800 Subject: [PATCH 38/42] Fix generation of Interface Lib Version --- .../com/microsoft/sqlserver/jdbc/SQLServerConnection.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index b43dee715..05ef07ef2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -4422,28 +4422,28 @@ private String generateInterfaceLibVersion() { // 2 characters reserved for patch // 2 characters reserved for minor // 2 characters reserved for major - if(2 == interfaceLibMajor.length()){ + if(2 == interfaceLibBuild.length()){ outputInterfaceLibVersion.append(interfaceLibBuild); } else{ outputInterfaceLibVersion.append("0"); outputInterfaceLibVersion.append(interfaceLibBuild); } - if(2 == interfaceLibMinor.length()){ + if(2 == interfaceLibPatch.length()){ outputInterfaceLibVersion.append(interfaceLibPatch); } else{ outputInterfaceLibVersion.append("0"); outputInterfaceLibVersion.append(interfaceLibPatch); } - if(2 == interfaceLibPatch.length()){ + if(2 == interfaceLibMinor.length()){ outputInterfaceLibVersion.append(interfaceLibMinor); } else{ outputInterfaceLibVersion.append("0"); outputInterfaceLibVersion.append(interfaceLibMinor); } - if(2 == interfaceLibBuild.length()){ + if(2 == interfaceLibMajor.length()){ outputInterfaceLibVersion.append(interfaceLibMajor); } else{ From 800e739453e9c343df3a44b17809ae79eb9cd0d0 Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Fri, 2 Dec 2016 17:51:23 -0800 Subject: [PATCH 39/42] Added ChangeLog --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..b32f473ba --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) + +## [6.1.1] +### Added +- Java Docs +- Driver version number in LOGIN7 packet +- Travis- CI Integration +- Appveyor Integration +- Make Ms Jdbc driver more Spring friendly +- Implement Driver#getParentLogger +- Implement missing MetaData #unwrap methods +- Added Gradle build script +- Added a queryTimeout connection parameter +- Added Store Procedure support for TVP + +### Changed +- Use StandardCharsets +- Use Charset throughout +- Upgrade azure-keyvault to 0.9.7 +- Avoid unnecessary calls to String copy constructor +- make setObject() throw a clear exception for TVP when using with result set +- Few clean-ups like remove wild card imports, unused imports etc. + + +## [6.1.0] +### Changed +- Open Sourced. + + + From 5b2a92a99089c77dbff32ce040f666b939eed4f4 Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Fri, 2 Dec 2016 17:55:24 -0800 Subject: [PATCH 40/42] Increase Version Number. Increase Version Number to 6.1.1 --- build.gradle | 2 +- build.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 9fdda615d..d62910c57 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'java' archivesBaseName = 'mssql-jdbc' -version = '6.1.0' +version = '6.1.1' allprojects { tasks.withType(JavaCompile) { diff --git a/build.xml b/build.xml index c2194d7b1..c5d389d0f 100644 --- a/build.xml +++ b/build.xml @@ -4,7 +4,7 @@ - + diff --git a/pom.xml b/pom.xml index c00e93b82..57afefde9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.microsoft.sqlserver mssql-jdbc - 6.1.0 + 6.1.1 jar From 3e1bdd0634124773afe1ff1329c0883d6da914d9 Mon Sep 17 00:00:00 2001 From: v-nisidh Date: Tue, 6 Dec 2016 11:18:58 -0800 Subject: [PATCH 41/42] Updated Change Log. --- CHANGELOG.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b32f473ba..4a30f000b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,24 +5,25 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) ## [6.1.1] ### Added -- Java Docs -- Driver version number in LOGIN7 packet -- Travis- CI Integration -- Appveyor Integration -- Make Ms Jdbc driver more Spring friendly -- Implement Driver#getParentLogger -- Implement missing MetaData #unwrap methods -- Added Gradle build script -- Added a queryTimeout connection parameter -- Added Store Procedure support for TVP +- Java Docs [#46](https://github.com/Microsoft/mssql-jdbc/pull/46) +- Driver version number in LOGIN7 packet [#43](https://github.com/Microsoft/mssql-jdbc/pull/43) +- Travis- CI Integration [#23](https://github.com/Microsoft/mssql-jdbc/pull/23) +- Appveyor Integration [#23](https://github.com/Microsoft/mssql-jdbc/pull/23) +- Make Ms Jdbc driver more Spring friendly [#9](https://github.com/Microsoft/mssql-jdbc/pull/9) +- Implement Driver#getParentLogger [#8](https://github.com/Microsoft/mssql-jdbc/pull/8) +- Implement missing MetaData #unwrap methods [#12](https://github.com/Microsoft/mssql-jdbc/pull/12) +- Added Gradle build script [#54](https://github.com/Microsoft/mssql-jdbc/pull/54) +- Added a queryTimeout connection parameter [#45](https://github.com/Microsoft/mssql-jdbc/pull/45) +- Added Store Procedure support for TVP [#47](https://github.com/Microsoft/mssql-jdbc/pull/47) ### Changed -- Use StandardCharsets -- Use Charset throughout -- Upgrade azure-keyvault to 0.9.7 -- Avoid unnecessary calls to String copy constructor -- make setObject() throw a clear exception for TVP when using with result set -- Few clean-ups like remove wild card imports, unused imports etc. +- Use StandardCharsets [#15](https://github.com/Microsoft/mssql-jdbc/pull/15) +- Use Charset throughout [#26](https://github.com/Microsoft/mssql-jdbc/pull/26) +- Upgrade azure-keyvault to 0.9.7 [#50](https://github.com/Microsoft/mssql-jdbc/pull/50) +- Avoid unnecessary calls to String copy constructor [#14](https://github.com/Microsoft/mssql-jdbc/pull/14) +- make setObject() throw a clear exception for TVP when using with result set [#48](https://github.com/Microsoft/mssql-jdbc/pull/48) +- Few clean-ups like remove wild card imports, unused imports etc. [#52](https://github.com/Microsoft/mssql-jdbc/pull/52) +- Update Maven Plugin [#55](https://github.com/Microsoft/mssql-jdbc/pull/55) ## [6.1.0] From 4bc558f35f5ee414ac1cbfcf4a21036bceb85329 Mon Sep 17 00:00:00 2001 From: Andrea Lam Date: Tue, 6 Dec 2016 13:25:21 -0800 Subject: [PATCH 42/42] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a30f000b..6d49b370c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) - Implement missing MetaData #unwrap methods [#12](https://github.com/Microsoft/mssql-jdbc/pull/12) - Added Gradle build script [#54](https://github.com/Microsoft/mssql-jdbc/pull/54) - Added a queryTimeout connection parameter [#45](https://github.com/Microsoft/mssql-jdbc/pull/45) -- Added Store Procedure support for TVP [#47](https://github.com/Microsoft/mssql-jdbc/pull/47) +- Added Stored Procedure support for TVP [#47](https://github.com/Microsoft/mssql-jdbc/pull/47) ### Changed - Use StandardCharsets [#15](https://github.com/Microsoft/mssql-jdbc/pull/15)