From 49d94e78e569dd90a062b8e78b8d24cc4f088f2f Mon Sep 17 00:00:00 2001 From: susanh Date: Fri, 20 Jul 2018 16:26:40 -0700 Subject: [PATCH 1/9] updated javadocs --- .../microsoft/sqlserver/jdbc/DataTypes.java | 4 +- .../microsoft/sqlserver/jdbc/Geography.java | 10 ++- .../microsoft/sqlserver/jdbc/Geometry.java | 8 +- .../sqlserver/jdbc/ISQLServerBulkRecord.java | 26 +++--- .../jdbc/ISQLServerCallableStatement.java | 38 ++++----- .../sqlserver/jdbc/ISQLServerConnection.java | 20 ++--- .../jdbc/ISQLServerConnection43.java | 2 +- .../sqlserver/jdbc/ISQLServerDataRecord.java | 8 +- .../sqlserver/jdbc/ISQLServerDataSource.java | 82 ++++++++++--------- .../jdbc/ISQLServerPreparedStatement.java | 13 ++- .../sqlserver/jdbc/ISQLServerResultSet.java | 44 +++++----- .../jdbc/ISQLServerResultSetMetaData.java | 4 +- .../sqlserver/jdbc/ISQLServerSavepoint.java | 8 +- .../sqlserver/jdbc/ISQLServerStatement.java | 6 +- .../jdbc/InternalSpatialDatatype.java | 5 ++ .../sqlserver/jdbc/JaasConfiguration.java | 2 +- .../sqlserver/jdbc/KerbCallback.java | 4 +- .../sqlserver/jdbc/SQLServerBlob.java | 3 +- .../jdbc/SQLServerBulkBatchInsertRecord.java | 5 +- .../jdbc/SQLServerBulkCSVFileRecord.java | 10 +-- .../sqlserver/jdbc/SQLServerBulkCopy.java | 15 ++-- .../jdbc/SQLServerBulkCopyOptions.java | 22 ++--- .../jdbc/SQLServerCallableStatement.java | 2 +- .../sqlserver/jdbc/SQLServerClob.java | 19 ++--- ...ColumnEncryptionAzureKeyVaultProvider.java | 19 ++--- ...umnEncryptionCertificateStoreProvider.java | 5 +- ...rColumnEncryptionJavaKeyStoreProvider.java | 4 +- ...erverColumnEncryptionKeyStoreProvider.java | 1 + .../sqlserver/jdbc/SQLServerConnection.java | 20 ++--- .../sqlserver/jdbc/SQLServerConnection43.java | 4 +- .../SQLServerConnectionPoolDataSource.java | 2 +- .../sqlserver/jdbc/SQLServerDataColumn.java | 10 +-- .../sqlserver/jdbc/SQLServerDataSource.java | 6 +- .../SQLServerDataSourceObjectFactory.java | 14 ++-- .../sqlserver/jdbc/SQLServerDataTable.java | 7 +- .../jdbc/SQLServerDatabaseMetaData.java | 4 +- .../sqlserver/jdbc/SQLServerDriver.java | 16 ++-- .../sqlserver/jdbc/SQLServerException.java | 37 ++++----- ...LServerKeyVaultAuthenticationCallback.java | 8 +- .../sqlserver/jdbc/SQLServerMetaData.java | 46 ++++++----- .../sqlserver/jdbc/SQLServerNClob.java | 3 +- .../jdbc/SQLServerParameterMetaData.java | 18 ++-- .../jdbc/SQLServerPooledConnection.java | 6 +- .../jdbc/SQLServerPreparedStatement.java | 27 +++--- .../sqlserver/jdbc/SQLServerResource.java | 2 +- .../sqlserver/jdbc/SQLServerResultSet.java | 18 ++-- .../jdbc/SQLServerResultSetMetaData.java | 4 +- .../sqlserver/jdbc/SQLServerSQLXML.java | 2 +- .../sqlserver/jdbc/SQLServerSavepoint.java | 4 +- .../sqlserver/jdbc/SQLServerStatement.java | 41 ++++------ .../jdbc/SQLServerSymmetricKeyCache.java | 2 +- .../sqlserver/jdbc/SQLServerXAConnection.java | 2 +- .../sqlserver/jdbc/SQLServerXADataSource.java | 7 +- .../sqlserver/jdbc/SQLServerXAResource.java | 7 +- .../microsoft/sqlserver/jdbc/SqlVariant.java | 35 ++++---- .../sqlserver/jdbc/StreamColumns.java | 2 +- .../microsoft/sqlserver/jdbc/StringUtils.java | 8 +- .../dataclassification/ColumnSensitivity.java | 6 +- .../dataclassification/InformationType.java | 8 +- .../jdbc/dataclassification/Label.java | 8 +- .../SensitivityClassification.java | 10 +-- .../SensitivityProperty.java | 10 +-- .../jdbc/dns/DNSKerberosLocator.java | 6 +- .../sqlserver/jdbc/dns/DNSRecordSRV.java | 14 ++-- .../sqlserver/jdbc/dns/DNSUtilities.java | 5 +- .../java/microsoft/sql/DateTimeOffset.java | 11 +-- src/main/java/microsoft/sql/Types.java | 3 +- 67 files changed, 428 insertions(+), 404 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java index 9af5d640c9..b183470bad 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java @@ -531,7 +531,7 @@ static JavaType of(Object obj) { return JavaType.OBJECT; } - // Retrieve JDBC to use with this Java type. By default we use the static JDBC type + // Returns the JDBC type to use with this Java type. By default we use the static JDBC type // associated with the Java type, ignoring the JDBC type specified by the application. // But this behavior is overridden for certain Java types, like InputStream, which // require the JDBC type to be specified externally to be able to distinguish between @@ -677,7 +677,7 @@ private JDBCType(Category category, int intValue, String className) { } /** - * Gets the integer value of JDBCType + * Returns the integer value of JDBCType * * @return integer representation of JDBCType */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java index 1bcac796cd..4372e41cdf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java @@ -8,11 +8,13 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; - +/** + * Represents a Geography spatial data type. + */ public class Geography extends SQLServerSpatialDatatype { /** - * Private constructor used for creating a Geography object from WKT and srid. + * Constructs a Geography object from WKT and srid. * * @param WellKnownText * Well-Known Text (WKT) provided by the user. @@ -37,7 +39,7 @@ private Geography(String WellKnownText, int srid) throws SQLServerException { } /** - * Private constructor used for creating a Geography object from WKB. + * Constructs a Geography object from WKB. * * @param wkb * Well-Known Binary (WKB) provided by the user. @@ -409,4 +411,4 @@ private void readPoints() { points[2 * i] = buffer.getDouble(); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java index 45d8939f40..1332c60193 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java @@ -8,11 +8,13 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; - +/** + * Represents a Geometry spatial data type. + */ public class Geometry extends SQLServerSpatialDatatype { /** - * Private constructor used for creating a Geometry object from WKT and srid. + * Construct a Geometry object from WKT and srid. * * @param WellKnownText * Well-Known Text (WKT) provided by the user. @@ -37,7 +39,7 @@ private Geometry(String WellKnownText, int srid) throws SQLServerException { } /** - * Private constructor used for creating a Geometry object from WKB. + * Constructs a Geometry object from WKB. * * @param wkb * Well-Known Binary (WKB) provided by the user. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java index 3df14c51bc..cf1eaa2397 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java @@ -9,7 +9,7 @@ /** - * The ISQLServerBulkRecord interface can be used to create classes that read in data from any source (such as a file) + * Provides an interface used to create classes that read in data from any source (such as a file) * and allow a SQLServerBulkCopy class to write the data to SQL Server tables. * * This interface is implemented by {@link SQLServerBulkCommon} Class @@ -17,14 +17,14 @@ public interface ISQLServerBulkRecord { /** - * Get the ordinals for each of the columns represented in this data record. + * Returns the ordinals for each of the columns represented in this data record. * * @return Set of ordinals for the columns. */ public java.util.Set getColumnOrdinals(); /** - * Get the name of the given column. + * Returns the name of the given column. * * @param column * Column ordinal @@ -33,7 +33,7 @@ public interface ISQLServerBulkRecord { public String getColumnName(int column); /** - * Get the JDBC data type of the given column. + * Returns the JDBC data type of the given column. * * @param column * Column ordinal @@ -42,7 +42,7 @@ public interface ISQLServerBulkRecord { public int getColumnType(int column); /** - * Get the precision for the given column. + * Returns the precision for the given column. * * @param column * Column ordinal @@ -51,7 +51,7 @@ public interface ISQLServerBulkRecord { public int getPrecision(int column); /** - * Get the scale for the given column. + * Returns the scale for the given column. * * @param column * Column ordinal @@ -60,7 +60,7 @@ public interface ISQLServerBulkRecord { public int getScale(int column); /** - * Indicates whether the column represents an identity column. + * Returns whether the column represents an identity column. * * @param column * Column ordinal @@ -69,7 +69,7 @@ public interface ISQLServerBulkRecord { public boolean isAutoIncrement(int column); /** - * Gets the data for the current row as an array of Objects. + * Returns the data for the current row as an array of Objects. * * Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the * given column. For more information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings. @@ -130,7 +130,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int int scale) throws SQLServerException; /** - * Set the format for reading in dates from the file. + * Sets the format for reading in dates from the file. * * @param dateTimeFormat * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE @@ -138,7 +138,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int public void setTimestampWithTimezoneFormat(String dateTimeFormat); /** - * Set the format for reading in dates from the file. + * Sets the format for reading in dates from the file. * * @param dateTimeFormatter * format to parse data sent as java.sql.Types.TIMESTAMP_WITH_TIMEZONE @@ -146,7 +146,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int public void setTimestampWithTimezoneFormat(DateTimeFormatter dateTimeFormatter); /** - * Set the format for reading in dates from the file. + * Sets the format for reading in dates from the file. * * @param timeFormat * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE @@ -154,7 +154,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int public void setTimeWithTimezoneFormat(String timeFormat); /** - * Set the format for reading in dates from the file. + * Sets the format for reading in dates from the file. * * @param dateTimeFormatter * format to parse data sent as java.sql.Types.TIME_WITH_TIMEZONE @@ -162,7 +162,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter); /** - * Retreives dateTimeFormatter for the given column + * Returns the dateTimeFormatter for the given column * * @param column * Column ordinal diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java index 8f254c78b5..3e10537c2f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java @@ -12,7 +12,7 @@ /** - * This interface is implemented by {@link SQLServerCallableStatement} Class. + * Provides an interface to the {@link SQLServerCallableStatement} class */ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, ISQLServerPreparedStatement { @@ -20,7 +20,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public BigDecimal getBigDecimal(String parameterName, int scale) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -32,7 +32,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getDateTime(int index) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp * object in the Java programming language. * * @param parameterName @@ -45,7 +45,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getDateTime(String parameterName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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. * @@ -60,7 +60,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getDateTime(int index, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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. * @@ -75,7 +75,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getDateTime(String name, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -87,7 +87,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getSmallDateTime(int index) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp * object in the Java programming language. * * @param parameterName @@ -99,7 +99,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getSmallDateTime(String parameterName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -113,7 +113,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getSmallDateTime(int index, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp * object in the Java programming language. * * @param name @@ -127,7 +127,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getSmallDateTime(String name, Calendar cal) throws SQLServerException; /** - * Gets the DateTimeOffset value of parameter with index parameterIndex + * Returns the DateTimeOffset value of parameter with index parameterIndex * * @param parameterIndex * the first parameter is 1, the second is 2, and so on @@ -139,7 +139,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public microsoft.sql.DateTimeOffset getDateTimeOffset(int parameterIndex) throws SQLServerException; /** - * Gets the DateTimeOffset value of parameter with name parameterName + * Returns the DateTimeOffset value of parameter with name parameterName * * @param parameterName * the name of the parameter @@ -151,7 +151,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public microsoft.sql.DateTimeOffset getDateTimeOffset(String parameterName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a stream + * Returns 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. @@ -172,7 +172,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public java.io.InputStream getAsciiStream(int parameterIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a stream + * Returns 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. @@ -193,7 +193,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public java.io.InputStream getAsciiStream(String parameterName) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param parameterIndex * The zero-based ordinal of a column. @@ -204,7 +204,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public BigDecimal getMoney(int parameterIndex) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param parameterName * The name of a column. @@ -215,7 +215,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public BigDecimal getMoney(String parameterName) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param parameterIndex * The zero-based ordinal of a column. @@ -226,7 +226,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public BigDecimal getSmallMoney(int parameterIndex) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param parameterName * The name of a column. @@ -237,7 +237,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public BigDecimal getSmallMoney(String parameterName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a stream + * Returns 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. * @@ -257,7 +257,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public java.io.InputStream getBinaryStream(int parameterIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a stream + * Returns 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. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java index 628a1d282f..125ba8d2c8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java @@ -12,7 +12,7 @@ /** - * This interface is implemented by {@link SQLServerConnection} and {@link SQLServerConnectionPoolProxy} Classes. + * Provides an interface to the {@link SQLServerConnection} and {@link SQLServerConnectionPoolProxy} classes. */ public interface ISQLServerConnection extends java.sql.Connection { @@ -21,7 +21,7 @@ public interface ISQLServerConnection extends java.sql.Connection { public final static int TRANSACTION_SNAPSHOT = 0x1000; /** - * Gets the connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or + * Returns 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 @@ -215,7 +215,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException; /** - * Modifies the setting of the sendTimeAsDatetime connection property. When true, java.sql.Time values will be sent + * Sets the value 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. @@ -232,7 +232,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException; /** - * Checks the sendTimeAsDatetime property. + * Returns the value of the sendTimeAsDatetime property. * * @return boolean value of sendTimeAsDatetime * @@ -265,7 +265,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public boolean getEnablePrepareOnFirstPreparedStatementCall(); /** - * Specifies the behavior for a specific connection instance. If value is false the first execution will call + * Sets the behavior for a specific connection instance. If value is false the first execution will call * sp_executesql and not prepare a statement, once the second execution happens it will call sp_prepexec and * actually setup a prepared statement handle. Following executions will call sp_execute. This relieves the need for * sp_unprepare on prepared statement close if the statement is only executed once. @@ -288,7 +288,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public int getServerPreparedStatementDiscardThreshold(); /** - * Specifies the behavior for a specific connection instance. This setting controls how many outstanding prepared + * Sets the behavior for a specific connection instance. This setting controls how many outstanding prepared * statement discard actions (sp_unprepare) can be outstanding per connection before a call to clean-up the * outstanding handles on the server is executed. If the setting is {@literal <=} 1 unprepare actions will be * executed immedietely on prepared statement close. If it is set to {@literal >} 1 these calls will be batched @@ -300,7 +300,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public void setServerPreparedStatementDiscardThreshold(int value); /** - * Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache. + * Sets the size of the prepared statement cache for this connection. A value less than 1 means no cache. * * @param value * The new cache size. @@ -316,7 +316,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public int getStatementPoolingCacheSize(); /** - * Whether statement pooling is enabled or not for this connection. + * Returns whether statement pooling is enabled or not for this connection. * * @return Returns the current setting per the description. */ @@ -330,7 +330,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public int getStatementHandleCacheEntryCount(); /** - * Disable/enable statement pooling. + * Sets the value to Disable/enable statement pooling. * * @param value * true to disable statement pooling, false to enable it. @@ -338,7 +338,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public void setDisableStatementPooling(boolean value); /** - * Determine whether statement pooling is disabled. + * Returns the value whether statement pooling is disabled. * * @return true if statement pooling is disabled, false if it is enabled. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java index c6e9224da2..b17597aa6d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java @@ -9,7 +9,7 @@ /** - * This interface is implemented by {@link SQLServerConnection43} class. + * Provides an interface to the {@link SQLServerConnection43} class. */ public interface ISQLServerConnection43 extends ISQLServerConnection { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index 3236ae2906..54a14c2cb0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -6,12 +6,12 @@ package com.microsoft.sqlserver.jdbc; /** - * This interface can be used to create classes that read in data from any source (such as a file) and allow a + * Provides an interface to create classes that read in data from any source (such as a file) and allow a * structured type to be sent to SQL Server tables. */ public interface ISQLServerDataRecord { /** - * Get the column meta data + * Returns the column meta data * * @param column * the first column is 1, the second is 2, and so on @@ -20,14 +20,14 @@ public interface ISQLServerDataRecord { public SQLServerMetaData getColumnMetaData(int column); /** - * Get the column count. + * Returns the column count. * * @return Set of ordinals for the columns. */ public int getColumnCount(); /** - * Gets the data for the current row as an array of Objects. + * Returns the data for the current row as an array of Objects. * * Each Object must match the Java language Type that is used to represent the indicated JDBC data type for the * given column. For more information, see 'Understanding the JDBC Driver Data Types' for the appropriate mappings. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java index 7330feeea3..8d93f20fa2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java @@ -9,7 +9,7 @@ /** - * A factory to create connections to the data source represented by this object. This interface was added in SQL Server + * Provides a factory to create connections to the data source represented by this object. This interface was added in SQL Server * JDBC Driver 3.0. * * This interface is implemented by {@link SQLServerDataSource} Class. @@ -117,6 +117,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public boolean getEncrypt(); /** + * Sets the value to enable/disable Transparent Netowrk IP Resolution (TNIR) * 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 @@ -136,7 +137,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTransparentNetworkIPResolution(boolean tnir); /** - * Retrieves the TransparentNetworkIPResolution value. + * Returns the TransparentNetworkIPResolution value. * * @return if enabled, returns true. Otherwise, false. */ @@ -159,7 +160,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public boolean getTrustServerCertificate(); /** - * This parameter defines the keystore type for the trustStore. + * Sets the keystore type for the trustStore. * * @param trustStoreType * A String that contains the trust store type @@ -285,7 +286,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getResponseBuffering(); /** - * Modifies the setting of the sendTimeAsDatetime connection property. + * Sets the value to enable/disable 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 @@ -294,6 +295,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSendTimeAsDatetime(boolean sendTimeAsDatetime); /** + * Returns the value of the sendTimeAsDatetime connection property. * This method was added in SQL Server JDBC Driver 3.0. Returns the setting of the sendTimeAsDatetime connection * property. * @@ -311,14 +313,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode); /** - * Returns a boolean value that indicates if sending string parameters to the server in UNICODE format is enabled. + * Returns whether 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(); /** - * Translates the serverName from Unicode to ASCII Compatible Encoding (ACE) + * Sets whether the serverName will be translated from Unicode to ASCII Compatible Encoding (ACE) * * @param serverNameAsACE * if enabled the servername will be translated to ASCII Compatible Encoding (ACE) @@ -326,7 +328,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setServerNameAsACE(boolean serverNameAsACE); /** - * Retrieves if the serverName should be translated from Unicode to ASCII Compatible Encoding (ACE) + * Returns if the serverName should be translated from Unicode to ASCII Compatible Encoding (ACE) * * @return if enabled, will return true. Otherwise, false. */ @@ -408,7 +410,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getWorkstationID(); /** - * Sets a Boolean value that indicates if converting SQL states to XOPEN compliant states is enabled. + * Sets whether converting SQL states to XOPEN compliant states is enabled. * * @param xopenStates * true if converting SQL states to XOPEN compliant states is enabled. Otherwise, false. @@ -416,7 +418,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setXopenStates(boolean xopenStates); /** - * Returns a boolean value that indicates if converting SQL states to XOPEN compliant states is enabled. + * Returns the 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. */ @@ -468,7 +470,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public int getPacketSize(); /** - * Indicates the kind of integrated security you want your application to use. + * Sets the kind of integrated security you want your application to use. * * @param authenticationScheme * Values are "JavaKerberos" and the default "NativeAuthentication". @@ -476,7 +478,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setAuthenticationScheme(String authenticationScheme); /** - * sets the authentication mode + * Sets the authentication mode * * @param authentication * the authentication mode @@ -484,7 +486,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setAuthentication(String authentication); /** - * Retrieves the authentication mode + * Returns the authentication mode * * @return the authentication value */ @@ -506,7 +508,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getServerSpn(); /** - * sets GSSCredential + * Sets GSSCredential * * @param userCredential * the credential @@ -514,7 +516,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setGSSCredentials(GSSCredential userCredential); /** - * Retrieves the GSSCredential + * Returns the GSSCredential * * @return GSSCredential */ @@ -529,14 +531,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setAccessToken(String accessToken); /** - * Retrieves the access token. + * Returns the access token. * * @return the access token. */ public String getAccessToken(); /** - * Enables/disables Always Encrypted functionality for the data source object. The default is Disabled. + * Sets the value to enable/disable 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. @@ -544,7 +546,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setColumnEncryptionSetting(String columnEncryptionSetting); /** - * Retrieves the Always Encrypted functionality setting for the data source object. + * Returns the Always Encrypted functionality setting for the data source object. * * @return the Always Encrypted functionality setting for the data source object. */ @@ -560,7 +562,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setKeyStoreAuthentication(String keyStoreAuthentication); /** - * Gets the value of the keyStoreAuthentication setting for the data source object. + * Returns the value of the keyStoreAuthentication setting for the data source object. * * @return the value of the keyStoreAuthentication setting for the data source object. */ @@ -585,7 +587,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setKeyStoreLocation(String keyStoreLocation); /** - * Retrieves the keyStoreLocation for the Java Key Store. + * Returns the keyStoreLocation for the Java Key Store. * * @return the keyStoreLocation for the Java Key Store. */ @@ -601,7 +603,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setQueryTimeout(int queryTimeout); /** - * Getting the query timeout + * Returns the query timeout * * @return The number of seconds to wait before a timeout has occurred on a query. */ @@ -616,13 +618,15 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setCancelQueryTimeout(int cancelQueryTimeout); /** - * Getting the cancel timeout + * Returns the cancel timeout * * @return the number of seconds to wait before we wait for the query timeout to happen. */ public int getCancelQueryTimeout(); /** + * Sets the value that enables/disables whether the first execution of a prepared statement will call sp_executesql + * and not prepare a statement. * If this configuration is false the first execution of a prepared statement will call sp_executesql and not * prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared * statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared @@ -634,6 +638,8 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setEnablePrepareOnFirstPreparedStatementCall(boolean enablePrepareOnFirstPreparedStatementCall); /** + * Returns the value that indicates whether the first execution of a prepared statement will call sp_executesql + * and not prepare a statement. * If this configuration returns false the first execution of a prepared statement will call sp_executesql and not * prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared * statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared @@ -644,7 +650,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public boolean getEnablePrepareOnFirstPreparedStatementCall(); /** - * This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding + * Sets the value that setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding * per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is * {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to * {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too often. @@ -655,17 +661,15 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setServerPreparedStatementDiscardThreshold(int serverPreparedStatementDiscardThreshold); /** - * This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding - * per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is - * {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to - * {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too often. + * Returns the value of the setting that controls how many outstanding prepared statement discard actions (sp_unprepare) + * can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. * * @return Returns the current setting per the description. */ public int getServerPreparedStatementDiscardThreshold(); /** - * Specifies the size of the prepared statement cache for this connection. A value less than 1 means no cache. + * Sets the size of the prepared statement cache for this connection. A value less than 1 means no cache. * * @param statementPoolingCacheSize * Changes the setting per the description. @@ -680,7 +684,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public int getStatementPoolingCacheSize(); /** - * Disable/enable statement pooling. + * Sets the value to disable/enable statement pooling. * * @param disableStatementPooling * true to disable statement pooling, false to enable it. @@ -688,14 +692,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setDisableStatementPooling(boolean disableStatementPooling); /** - * Determine whether statement pooling is disabled. + * Return whether statement pooling is disabled. * * @return true if statement pooling is disabled, false if it is enabled. */ public boolean getDisableStatementPooling(); /** - * Setting the socket timeout + * Sets the socket timeout * * @param socketTimeout * The number of milliseconds to wait before a timeout is occurred on a socket read or accept. The default @@ -704,7 +708,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSocketTimeout(int socketTimeout); /** - * Getting the socket timeout + * Returns the socket timeout * * @return The number of milliseconds to wait before a timeout is occurred on a socket read or accept. */ @@ -720,14 +724,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setJASSConfigurationName(String configurationName); /** - * Retrieves the login configuration file for Kerberos authentication. + * Returns the login configuration file for Kerberos authentication. * * @return login configuration file name */ public String getJASSConfigurationName(); /** - * Enables Fips Mode on the connection For FIPS enabled JVM this property should be true. + * Sets Fips Mode on the connection For FIPS enabled JVM this property should be true. * * @param fips * Boolean property to enable/disable fips @@ -735,7 +739,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setFIPS(boolean fips); /** - * Retrieves value of connection property "fips" For FIPS enabled JVM this property should be true. + * Returns the value of connection property "fips" For FIPS enabled JVM this property should be true. * * @return fips boolean value */ @@ -752,7 +756,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSSLProtocol(String sslProtocol); /** - * Retrieves value of connection property 'sslProtocol' + * Returns the value of connection property 'sslProtocol' * * @return sslProtocol property value */ @@ -767,7 +771,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTrustManagerClass(String trustManagerClass); /** - * Retrieves value for the connection property 'trustManagerClass' + * Returns the value for the connection property 'trustManagerClass' * * @return trustManagerClass property value */ @@ -782,21 +786,21 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTrustManagerConstructorArg(String trustManagerConstructorArg); /** - * Retrieves value for the connection property 'trustManagerConstructorArg' + * Returns the value for the connection property 'trustManagerConstructorArg' * * @return trustManagerConstructorArg property value */ public String getTrustManagerConstructorArg(); /** - * Getting the use Bulk Copy API for Batch Insert + * Returns whether the use Bulk Copy API is used for Batch Insert * * @return whether the driver should use Bulk Copy API for Batch Insert operations. */ public boolean getUseBulkCopyForBatchInsert(); /** - * Setting the use Bulk Copy API for Batch Insert + * Sets whether the use Bulk Copy API should be used for Batch Insert * * @param useBulkCopyForBatchInsert * indicates whether Bulk Copy API should be used for Batch Insert operations. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java index 7068eaa6f0..712f2a8141 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java @@ -12,7 +12,7 @@ /** - * This interface is implemented by {@link SQLServerPreparedStatement} class. + * Provides an interface to the {@link SQLServerPreparedStatement} class. */ public interface ISQLServerPreparedStatement extends java.sql.PreparedStatement, ISQLServerStatement { /** @@ -367,7 +367,6 @@ public void setBigDecimal(int parameterIndex, BigDecimal x, int precision, int s public void setLong(int parameterIndex, long x, boolean forceEncrypt) throws SQLServerException; /** - *

* Sets the value of the designated parameter with the given object. * *

@@ -400,7 +399,6 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, Integer p int scale) throws SQLServerException; /** - *

* Sets the value of the designated parameter with the given object. * *

@@ -646,7 +644,7 @@ public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x, boolean forceEncrypt) throws SQLServerException; /** - * Populates a table valued parameter with a data table + * Sets the data table to populates a table valued parameter * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -657,11 +655,10 @@ public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x, * @throws SQLServerException * when an error occurs */ - public void setStructured(int parameterIndex, String tvpName, - SQLServerDataTable tvpDataTable) throws SQLServerException; + public void setStructured(int parameterIndex, String tvpName, SQLServerDataTable tvpDataTable) throws SQLServerException; /** - * Populates a table valued parameter with a data table + * Sets the result set to populate a table valued parameter * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -675,7 +672,7 @@ public void setStructured(int parameterIndex, String tvpName, public void setStructured(int parameterIndex, String tvpName, ResultSet tvpResultSet) throws SQLServerException; /** - * Populates a table valued parameter with a data table + * Sets the server bulk record to populate a table valued parameter * * @param parameterIndex * the first parameter is 1, the second is 2, ... diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java index 7325ef2130..33b1484c93 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java @@ -13,7 +13,7 @@ /** - * This interface is implemented by {@link SQLServerResultSet} class. + * Provides an interface to the {@link SQLServerResultSet} class. */ public interface ISQLServerResultSet extends java.sql.ResultSet { @@ -29,7 +29,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public static final int CONCUR_SS_OPTIMISTIC_CCVAL = 1010; // CONCUR_UPDATABLE + 2 /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a + * Returns the value of the designated column in the current row of this ResultSet object as a * com.microsoft.sqlserver.jdbc.Geometry object in the Java programming language. * * @param columnIndex @@ -41,7 +41,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public Geometry getGeometry(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a + * Returns the value of the designated column in the current row of this ResultSet object as a * com.microsoft.sqlserver.jdbc.Geometry object in the Java programming language. * * @param columnName @@ -53,7 +53,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public Geometry getGeometry(String columnName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a + * Returns the value of the designated column in the current row of this ResultSet object as a * com.microsoft.sqlserver.jdbc.Geography object in the Java programming language. * * @param columnIndex @@ -65,7 +65,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public Geography getGeography(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a + * Returns the value of the designated column in the current row of this ResultSet object as a * com.microsoft.sqlserver.jdbc.Geography object in the Java programming language. * * @param columnName @@ -77,7 +77,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public Geography getGeography(String columnName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a String object in + * Returns the value of the designated column in the current row of this ResultSet object as a String object in * the Java programming language. * * @param columnIndex @@ -89,7 +89,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public String getUniqueIdentifier(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a String object in + * Returns the value of the designated column in the current row of this ResultSet object as a String object in * the Java programming language. * * @param columnLabel @@ -101,7 +101,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public String getUniqueIdentifier(String columnLabel) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -113,7 +113,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getDateTime(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -125,7 +125,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getDateTime(String columnName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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. * @@ -140,7 +140,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getDateTime(int columnIndex, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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. * @@ -156,7 +156,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getDateTime(String colName, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -168,7 +168,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getSmallDateTime(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -180,7 +180,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getSmallDateTime(String columnName) throws SQLServerException; /** - * Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp + * Returns 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 @@ -194,6 +194,8 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getSmallDateTime(int columnIndex, Calendar cal) throws SQLServerException; /** + * Returns 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 colName * The name of a column @@ -206,7 +208,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public java.sql.Timestamp getSmallDateTime(String colName, Calendar cal) throws SQLServerException; /** - * Retrieves the value of the designated column as a microsoft.sql.DateTimeOffset object, given a zero-based column + * Returns the value of the designated column as a microsoft.sql.DateTimeOffset object, given a zero-based column * ordinal. * * @param columnIndex @@ -218,7 +220,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public microsoft.sql.DateTimeOffset getDateTimeOffset(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the column specified as a microsoft.sql.DateTimeOffset object, given a column name. + * Returns the value of the column specified as a microsoft.sql.DateTimeOffset object, given a column name. * * @param columnName * The name of a column. @@ -229,7 +231,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public microsoft.sql.DateTimeOffset getDateTimeOffset(String columnName) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param columnIndex * The zero-based ordinal of a column. @@ -240,7 +242,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public BigDecimal getMoney(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param columnName * is the name of a column. @@ -251,7 +253,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public BigDecimal getMoney(String columnName) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param columnIndex * The zero-based ordinal of a column. @@ -262,7 +264,7 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public BigDecimal getSmallMoney(int columnIndex) throws SQLServerException; /** - * Retrieves the value of the column specified as a java.math.BigDecimal object. + * Returns the value of the column specified as a java.math.BigDecimal object. * * @param columnName * is the name of a column. @@ -1563,7 +1565,7 @@ public void updateObject(String columnName, Object x, int precision, int scale, boolean forceEncrypt) throws SQLServerException; /** - * Exposes Data Classification information for the current ResultSet For SQL Servers that do not support Data + * Returns the Data Classification information for the current ResultSet For SQL Servers that do not support Data * Classification or results that do not fetch any classified columns, this data can be null * * @return SensitivityClassification diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java index c91a18ac82..5eb3ec836e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java @@ -9,12 +9,12 @@ /** - * This interface is implemented by {@link SQLServerResultSetMetaData} class. + * Provides an interface to the{@link SQLServerResultSetMetaData} class. */ public interface ISQLServerResultSetMetaData extends ResultSetMetaData { /** - * Returns true if the column is a SQLServer SparseColumnSet + * Returns if the column is a SQLServer SparseColumnSet * * @param column * The column number diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java index e5813da6f8..3f97fe79b5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerSavepoint.java @@ -9,26 +9,26 @@ /** - * This interface is implemented by {@link SQLServerSavepoint} class. + * Provides an interface to the {@link SQLServerSavepoint} class. */ public interface ISQLServerSavepoint extends Savepoint { /** - * Get the savepoint name + * Returns the savepoint name * * @return the name of savepoint */ public String getSavepointName() throws SQLServerException; /** - * Get the savepoint label + * Returns the savepoint label * * @return the label for Savepoint */ public String getLabel(); /** - * Checks if the savepoint label is null + * Returns if the savepoint label is null * * @return true is the savepoint is named. Otherwise, false. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java index 66e2293869..426800a12f 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 @@ package com.microsoft.sqlserver.jdbc; /** - * This interface is implemented by {@link SQLServerStatement} class. + * Provides an interface to the {@link SQLServerStatement} class. */ public interface ISQLServerStatement extends java.sql.Statement { /** @@ -29,7 +29,7 @@ public interface ISQLServerStatement extends java.sql.Statement { public void setResponseBuffering(String value) throws SQLServerException; /** - * Retrieves the response buffering mode for this SQLServerStatement object. + * Returns the response buffering mode for this SQLServerStatement object. * * @return A String that contains a lower-case full or adaptive. * @throws SQLServerException @@ -38,7 +38,7 @@ public interface ISQLServerStatement extends java.sql.Statement { public String getResponseBuffering() throws SQLServerException; /** - * Retrieves the cancelQueryTimeout property set on this SQLServerStatement object. + * Returns the cancelQueryTimeout property set on this SQLServerStatement object. * * @return cancelQueryTimeout Time duration in seconds. * @throws SQLServerException diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java index 0fac3699b2..3431e8dc01 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java @@ -5,6 +5,11 @@ package com.microsoft.sqlserver.jdbc; +/** + * + * Specifies the spatial data types values + * + */ public enum InternalSpatialDatatype { POINT((byte) 1, "POINT"), LINESTRING((byte) 2, "LINESTRING"), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/JaasConfiguration.java b/src/main/java/com/microsoft/sqlserver/jdbc/JaasConfiguration.java index 55a51739a1..2f8dda592d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/JaasConfiguration.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/JaasConfiguration.java @@ -12,7 +12,7 @@ /** - * This class overrides JAAS Configuration and always provide a configuration is not defined for default configuration. + * Overrides JAAS Configuration and always provide a configuration is not defined for default configuration. */ public class JaasConfiguration extends Configuration { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java index 0df4f10118..119f74f148 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java @@ -15,7 +15,9 @@ import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; - +/** + * Provides implemention of the callback handler for Kerberos. + */ public class KerbCallback implements CallbackHandler { private final SQLServerConnection con; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java index 8d3bb849f9..b1e7858172 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBlob.java @@ -18,9 +18,8 @@ /** - * SQLServerBlob represents a binary LOB object and implements a java.sql.Blob. + * Represents a binary LOB object and implements a java.sql.Blob. */ - public final class SQLServerBlob extends SQLServerLob implements java.sql.Blob, java.io.Serializable { /** * Always refresh SerialVersionUID when prompted diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java index a3432ff907..0e53e1308b 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java @@ -21,7 +21,7 @@ /** - * A simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types + * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types * from an ArrayList of Parameters that were provided by pstmt/cstmt. */ public class SQLServerBulkBatchInsertRecord extends SQLServerBulkCommon { @@ -41,6 +41,9 @@ public class SQLServerBulkBatchInsertRecord extends SQLServerBulkCommon { */ private static final java.util.logging.Logger loggerExternal = java.util.logging.Logger.getLogger(loggerClassName); + /* + * Constructs a SQLServerBulkBatchInsertRecord with the batch parameter, column list, value list, and encoding + */ public SQLServerBulkBatchInsertRecord(ArrayList batchParam, ArrayList columnList, ArrayList valueList, String encoding) throws SQLServerException { loggerExternal.entering(loggerClassName, "SQLServerBulkBatchInsertRecord", new Object[] {batchParam, encoding}); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java index c8e6b27b2e..3d60438a8e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java @@ -25,7 +25,7 @@ /** - * A simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types + * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types * from a delimited file where each line represents a row of data. */ public class SQLServerBulkCSVFileRecord extends SQLServerBulkCommon implements java.lang.AutoCloseable { @@ -57,7 +57,7 @@ public class SQLServerBulkCSVFileRecord extends SQLServerBulkCommon implements j private static final java.util.logging.Logger loggerExternal = java.util.logging.Logger.getLogger(loggerClassName); /** - * Creates a simple reader to parse data from a delimited file with the given encoding. + * Contructs a simple reader to parse data from a delimited file with the given encoding. * * @param fileToParse * File to parse data from @@ -111,7 +111,7 @@ public SQLServerBulkCSVFileRecord(String fileToParse, String encoding, String de } /** - * Creates a simple reader to parse data from a delimited file with the given encoding. + * Constructs a SQLServerBulkCSVFileRecord to parse data from a delimited file with the given encoding. * * @param fileToParse * InputStream to parse data from @@ -162,7 +162,7 @@ public SQLServerBulkCSVFileRecord(InputStream fileToParse, String encoding, Stri } /** - * Creates a simple reader to parse data from a CSV file with the given encoding. + * Constructs a SQLServerBulkCSVFileRecord to parse data from a CSV file with the given encoding. * * @param fileToParse * File to parse data from @@ -179,7 +179,7 @@ public SQLServerBulkCSVFileRecord(String fileToParse, String encoding, } /** - * Creates a simple reader to parse data from a CSV file with the default encoding. + * Constructs a SQLServerBulkCSVFileRecord to parse data from a CSV file with the default encoding. * * @param fileToParse * File to parse data from diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index c7e9ce2b33..b464255806 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -50,7 +50,7 @@ /** - * Lets you efficiently bulk load a SQL Server table with data from another source.
+ * Provides functionality to efficiently bulk load a SQL Server table with data from another source.
*
* Microsoft SQL Server includes a popular command-prompt utility named bcp for moving data from one table to another, * whether on a single server or between servers. The SQLServerBulkCopy class lets you write code solutions in Java that @@ -315,8 +315,7 @@ public void run() { private static final int sourceBulkRecordTemporalMaxPrecision = 50; /** - * Initializes a new instance of the SQLServerBulkCopy class using the specified open instance of - * SQLServerConnection. + * Constructs a SQLServerBulkCopy using the specified open instance of SQLServerConnection. * * @param connection * Open instance of Connection to destination server. Must be from the Microsoft JDBC driver for SQL Server. @@ -349,7 +348,7 @@ public SQLServerBulkCopy(Connection connection) throws SQLServerException { } /** - * Initializes and opens a new instance of SQLServerConnection based on the supplied connectionString. + * Constructs a SQLServerBulkCopy based on the supplied connectionString. * * @param connectionUrl * Connection string for the destination server. @@ -498,7 +497,7 @@ public void close() { } /** - * Gets the name of the destination table on the server. + * Returns the name of the destination table on the server. * * @return Destination table name. */ @@ -527,7 +526,7 @@ public void setDestinationTableName(String tableName) throws SQLServerException } /** - * Gets the current SQLServerBulkCopyOptions. + * Returns the current SQLServerBulkCopyOptions. * * @return Current SQLServerBulkCopyOptions settings. */ @@ -1705,7 +1704,7 @@ private void validateStringBinaryLengths(Object colValue, int srcCol, int destCo } /* - * Retrieves the column metadata for the destination table (and saves it for later) + * Returns the column metadata for the destination table (and saves it for later) */ private void getDestinationMetadata() throws SQLServerException { if (null == destinationTableName) { @@ -1771,7 +1770,7 @@ private void getDestinationMetadata() throws SQLServerException { } /* - * Retrieves the column metadata for the source (and saves it for later). Retrieving source metadata in + * Returns the column metadata for the source (and saves it for later). Retrieving source metadata in * BulkColumnMetaData object helps to access source metadata from the same place for both ResultSet and File. */ private void getSourceMetadata() throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java index 7f353e2c4e..081cf10b2d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java @@ -9,7 +9,7 @@ /** - * A collection of settings that control how an instance of SQLServerBulkCopy behaves. Used when constructing a + * Provides a collection of settings that control how an instance of SQLServerBulkCopy behaves. Used when constructing a * SQLServerBulkCopy instance to change how the writeToServer methods for that instance behave. */ public class SQLServerBulkCopyOptions { @@ -81,7 +81,7 @@ public class SQLServerBulkCopyOptions { private boolean allowEncryptedValueModifications; /** - * Initializes an instance of the SQLServerBulkCopySettings class using defaults for all of the settings. + * Constructs a SQLServerBulkCopySettings class using defaults for all of the settings. */ public SQLServerBulkCopyOptions() { batchSize = 0; @@ -96,7 +96,7 @@ public SQLServerBulkCopyOptions() { } /** - * Gets the number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server. + * Returns the number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server. * * @return Number of rows in each batch. */ @@ -123,7 +123,7 @@ public void setBatchSize(int batchSize) throws SQLServerException { } /** - * Gets the number of seconds for the operation to complete before it times out. + * Returns the number of seconds for the operation to complete before it times out. * * @return Number of seconds before operation times out. */ @@ -150,7 +150,7 @@ public void setBulkCopyTimeout(int timeout) throws SQLServerException { } /** - * Indicates whether or not to preserve any source identity values. + * Returns whether or not to preserve any source identity values. * * @return True if source identity values are to be preserved; false if they are to be assigned by the destination. */ @@ -169,7 +169,7 @@ public void setKeepIdentity(boolean keepIdentity) { } /** - * Indicates whether to preserve null values in the destination table regardless of the settings for default values, + * Returns whether to preserve null values in the destination table regardless of the settings for default values, * or if they should be replaced by default values (where applicable). * * @return True if null values should be preserved; false if null values should be replaced by default values where @@ -192,7 +192,7 @@ public void setKeepNulls(boolean keepNulls) { } /** - * Indicates whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation. + * Returns whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation. * * @return True to obtain row locks; false otherwise. */ @@ -211,7 +211,7 @@ public void setTableLock(boolean tableLock) { } /** - * Indicates whether each batch of the bulk-copy operation will occur within a transaction or not. + * Returns whether each batch of the bulk-copy operation will occur within a transaction or not. * * @return True if the batch will occur within a transaction; false otherwise. */ @@ -230,7 +230,7 @@ public void setUseInternalTransaction(boolean useInternalTransaction) { } /** - * Indicates whether constraints are to be checked while data is being inserted or not. + * Returns whether constraints are to be checked while data is being inserted or not. * * @return True if constraints are to be checked; false otherwise. */ @@ -249,7 +249,7 @@ public void setCheckConstraints(boolean checkConstraints) { } /** - * Indicates if the server should fire insert triggers for rows being inserted into the database. + * Returns if the server should fire insert triggers for rows being inserted into the database. * * @return True triggers are enabled; false otherwise. */ @@ -268,7 +268,7 @@ public void setFireTriggers(boolean fireTriggers) { } /** - * Indicates if allowEncryptedValueModifications option is enabled or not + * Returns if allowEncryptedValueModifications option is enabled or not * * @return True if allowEncryptedValueModification is set to true; false otherwise. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index 82ad288757..87054ef958 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -30,7 +30,7 @@ /** - * CallableStatement implements JDBC callable statements. CallableStatement allows the caller to specify the procedure + * Provides implementation of JDBC callable statements. 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 *

diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java index cd947d88b4..6b52be79b6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java @@ -30,9 +30,8 @@ /** - * SQLServerClob represents a character LOB object and implements java.sql.Clob. + * Represents a character LOB object and implements java.sql.Clob. */ - public class SQLServerClob extends SQLServerClobBase implements Clob { /** * Always refresh SerialVersionUID when prompted @@ -44,7 +43,7 @@ public class SQLServerClob extends SQLServerClobBase implements Clob { private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerClob"); /** - * Create a new CLOB + * Constructs a SQLServerClob * * @param connection * the database connection this blob is implemented on @@ -292,7 +291,7 @@ public InputStream getAsciiStream() throws SQLException { } /** - * Retrieves the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of + * Returns the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of * characters). * * @throws SQLException @@ -331,7 +330,7 @@ public Reader getCharacterStream(long pos, long length) throws SQLException { } /** - * Retrieves a copy of the specified substring in the CLOB value designated by this Clob object. The substring + * Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring * begins at position pos and has up to length consecutive characters. * * @param pos @@ -377,7 +376,7 @@ public String getSubString(long pos, int length) throws SQLException { } /** - * Retrieves the number of characters in the CLOB value designated by this Clob object. + * Returns the number of characters in the CLOB value designated by this Clob object. * * @throws SQLException * when an error occurs @@ -421,7 +420,7 @@ private void getStringFromStream() throws SQLServerException { } /** - * Retrieves the character position at which the specified Clob object searchstr appears in this Clob object. The + * Returns the character position at which the specified Clob object searchstr appears in this Clob object. The * search begins at position start. * * @param searchstr @@ -449,7 +448,7 @@ public long position(Clob searchstr, long start) throws SQLException { } /** - * Retrieves the character position at which the specified substring searchstr appears in the SQL CLOB value + * Returns the character position at which the specified substring searchstr appears in the SQL CLOB value * represented by this Clob object. The search begins at position start. * * @param searchstr @@ -508,7 +507,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, + * Returns a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, * starting at position pos. * * @param pos @@ -530,7 +529,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 + * Returns 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 diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index 9852513bc1..03b38f5141 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -72,8 +72,8 @@ public String getName() { } /** - * Constructor that takes a callback function to authenticate to AAD. This is used by KeyVaultClient at runtime to - * authenticate to Azure Key Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD and an executor service.. + * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * This constructor is present to maintain backwards compatibility with 6.0 version of the driver. Deprecated for * removal in next stable release. @@ -94,8 +94,8 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider( } /** - * Constructor that takes a callback function to authenticate to AAD. This is used by KeyVaultClient at runtime to - * authenticate to Azure Key Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD. + * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * @param authenticationCallback * - Callback function used for authenticating to AAD. @@ -117,8 +117,8 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider( } /** - * Constructor that authenticates to AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key - * Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a client id and client key to authenticate to AAD. + * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * @param clientId * Identifier of the client requesting the token. @@ -133,8 +133,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(String clientId, String cl } /** - * This function uses the asymmetric key specified by the key path and decrypts an encrypted CEK with RSA encryption - * algorithm. + * Decryptes an encrypted CEK with RSA encryption algorithm using the asymmetric key specified by the key path * * @param masterKeyPath * - Complete path of an asymmetric key in AKV @@ -270,7 +269,7 @@ private short convertTwoBytesToShort(byte[] input, int index) throws SQLServerEx } /** - * This function uses the asymmetric key specified by the key path and encrypts CEK with RSA encryption algorithm. + * Encrypts CEK with RSA encryption algorithm using the asymmetric key specified by the key path * * @param masterKeyPath * - Complete path of an asymmetric key in AKV @@ -554,7 +553,7 @@ private boolean AzureKeyVaultVerifySignature(byte[] dataToVerify, byte[] signatu } /** - * Gets the public Key size in bytes + * Returns the public Key size in bytes * * @param masterKeyPath * - Azure Key Vault Key path diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index eb2cd0722d..7f873e56ea 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -25,7 +25,7 @@ /** - * The implementation of the key store provider for the Windows Certificate Store. This class enables using keys stored + * Provides 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. * */ @@ -50,6 +50,9 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL } private Path keyStoreDirectoryPath = null; + /** + * Constructs a SQLServerColumnEncryptionCertificateStoreProvider + */ public SQLServerColumnEncryptionCertificateStoreProvider() { windowsCertificateStoreLogger.entering(SQLServerColumnEncryptionCertificateStoreProvider.class.getName(), "SQLServerColumnEncryptionCertificateStoreProvider"); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index 608ca98ca4..bf825a7e4e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -33,7 +33,7 @@ /** * - * The implementation of the key store provider for Java Key Store. This class enables using certificates stored in the + * Provides 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. * */ @@ -54,7 +54,7 @@ public String getName() { } /** - * Key store provider for the Java Key Store. + * Constructs a SQLServerColumnEncryptionJavaKeyStoreProvider for the Java Key Store. * * @param keyStoreLocation * specifies the location of the keystore diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java index 2778f9c132..c670139431 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java @@ -7,6 +7,7 @@ /** * + * Defines the abtract class for a SQL Server Column Encryption key store provider * Extend this class to implement a custom key store provider. * */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 86998e04a7..8e51c929fc 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -52,7 +52,7 @@ /** - * SQLServerConnection implements a JDBC connection to SQL Server. SQLServerConnections support JDBC connection pooling + * Provides implementation 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 @@ -214,12 +214,12 @@ private boolean isExplicitlyDiscarded() { return explicitlyDiscarded; } - /** Get the actual handle. */ + /** Returns the actual handle. */ int getHandle() { return handle; } - /** Get the cache key. */ + /** Returns the cache key. */ CityHash128Key getKey() { return key; } @@ -495,7 +495,7 @@ final int getQueryTimeoutSeconds() { private int cancelQueryTimeoutSeconds; /** - * Retrieves the cancelTimeout in seconds + * Returns the cancelTimeout in seconds * * @return */ @@ -515,7 +515,7 @@ final int getSocketTimeoutMilliseconds() { private boolean useBulkCopyForBatchInsert; /** - * Retrieves the useBulkCopyForBatchInsert value. + * Returns the useBulkCopyForBatchInsert value. * * @return flag for using Bulk Copy API for batch insert operations. */ @@ -775,7 +775,7 @@ public static synchronized void removeColumnEncryptionTrustedMasterKeyPaths(Stri } /** - * Retrieves the Trusted Master Key Paths. + * Returns the Trusted Master Key Paths. * * @return columnEncryptionTrustedMasterKeyPaths. */ @@ -1065,7 +1065,7 @@ void checkClosed() throws SQLServerException { } /** - * Check if a string property is enabled. + * Returns if a string property is enabled. * * @param propName * the string property name @@ -2938,7 +2938,7 @@ private String sqlStatementToInitialize() { } /** - * Return the syntax to set the database calatog to use. + * Sets the syntax to set the database calatog to use. * * @param sDB * the new catalog @@ -2953,7 +2953,7 @@ void setCatalogName(String sDB) { } /** - * Return the syntax to set the database isolation level. + * Returns the syntax to set the database isolation level. * * @return the required syntax */ @@ -2991,7 +2991,7 @@ String sqlStatementToSetTransactionIsolationLevel() throws SQLServerException { } /** - * Return the syntax to set the database commit mode. + * Returns the syntax to set the database commit mode. * * @return the required syntax */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java index d3903938c2..ffdad25361 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java @@ -10,8 +10,8 @@ /** - * SQLServerConnection43 extends {@link SQLServerConnection43} class and implements {@link ISQLServerConnection43} with - * methods introduced in JDBC 4.3 Specifications. This class is used by the drdiver when initializing a class with 43 + * Extends {@link SQLServerConnection43} class and implements {@link ISQLServerConnection43} with + * methods introduced in JDBC 4.3 Specifications. This class is used by the driver when initializing a class with 43 * driver version */ public class SQLServerConnection43 extends SQLServerConnection implements ISQLServerConnection43 { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java index a63891c3f2..06f63792b3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java @@ -14,7 +14,7 @@ /** - * SQLServerConnectionPoolDataSource provides physical database connections for connection pool managers. + * Provides physical database connections for connection pool managers. * SQLServerConnectionPoolDataSource is typically used in Java Application Server environments that support built-in * connection pooling and require a ConnectionPoolDataSource to provide physical connections. For example, J2EE * application servers that provide JDBC 3.0 API spec connection pooling. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataColumn.java index 2357e47d61..218f58dbbf 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 @@ package com.microsoft.sqlserver.jdbc; /** - * This class represents a column of the in-memory data table represented by SQLServerDataTable. + * Represents a column of the in-memory data table represented by {@link SQLServerDataTable}. */ public final class SQLServerDataColumn { String columnName; @@ -16,7 +16,7 @@ public final class SQLServerDataColumn { int numberOfDigitsIntegerPart = 0; /** - * Initializes a new instance of SQLServerDataColumn with the column name and type. + * Constructs a SQLServerDataColumn with the column name and type. * * @param columnName * the name of the column @@ -29,7 +29,7 @@ public SQLServerDataColumn(String columnName, int sqlType) { } /** - * Retrieves the column name. + * Returns the column name. * * @return the name of the column. */ @@ -38,11 +38,11 @@ public String getColumnName() { } /** - * Retrieves the column type. + * Returns the column type. * * @return the column type. */ public int getColumnType() { return javaSqlType; } -} \ No newline at end of file +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index c6a0dad5cb..d2ff110e62 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -21,7 +21,7 @@ /** - * This datasource lists properties specific for the SQLServerConnection class. + * Contains a list of properties specific for the {@link SQLServerConnection} class. */ public class SQLServerDataSource implements ISQLServerDataSource, javax.sql.DataSource, java.io.Serializable, javax.naming.Referenceable { @@ -57,7 +57,7 @@ public class SQLServerDataSource final private String traceID; /** - * Initializes a new instance of the SQLServerDataSource class. + * Constructs a SQLServerDataSource */ public SQLServerDataSource() { connectionProps = new Properties(); @@ -125,7 +125,7 @@ public void setLogWriter(PrintWriter out) { loggerExternal.exiting(getClassNameLogging(), "setLogWriter"); } - // Retrieves the log writer for this DataSource. + // Returns the log writer for this DataSource. @Override public PrintWriter getLogWriter() { loggerExternal.entering(getClassNameLogging(), "getLogWriter"); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 82af8db656..3b49cc8720 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -14,22 +14,24 @@ /** - * SQLServerDataSourceObjectFactory is an object factory to materialize datasources from JNDI. + * Defines an object factory to materialize datasources from JNDI. */ - 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. + * Constructs a SQLServerDataSourceObjectFactory */ public SQLServerDataSourceObjectFactory() {} - // getObjectInstance is a factory for rehydrating references to SQLServerDataSource and its child classes. - // Caller gets the reference by calling SQLServerDataSource.getReference. - // References are used by JNDI to persist and rehydrate objects. + /** + * Returns an reference to the SQLServerDataSource instance + * getObjectInstance is a factory for rehydrating references to SQLServerDataSource and its child classes. + * Caller gets the reference by calling SQLServerDataSource.getReference. + * References are used by JNDI to persist and rehydrate objects. + */ public Object getObjectInstance(Object ref, Name name, Context c, Hashtable h) throws SQLServerException { // Create a new instance of a DataSource class from the given reference. try { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index 634d2d85d8..269f0d3d0a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -19,6 +19,9 @@ import java.util.UUID; +/** + * Represents the data table for SQL Server. + */ public final class SQLServerDataTable { int rowCount = 0; @@ -54,7 +57,7 @@ public synchronized void clear() { } /** - * Retrieves an iterator on the rows of the data table. + * Returns an iterator on the rows of the data table. * * @return an iterator on the rows of the data table. */ @@ -294,7 +297,7 @@ else if (val instanceof OffsetTime) } /** - * Retrieves java.util.Map object type of columnMetaData for all columns where column indexes are + * Returns the java.util.Map object type of columnMetaData for all columns where column indexes are * mapped with their respective {@link SQLServerDataColumn} Java object * * @return Map diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 21b37244dc..f4606fe91a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -20,7 +20,7 @@ /** - * SQLServerDatabaseMetaData provides JDBC database meta data. + * Provides the JDBC database meta data. * * 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. @@ -2445,4 +2445,4 @@ final Object apply(Object value, JDBCType asJDBCType) throws SQLServerException } } -} \ No newline at end of file +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 0245fc2c56..4655b4c488 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -359,7 +359,11 @@ public String toString() { } } - +/** + * + * Provides methods to connect to a SQL Server database and to obtain information about the JDBC driver. + * + */ public final class SQLServerDriver implements java.sql.Driver { static final String PRODUCT_NAME = "Microsoft JDBC Driver " + SQLJdbcVersion.major + "." + SQLJdbcVersion.minor + " for SQL Server"; @@ -624,7 +628,7 @@ static Properties mergeURLAndSuppliedProperties(Properties urlProps, } /** - * normalize the property names + * Returns the normalized the property names * * @param name * name to normalize @@ -652,7 +656,7 @@ static String getNormalizedPropertyName(String name, Logger logger) { } /** - * get property-only names that do not work with connection string + * Returns the property-only names that do not work with connection string * * @param name * to normalize @@ -674,7 +678,7 @@ static String getPropertyOnlyName(String name, Logger logger) { return null; } - /* L0 */ public java.sql.Connection connect(String Url, Properties suppliedProperties) throws SQLServerException { + public java.sql.Connection connect(String Url, Properties suppliedProperties) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "connect", "Arguments not traced."); SQLServerConnection result = null; @@ -713,7 +717,7 @@ private Properties parseAndMergeProperties(String Url, Properties suppliedProper return connectProperties; } - /* L0 */ public boolean acceptsURL(String url) throws SQLServerException { + public boolean acceptsURL(String url) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "acceptsURL", "Arguments not traced."); if (null == url) { @@ -768,7 +772,7 @@ public Logger getParentLogger() throws SQLFeatureNotSupportedException { return parentLogger; } - /* L0 */ public boolean jdbcCompliant() { + public boolean jdbcCompliant() { loggerExternal.entering(getClassNameLogging(), "jdbcCompliant"); loggerExternal.exiting(getClassNameLogging(), "jdbcCompliant", Boolean.TRUE); return true; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java index 881ce780a5..60feb165c4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java @@ -11,12 +11,6 @@ import java.util.logging.Level; -/** - * SQLServerException is thrown from any point in the driver that throws a java.sql.SQLException. SQLServerException - * handles both SQL 92 and XOPEN state codes. They are switchable via a user specified connection property. - * SQLServerExceptions are written to any open log files the user has specified. - */ - enum SQLState { STATEMENT_CANCELED("HY008"), DATA_EXCEPTION_NOT_SPECIFIC("22000"), @@ -51,6 +45,11 @@ final int getErrorCode() { } +/** + * Represents the exception thrown from any point in the driver that throws a java.sql.SQLException. SQLServerException + * handles both SQL 92 and XOPEN state codes. They are switchable via a user specified connection property. + * SQLServerExceptions are written to any open log files the user has specified. + */ public final class SQLServerException extends java.sql.SQLException { static final String EXCEPTION_XOPEN_CONNECTION_CANT_ESTABLISH = "08001"; static final String EXCEPTION_XOPEN_CONNECTION_DOES_NOT_EXIST = "08003"; @@ -90,7 +89,7 @@ final void setDriverErrorCode(int value) { } /** - * Log an exception to the driver log file + * Logs an exception to the driver log file * * @param o * the io buffer that generated the exception @@ -162,14 +161,14 @@ public SQLServerException(String errText, Throwable cause) { ActivityCorrelator.setCurrentActivityIdSentFlag(); } - /* L0 */ public SQLServerException(Object obj, String errText, String errState, int errNum, boolean bStack) { + public SQLServerException(Object obj, String errText, String errState, int errNum, boolean bStack) { super(errText, errState, errNum); logException(obj, errText, bStack); ActivityCorrelator.setCurrentActivityIdSentFlag(); } /** - * Make a new SQLException + * Constructs a new SQLServerException * * @param obj * the object @@ -182,7 +181,7 @@ public SQLServerException(String errText, Throwable cause) { * @param bStack * true to generate the stack trace */ - /* L0 */ public SQLServerException(Object obj, String errText, String errState, StreamError streamError, + public SQLServerException(Object obj, String errText, String errState, StreamError streamError, boolean bStack) { super(errText, errState, streamError.getErrorNumber()); @@ -193,7 +192,7 @@ public SQLServerException(String errText, Throwable cause) { } /** - * Build a new SQL Exception from an error detected by the driver. + * Builds a new SQL Exception from an error detected by the driver. * * @param con * the connection @@ -206,7 +205,7 @@ public SQLServerException(String errText, Throwable cause) { * true to generate the stack trace * @throws SQLServerException */ - /* L0 */static void makeFromDriverError(SQLServerConnection con, Object obj, String errText, String state, + static void makeFromDriverError(SQLServerConnection con, Object obj, String errText, String state, boolean bStack) throws SQLServerException { // The sql error code is 0 since the error was not returned from the database // The state code is supplied by the calling code as XOPEN compliant. @@ -232,7 +231,7 @@ public SQLServerException(String errText, Throwable cause) { } /** - * Build a new SQL Exception from a streamError detected by the driver. + * Builds a new SQL Exception from a streamError detected by the driver. * * @param con * the connection @@ -244,7 +243,7 @@ public SQLServerException(String errText, Throwable cause) { * true to generate the stack trace * @throws SQLServerException */ - /* L0 */ static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText, + static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText, StreamError streamError, boolean bStack) throws SQLServerException { String state = generateStateCode(con, streamError.getErrorNumber(), streamError.getErrorState()); @@ -278,13 +277,13 @@ static void ConvertConnectExceptionToSQLServerException(String hostName, int por } /** - * Map XOPEN states. + * Maps XOPEN states. * * @param state * the state * @return the mapped state */ - /* L0 */ static String mapFromXopen(String state) { + static String mapFromXopen(String state) { // Exceptions generated by the driver (not the database) are instanced with an XOPEN state code // since the SQL99 states cant be located on the web (must pay) and the XOPEN states appear to // be specific. Therefore if the driver is in SQL 99 mode we must map to SQL 99 state codes. @@ -307,7 +306,7 @@ static void ConvertConnectExceptionToSQLServerException(String hostName, int por } /** - * Generate the JDBC state code based on the error number returned from the database + * Generates the JDBC state code based on the error number returned from the database * * @param con * the connection @@ -317,7 +316,7 @@ static void ConvertConnectExceptionToSQLServerException(String hostName, int por * the database state * @return the state code */ - /* L0 */ static String generateStateCode(SQLServerConnection con, int errNum, int databaseState) { + static String generateStateCode(SQLServerConnection con, int errNum, int databaseState) { // Generate a SQL 99 or XOPEN state from a database generated error code boolean xopenStates = (con != null && con.xopenStates); if (xopenStates) { @@ -360,7 +359,7 @@ static void ConvertConnectExceptionToSQLServerException(String hostName, int por } /** - * Append ClientConnectionId to an error message if applicable + * Appends ClientConnectionId to an error message if applicable * * @param errMsg * - the orginal error message. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java index 7358279bfa..daa475b995 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerKeyVaultAuthenticationCallback.java @@ -5,10 +5,14 @@ package com.microsoft.sqlserver.jdbc; +/** + * Provides a callback delegate which is to be implemented by the client code + * + */ public interface SQLServerKeyVaultAuthenticationCallback { /** - * The authentication callback delegate which is to be implemented by the client code + * Returns the acesss token of the authentication request * * @param authority * - Identifier of the authority, a URL. @@ -19,4 +23,4 @@ public interface SQLServerKeyVaultAuthenticationCallback { * @return access token */ public String getAccessToken(String authority, String resource, String scope); -} \ No newline at end of file +} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java index 9e7144f126..8f2316b700 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java @@ -10,7 +10,7 @@ /** * - * This class represents metadata for a column. It is used in the ISQLServerDataRecord interface to pass column metadata + * Represents metadata for a column. It is used in the ISQLServerDataRecord interface to pass column metadata * to the table-valued parameter. * */ @@ -29,7 +29,7 @@ public class SQLServerMetaData { static final int defaultSortOrdinal = -1; /** - * Creates a new SQLServerMetaData + * Constructs a SQLServerMetaData with the column name and SQL type * * @param columnName * the name of the column @@ -42,7 +42,7 @@ public SQLServerMetaData(String columnName, int sqlType) { } /** - * creates a new SQLServerMetaData + * Constructs a SQLServerMetaData with the column name, SQL type, precision, and scale * * @param columnName * the name of the column @@ -61,7 +61,7 @@ public SQLServerMetaData(String columnName, int sqlType, int precision, int scal } /** - * Creates a new SQLServerMetaData + * Constructs a SQLServerMetaData * * @param columnName * the name of the column @@ -96,7 +96,7 @@ public SQLServerMetaData(String columnName, int sqlType, int precision, int scal } /** - * Initializes a new instance of SQLServerMetaData from another SQLServerMetaData object. + * Constructs a SQLServerMetaData from another SQLServerMetaData object. * * @param sqlServerMetaData * the object passed to initialize a new instance of SQLServerMetaData @@ -113,69 +113,73 @@ public SQLServerMetaData(SQLServerMetaData sqlServerMetaData) { } /** - * - * @return Retrieves the column name. + * Returns the column name. + * @return column name */ public String getColumName() { return columnName; } /** - * - * @return Retrieves the java sql type. + * Returns the java sql type. + * @return java sql type */ public int getSqlType() { return javaSqlType; } /** - * - * @return retrieves the precision of the type passed to the column. + * Returns the precision of the type passed to the column. + * @return precision */ public int getPrecision() { return precision; } /** - * - * @return retrieves the scale of the type passed to the column. + * Returns the scale of the type passed to the column. + * @return scale */ public int getScale() { return scale; } /** - * - * @return returns whether the column uses the default server value. + * Returns whether the column uses the default server value. + * @return whether the column uses the default server value. */ public boolean useServerDefault() { return useServerDefault; } /** - * - * @return retrieves the whether the column is unique. + * Returns whether the column is unique. + * @return whether the column is unique. */ public boolean isUniqueKey() { return isUniqueKey; } /** - * - * @return retrieves the sort order. + * Returns the sort order. + * @return sort order */ public SQLServerSortOrder getSortOrder() { return sortOrder; } /** - * - * @return retrieves the sort ordinal. + * Returns the sort ordinal. + * @return sort ordinal */ public int getSortOrdinal() { return sortOrdinal; } + /** + * Returns collation. + * @return SQL collation + */ SQLCollation getCollation() { return this.collation; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java index 7988ba3767..dfa9fb12d9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNClob.java @@ -17,9 +17,8 @@ /** - * SQLServerNClob represents a National Character Set LOB object and implements java.sql.NClob. + * Represents a National Character Set LOB object and implements java.sql.NClob. */ - public final class SQLServerNClob extends SQLServerClobBase implements NClob { /** diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 3d00845f60..a33fc8a5da 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -21,7 +21,7 @@ /** - * SQLServerParameterMetaData provides JDBC 3.0 meta data for prepared statement parameters. + * Provides JDBC 3.0 meta data for prepared statement parameters. * * 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. @@ -60,7 +60,7 @@ private static int nextInstanceID() { } /** - * This is a helper function to provide an ID string suitable for tracing. + * Provides a helper function to provide an ID string suitable for tracing. * * @return traceID string */ @@ -70,7 +70,7 @@ final public String toString() { } /** - * Parse the columns in a column set. + * Parses the columns in a column set. * * @param columnSet * the list of columns @@ -131,7 +131,7 @@ private String parseColumns(String columnSet, String columnStartToken) throws SQ } /** - * Parse the column set in an insert syntax. + * Parses the column set in an insert syntax. * * @param sql * the sql syntax @@ -203,7 +203,7 @@ class QueryMeta { Map queryMetaMap = null; /* - * Parse query metadata. + * Parses query metadata. */ private void parseQueryMeta(ResultSet rsQueryMeta) throws SQLServerException { Pattern datatypePattern = Pattern.compile("(.*)\\((.*)(\\)|,(.*)\\))"); @@ -325,7 +325,7 @@ private void parseQueryMetaFor2008(ResultSet rsQueryMeta) throws SQLServerExcept } /** - * Escape parser, using the tokenizer tokenizes escaped strings properly e.g.[Table Name, ] + * Parses escaped strings properly e.g.[Table Name, ] using tokenizer * * @param st * string tokenizer @@ -372,7 +372,7 @@ private class MetaInfo { } /** - * Parse a SQL syntax. + * Parses a SQL syntax. * * @param sql * String @@ -427,7 +427,7 @@ private MetaInfo parseStatement(String sql, String sTableMarker) throws SQLServe } /** - * Parse a SQL syntax. + * Parses a SQL syntax. * * @param sql * the syntax @@ -534,7 +534,7 @@ private void checkClosed() throws SQLServerException { } /** - * Create new parameter meta data. + * Construct a SQLServerParameterMetaData parameter meta data. * * @param st * the prepared statement diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java index e37adc6ccd..dd7952b689 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java @@ -18,7 +18,7 @@ /** - * SQLServerPooledConnection represents a database physical connection in a connection pool. If provides methods for the + * 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. */ @@ -57,7 +57,7 @@ public class SQLServerPooledConnection implements PooledConnection { } /** - * This is a helper function to provide an ID string suitable for tracing. + * Provides a helper function to provide an ID string suitable for tracing. * * @return traceID String */ @@ -72,7 +72,7 @@ private SQLServerConnection createNewConnection() throws SQLException { } /** - * Creates an object handle for the physical connection that this PooledConnection object represents. + * Returns an object handle for the physical connection that this PooledConnection object represents. * * @throws SQLException * when an error occurs diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 2a4c4f0ec2..4aef3148be 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -34,7 +34,7 @@ /** - * SQLServerPreparedStatement provides JDBC prepared statement functionality. SQLServerPreparedStatement provides + * 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 @@ -46,7 +46,6 @@ * 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 { /** Flag to indicate that it is an internal query to retrieve encryption metadata. */ boolean isInternalEncryptionQuery = false; @@ -116,7 +115,7 @@ private void setPreparedStatementHandle(int handle) { private boolean useBulkCopyForBatchInsert; /** - * Gets the prepared statement's useBulkCopyForBatchInsert value. + * Returns the prepared statement's useBulkCopyForBatchInsert value. * * @return Per the description. * @throws SQLServerException @@ -188,7 +187,7 @@ String getClassNameInternal() { } /** - * Create a new prepaed statement. + * Constructs a SQLServerPreparedStatement * * @param conn * the connection @@ -238,7 +237,7 @@ String getClassNameInternal() { } /** - * Close the prepared statement's prepared handle. + * Closes the prepared statement's prepared handle. */ private void closePreparedHandle() { if (!hasPreparedStatementHandle()) @@ -336,7 +335,7 @@ final void closeInternal() { } /** - * Intialize the statement parameters. + * Intializes the statement parameters. * * @param nParams * Number of parameters to Intialize. @@ -382,7 +381,7 @@ private boolean buildPreparedStrings(Parameter[] params, boolean renewDefinition } /** - * Build the parameter type definitons for a JDBC prepared statement that will be used to prepare the statement. + * Builds the parameter type definitons for a JDBC prepared statement that will be used to prepare the statement. * * @param params * the statement parameters @@ -438,7 +437,7 @@ public java.sql.ResultSet executeQuery() throws SQLServerException, SQLTimeoutEx } /** - * Execute a query without cursoring for metadata. + * Executes a query without cursoring for metadata. * * @throws SQLServerException * @return ResultSet @@ -596,8 +595,8 @@ final void doExecutePreparedStatement(PrepStmtExecCmd command) throws SQLServerE } /** - * Should the execution be retried because the re-used cached handle could not be re-used due to server side state - * changes? + * Returns if the execution should be retried because the re-used cached handle could not be re-used due to server side state + * changes */ private boolean retryBasedOnFailedReuseOfCachedHandle(SQLException e, int attempt, boolean needsPrepare, boolean isBatch) { @@ -613,7 +612,7 @@ private boolean retryBasedOnFailedReuseOfCachedHandle(SQLException e, int attemp } /** - * Consume the OUT parameter for the statement object itself. + * Consumes the OUT parameter for the statement object itself. * * When a prepared statement handle is expected as the first OUT parameter from PreparedStatement or * CallableStatement execution, then it gets consumed here. @@ -660,7 +659,7 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException { } /** - * Send the statement parameters by RPC + * Sends the statement parameters by RPC */ void sendParamsByRPC(TDSWriter tdsWriter, Parameter[] params) throws SQLServerException { char cParamName[]; @@ -1065,7 +1064,7 @@ public final java.sql.ResultSetMetaData getMetaData() throws SQLServerException } /** - * Retreive meta data for the statement before executing it. This is called in cases where the driver needs the meta + * Returns meta data for the statement before executing it. This is called in cases where the driver needs the meta * data prior to executing the statement. * * @throws SQLServerException @@ -1094,7 +1093,7 @@ private ResultSet buildExecuteMetaData() throws SQLServerException { /* -------------- JDBC API Implementation ------------------ */ /** - * Set the parameter value for a statement. + * Sets the parameter value for a statement. * * @param index * The index of the parameter to set starting at 1. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java index 5f78cd0722..609dc7e135 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java @@ -9,7 +9,7 @@ /** - * A simple resource bundle containing the strings for localizing. + * Represents a simple resource bundle containing the strings for localizing. * */ public final class SQLServerResource extends ListResourceBundle { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index b017691bfd..5309dd1ad5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -43,7 +43,7 @@ enum RowType { /** - * Top-level JDBC ResultSet implementation + * Defines the Top-level JDBC ResultSet implementation. */ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializable { @@ -188,7 +188,7 @@ final void setDeletedCurrentRow(boolean rowDeleted) { // The CekTable retrieved from the COLMETADATA token for this resultset. private CekTable cekTable = null; - /* Gets the CekTable */ + /* Returns the CekTable */ CekTable getCekTable() { return cekTable; } @@ -228,7 +228,7 @@ public SensitivityClassification getSensitivityClassification() { } /** - * Make a new result set + * Constructs a SQLServerResultSet * * @param stmtIn * the generating statement @@ -434,7 +434,7 @@ public T unwrap(Class iface) throws SQLException { private SQLServerException rowErrorException = null; /** - * Check if the result set is closed + * Checks if the result set is closed * * @throws SQLServerException */ @@ -505,7 +505,7 @@ private void verifyResultSetIsUpdatable() throws SQLServerException { } /** - * Checks whether the result set has a current row. + * Returns if whether the result set has a current row. * * @return true if there is a current row * @return false if the result set is positioned before the first row or after the last row. @@ -763,7 +763,7 @@ private Column loadColumn(int index) throws SQLServerException { } /** - * Clear result set warnings + * Clears result set warnings * * @throws SQLServerException * when an error occurs @@ -964,7 +964,7 @@ private void updateCurrentRow(int rowsToMove) { } /** - * Initially moves the cursor to the first row of this ResultSet object, with subsequent calls moving the cursor to + * Moves the cursor to the first row of this ResultSet object initially, then subsequent calls moves the cursor to * the second row, the third row, and so on. * * @return false when there are no more rows to read @@ -1171,7 +1171,7 @@ public boolean isAfterLast() throws SQLException { } /** - * Retrieves whether the cursor is on the first row of this ResultSet object. + * Returns whether the cursor is on the first row of this ResultSet object. * * This method should be called only on ResultSet objects that are scrollable: TYPE_SCROLL_SENSITIVE, * TYPE_SCROLL_INSENSITIVE, TYPE_SS_SCROLL_STATIC, TYPE_SS_SCROLL_KEYSET, TYPE_SS_SCROLL_DYNAMIC. @@ -1218,7 +1218,7 @@ public boolean isFirst() throws SQLException { } /** - * Retrieves whether the cursor is on the last row of this ResultSet object. Note: + * Returns whether the cursor is on the last row of this ResultSet object. Note: * Calling the method isLast may be expensive because the JDBC driver might need to fetch ahead one row * in order to determine whether the current row is the last row in the result set. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java index 5da5fbf20d..a9d52ee683 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java @@ -10,13 +10,13 @@ /** + * Provides an implementation of the result set metadata to the SQL Server. * A ResultSetMetaData object can be used to obtain the meta data (types and type properties) of the columns in a * ResultSet. * * 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 final class SQLServerResultSetMetaData implements ISQLServerResultSetMetaData { private SQLServerConnection con; private final SQLServerResultSet rs; @@ -37,7 +37,7 @@ final public String toString() { } /** - * Create a new meta data object for the result set. + * Constructs a SQLServerResultSetMetaData meta data object for the result set. * * @param con * the connection diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java index 22d60f3faf..26ceb7b106 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java @@ -218,7 +218,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 + * Sets 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. * * @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 f061713dbc..2a921f8dbd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java @@ -9,7 +9,7 @@ /** - * SQLServerSavepoint implements JDBC 3.0 savepoints. A savepoint is checkpoint to which a transaction can be rolled + * Provides an implementation of the 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 @@ -22,7 +22,7 @@ public final class SQLServerSavepoint implements ISQLServerSavepoint { private final SQLServerConnection con; /** - * Create a new savepoint + * Constructs a SQLServerSavepoint * * @param con * the connection diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 44803122b1..00996951ed 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -29,7 +29,7 @@ /** - * SQLServerStatment provides the basic implementation of JDBC statement functionality. It also provides a number of + * Provides the basic implementation of JDBC statement functionality. It also provides a number of * base class implementation methods for the JDBC prepared statement and callable Statements. SQLServerStatement's basic * role is to execute SQL statements and return update counts and resultset rows to the user application. * @@ -103,7 +103,7 @@ final boolean wasExecuted() { Parameter[] inOutParam; // Parameters for prepared stmts and stored procedures /** - * The statements connection. + * The statement's connection. */ final SQLServerConnection connection; @@ -346,7 +346,7 @@ final int getCursorType() { } /** - * Indicates whether to request a server cursor when executing this statement. + * Returns whether to request a server cursor when executing this statement. * * Executing a statement with execute() or executeQuery() requests a server cursor in all scrollability and * updatability combinations except direct forward-only, read-only. @@ -464,7 +464,7 @@ boolean onDone(TDSReader tdsReader) throws SQLServerException { static final private java.util.logging.Logger stmtlogger = java.util.logging.Logger .getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerStatement"); - /** The statement's id for logging info */ + /** Returns the statement's id for logging info */ @Override public String toString() { return traceID; @@ -483,7 +483,7 @@ private static int nextStatementID() { } /** - * The regular statement constructor + * Constructs a SQLServerStatement * * @param con * The statements connections. @@ -635,7 +635,7 @@ final java.util.logging.Logger getStatementLogger() { } /** - * Close the statement. + * Closes the statement. * * Note that the public close() method performs all of the cleanup work through this internal method which cannot * throw any exceptions. This is done deliberately to ensure that ALL of the object's client-side and server-side @@ -933,7 +933,7 @@ private void doExecuteStatementBatch(StmtBatchExecCmd execCmd) throws SQLServerE } /** - * Reset the state to get the statement for reexecute callable statement overrides this. + * Resets the state to get the statement for reexecute callable statement overrides this. */ final void resetForReexecute() throws SQLServerException { ensureExecuteResultsReader(null); @@ -945,7 +945,7 @@ final void resetForReexecute() throws SQLServerException { } /** - * Determine if the SQL is a SELECT. + * Determines if the SQL is a SELECT. * * @param sql * The statment SQL. @@ -969,7 +969,7 @@ final boolean isSelect(String sql) throws SQLServerException { * The statment SQL. * @return True if the statement is an insert. */ - /* L0 */ final boolean isInsert(String sql) throws SQLServerException { + final boolean isInsert(String sql) throws SQLServerException { checkClosed(); // Used to check just the first letter which would cause // "Set" commands to return true... @@ -985,7 +985,7 @@ final boolean isSelect(String sql) throws SQLServerException { } /** - * Replace a JDBC parameter marker with the parameter's string value + * Replaces a JDBC parameter marker with the parameter's string value * * @param str * the parameter syntax @@ -1004,7 +1004,7 @@ static String replaceParameterWithString(String str, char marker, String replace } /** - * Set a JDBC parameter to null. (Used only when processing LOB column sources.) + * Sets a JDBC parameter to null. (Used only when processing LOB column sources.) * * @param sql * the parameter syntax @@ -1314,7 +1314,7 @@ final void processResults() throws SQLServerException { } /** - * Check for more results in the TDS stream + * Returns more results in the TDS stream * * @return true if the next result is a ResultSet object; false if it is an integer (indicating that it is an update * count or there are no more results). @@ -1364,7 +1364,7 @@ final void clearLastResult() { } /** - * Get the next result in the TDS response token stream, which may be a result set, update count or exception. + * Returns the next result in the TDS response token stream, which may be a result set, update count or exception. * * @return true if another result (ResultSet or update count) was available; false if there were no more results. */ @@ -1646,7 +1646,7 @@ else if (nextResult.isUpdateCount()) { } /** - * Consume the OUT parameter for the statement object itself. + * Consumes the OUT parameter for the statement object itself. * * Normal Statement objects consume the server cursor OUT params when present. PreparedStatement and * CallableStatement objects override this method to consume the prepared statement handle as well. @@ -1748,7 +1748,7 @@ public void clearBatch() throws SQLServerException { } /** - * Send a batch of statements to the database. + * Sends a batch of statements to the database. */ @Override public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException { @@ -1902,7 +1902,7 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio } // executeLargeBatch /** - * Return the statement's connection + * Returns the statement's connection * * @throws SQLServerException * when an error occurs @@ -1922,15 +1922,6 @@ public final java.sql.Connection getConnection() throws SQLServerException { /* ----------------- Server side cursor support -------------------------- */ - /** - * Open a server side cursor. - * - * @param sql - * The SQL query. - * @exception SQLServerException - * The SQL query was invalid. - */ - final int getResultSetScrollOpt() { int scrollOpt = (null == inOutParam) ? 0 : TDS.SCROLLOPT_PARAMETERIZED_STMT; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java index cd2e4eb515..80eb9a03ae 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSymmetricKeyCache.java @@ -79,7 +79,7 @@ ConcurrentHashMap getCache() { } /** - * Retrieves key + * Returns key * * @param keyInfo * contains encryption meta data information diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java index 81b28c5f3a..bfb18780ca 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAConnection.java @@ -15,7 +15,7 @@ /** - * SQLServerXAConnection provides JDBC connections that can participate in distributed (XA) transactions. + * Provides JDBC connections that can participate in distributed (XA) transactions. */ public final class SQLServerXAConnection extends SQLServerPooledConnection implements XAConnection { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java index c15eb7d842..40c41fbc7e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java @@ -15,7 +15,7 @@ /** - * SQLServerXADataSource provides database connections for use in distributed (XA) transactions. SQLServerXADataSource + * Provides database connections for use in distributed (XA) transactions. SQLServerXADataSource * also supports connection pooling of physical connections. * * The XADataSource and XAConnection interfaces, which are defined in the package javax.sql, are implemented by @@ -40,13 +40,12 @@ * SQLServerXADataSource can be configured to integrate with Microsoft Distributed Transaction Coordinator (DTC) to * provide true, distributed transaction processing. */ - public final class SQLServerXADataSource extends SQLServerConnectionPoolDataSource implements XADataSource { static Logger xaLogger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.XA"); /** - * Obtain a physical database connection to particate in an XA transaction with the specified user and password. + * Returns a physical database connection to particate in an XA transaction with the specified user and password. * This API should only be called by XA connection pool implementations, not regular JDBC application code. * * @return A new XAConnection @@ -79,7 +78,7 @@ public XAConnection getXAConnection(String user, String password) throws SQLExce } /** - * Obtain a physical database connection to particate in an XA transaction. This API should only be called by XA + * Returns a physical database connection to particate in an XA transaction. This API should only be called by XA * connection pool implementations, not regular JDBC application code. * * @return A new XAConnection diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java index 44dbb3ac22..e248212f26 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java @@ -26,7 +26,6 @@ /** * Transaction id implementation used to recover transactions. */ - final class XidImpl implements Xid { private final int formatId; private final byte gtrid[]; @@ -42,7 +41,7 @@ final class XidImpl implements Xid { */ /** - * Create a new XID + * Constructs a XidImpl * * @param formatId * format id @@ -71,7 +70,7 @@ public int getFormatId() { } /** - * Used for tracing + * Returns trace id used for tracing * * @return traceID string */ @@ -103,7 +102,7 @@ final class XAReturnValue { /** - * SQLServerXAResource provides an XAResource for XA distributed transaction management. XA transactions are implemented + * This class provides an XAResource for XA distributed transaction management. XA transactions are implemented * over SQL Server using Microsoft Distributed Transaction Manager (DTC). SQLServerXAResource makes calls to a SQL * Server extended dll called SQLServer_XA.dll which interfaces with DTC. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java b/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java index 2adff66945..4bab44e13c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java @@ -7,11 +7,6 @@ import java.text.MessageFormat; -/** - * This class holds information regarding the basetype of a sql_variant data. - * - */ - /** * Enum for valid probBytes for different TDSTypes * @@ -70,6 +65,10 @@ static sqlVariantProbBytes valueOf(int intValue) { } +/** + * Holds information regarding the basetype of a sql_variant data. + * + */ public class SqlVariant { private int baseType; @@ -82,14 +81,14 @@ public class SqlVariant { private JDBCType baseJDBCType; /** - * Constructor for sqlVariant + * Constructs a SqlVariant */ SqlVariant(int baseType) { this.baseType = baseType; } /** - * Check if the basetype for variant is of time value + * Returns if the basetype for variant is of time value * * @return */ @@ -102,7 +101,7 @@ void setIsBaseTypeTimeValue(boolean isBaseTypeTime) { } /** - * store the base type for sql-variant + * Sets the base type for sql-variant * * @param baseType */ @@ -111,7 +110,7 @@ void setBaseType(int baseType) { } /** - * retrieves the base type for sql-variant + * Returns the base type for sql-variant * * @return */ @@ -129,7 +128,7 @@ void setBaseJDBCType(JDBCType baseJDBCType) { } /** - * retrieves the base type as jdbc type + * Returns the base type as jdbc type * * @return */ @@ -138,7 +137,7 @@ JDBCType getBaseJDBCType() { } /** - * stores the scale if applicable + * Sets the scale if applicable * * @param scale */ @@ -147,7 +146,7 @@ void setScale(int scale) { } /** - * retrieves the scale + * Returns the scale * * @return */ @@ -156,7 +155,7 @@ int getScale() { } /** - * stores the precision if applicable + * Sets the precision if applicable * * @param precision */ @@ -165,7 +164,7 @@ void setPrecision(int precision) { } /** - * retrieves the precision + * Returns the precision * * @return */ @@ -174,7 +173,7 @@ int getPrecision() { } /** - * stores the collation if applicable + * Sets the collation if applicable * * @param collation */ @@ -183,7 +182,7 @@ void setCollation(SQLCollation collation) { } /** - * Retrieves the collation + * Returns the collation * * @return */ @@ -192,7 +191,7 @@ SQLCollation getCollation() { } /** - * stores the maximum length + * Sets the maximum length * * @param maxLength */ @@ -201,7 +200,7 @@ void setMaxLength(int maxLength) { } /** - * retrieves the maximum length + * Returns the maximum length * * @return */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java index f89ba18074..df8b031fdd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java @@ -29,7 +29,7 @@ final class StreamColumns extends StreamPacket { private boolean shouldHonorAEForRead = false; - /* Gets the CekTable */ + /* Returns the CekTable */ CekTable getCekTable() { return cekTable; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StringUtils.java b/src/main/java/com/microsoft/sqlserver/jdbc/StringUtils.java index c792a0cb93..d481117d87 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StringUtils.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StringUtils.java @@ -6,7 +6,7 @@ package com.microsoft.sqlserver.jdbc; /** - * Utility class for Strings. + * Provides a utility class for Strings. * * @since 6.1.2 */ @@ -25,7 +25,7 @@ private StringUtils() { } /** - * Checks if String is null + * Returns if String is null * * @param charSequence * {@link CharSequence} Can provide null @@ -37,7 +37,7 @@ public static boolean isEmpty(final CharSequence charSequence) { } /** - * Check if String is numeric or not. + * Returns if String is numeric or not. * * @param str * {@link String} @@ -48,7 +48,7 @@ public static boolean isNumeric(final String str) { } /** - * Check if string is integer or not + * Returns if string is integer or not * * @param str * {@link String} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/ColumnSensitivity.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/ColumnSensitivity.java index 9d2a314c7b..5bc4cab721 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/ColumnSensitivity.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/ColumnSensitivity.java @@ -10,13 +10,13 @@ /** - * This class is used to retrieve Sensitivity Information for columns as configured in Database. + * Represents the Data Classification Sensitivity Information for columns as configured in Database. */ public class ColumnSensitivity { private List sensitivityProperties; /** - * Constructor for ColumnSensitivity + * Constructs a ColumnSensitivity * * @param sensitivityProperties * List of sensitivity properties as received from SQL Server @@ -26,7 +26,7 @@ public ColumnSensitivity(List sensitivityProperties) { } /** - * Retrieves list of sensitivity properties as received from Server for this ColumnSensitivity + * Returns the list of sensitivity properties as received from Server for this ColumnSensitivity * information * * @return sensitivityProperties for this Class Object diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/InformationType.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/InformationType.java index 6bbb925e67..c6c0fc103d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/InformationType.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/InformationType.java @@ -6,14 +6,14 @@ package com.microsoft.sqlserver.jdbc.dataclassification; /** - * This class retrieves Information Types as recieved from SQL Server for the active resultSet + * Represents the Data Classification Information Types as received from SQL Server for the active resultSet */ public class InformationType { private String name; private String id; /** - * Constructor for Information Type + * Constructs a InformationType * * @param name * Name of Information Type @@ -26,7 +26,7 @@ public InformationType(String name, String id) { } /** - * Retrieves Name of this InformationType Object + * Returns the name of this InformationType Object * * @return Name of Information Type */ @@ -35,7 +35,7 @@ public String getName() { } /** - * Retrieves ID for this InformationType object + * Returns the ID for this InformationType object * * @return ID of Information Type */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/Label.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/Label.java index 5476cf6e73..0d481eddd5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/Label.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/Label.java @@ -6,14 +6,14 @@ package com.microsoft.sqlserver.jdbc.dataclassification; /** - * This class retrieves Labels as recieved from SQL Server for the active resultSet + * Represents the Data Classification Labels as received from SQL Server for the active resultSet */ public class Label { private String name; private String id; /** - * Constructor for Label + * Constructs a Label * * @param name * Name of Label @@ -26,7 +26,7 @@ public Label(String name, String id) { } /** - * Retrieves Name of this InformationType Object + * Returns the name of this InformationType Object * * @return Name of Information Type */ @@ -35,7 +35,7 @@ public String getName() { } /** - * Retrieves ID for this InformationType object + * Returns the ID for this InformationType object * * @return ID of Information Type */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java index 233e0f4592..5e9e1c8792 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java @@ -10,7 +10,7 @@ /** - * This class retrieves Sensitivity Classification data as recieved from SQL Server for the active resultSet + * Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active resultSet */ public class SensitivityClassification { private List

* The returned value represents an instant in time as the number of milliseconds since January 1, 1970, 00:00:00 * GMT. @@ -216,7 +216,7 @@ public java.sql.Timestamp getTimestamp() { } /** - * Gets this DateTimeOffset object's offset value. + * Returns this DateTimeOffset object's offset value. * * @return this DateTimeOffset object's minutes offset from GMT */ @@ -262,7 +262,8 @@ private static class SerializationProxy implements java.io.Serializable { private Object readResolve() { java.sql.Timestamp timestamp = new java.sql.Timestamp(utcMillis); timestamp.setNanos(nanos); - return new DateTimeOffset(timestamp, minutesOffset); + r +turn new DateTimeOffset(timestamp, minutesOffset); } } diff --git a/src/main/java/microsoft/sql/Types.java b/src/main/java/microsoft/sql/Types.java index e43e98d204..ec326fe3c2 100644 --- a/src/main/java/microsoft/sql/Types.java +++ b/src/main/java/microsoft/sql/Types.java @@ -6,8 +6,7 @@ package microsoft.sql; /** - * The class that defines the constants that are used to identify the SQL types that are specific to Microsoft SQL - * Server. + * Defines the constants that are used to identify the SQL types that are specific to Microsoft SQL Server. * * This class is never instantiated. */ From fb3a2c802f57cdcda054dd2bf698a0a3f2a5d83c Mon Sep 17 00:00:00 2001 From: susanh Date: Fri, 20 Jul 2018 17:09:43 -0700 Subject: [PATCH 2/9] back to prev versions of Geography and Geometry --- .../microsoft/sqlserver/jdbc/Geography.java | 208 +++++++++--------- .../microsoft/sqlserver/jdbc/Geometry.java | 8 +- .../java/microsoft/sql/DateTimeOffset.java | 3 +- 3 files changed, 112 insertions(+), 107 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java index 4372e41cdf..8726cb0013 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java @@ -1,6 +1,9 @@ /* - * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made - * available under the terms of the MIT License. See the LICENSE file in the project root for more information. + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) Microsoft Corporation All rights reserved. + * + * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. */ package com.microsoft.sqlserver.jdbc; @@ -8,149 +11,154 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; -/** - * Represents a Geography spatial data type. - */ public class Geography extends SQLServerSpatialDatatype { - + /** - * Constructs a Geography object from WKT and srid. + * Private constructor used for creating a Geography object from WKT and srid. * * @param WellKnownText - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @throws SQLServerException - * if an exception occurs + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @throws SQLServerException + * if an exception occurs */ private Geography(String WellKnownText, int srid) throws SQLServerException { this.wkt = WellKnownText; this.srid = srid; - + try { parseWKTForSerialization(this, currentWktPos, -1, false); - } catch (StringIndexOutOfBoundsException e) { + } + catch (StringIndexOutOfBoundsException e) { String strError = SQLServerException.getErrString("R_illegalWKT"); throw new SQLServerException(strError, null, 0, null); } - + serializeToWkb(false); isNull = false; } /** - * Constructs a Geography object from WKB. + * Private constructor used for creating a Geography object from WKB. * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @throws SQLServerException - * if an exception occurs + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @throws SQLServerException + * if an exception occurs */ private Geography(byte[] wkb) throws SQLServerException { this.wkb = wkb; buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); - + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - + wkt = WKTsb.toString(); wktNoZM = WKTsbNoZM.toString(); isNull = false; } - + /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation - * augmented with any Z (elevation) and M (measure) values carried by the instance. - * + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) + * representation augmented with any Z (elevation) and M (measure) values carried by the instance. + * * @param wkt - * Well-Known Text (WKT) provided by the user. + * Well-Known Text (WKT) provided by the user. * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @return Geography Geography instance created from WKT and SRID - * @throws SQLServerException - * if an exception occurs + * Spatial Reference Identifier (SRID) provided by the user. + * @return Geography + * Geography instance created from WKT and SRID + * @throws SQLServerException + * if an exception occurs */ public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException { return new Geography(wkt, srid); } - + /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. + * Returns a Geography instance from an Open Geospatial Consortium (OGC) + * Well-Known Binary (WKB) representation. * * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs + * Well-Known Binary (WKB) provided by the user. + * @return Geography + * Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs */ public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException { return new Geography(wkb); } - + /** * Returns a constructed Geography from an internal SQL Server format for spatial data. * * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs + * Well-Known Binary (WKB) provided by the user. + * @return Geography + * Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs */ public static Geography deserialize(byte[] wkb) throws SQLServerException { return new Geography(wkb); } /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID - * is defaulted to 4326. + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. + * SRID is defaulted to 4326. * * @param wkt - * Well-Known Text (WKT) provided by the user. - * @return Geography Geography instance created from WKT - * @throws SQLServerException - * if an exception occurs + * Well-Known Text (WKT) provided by the user. + * @return Geography + * Geography instance created from WKT + * @throws SQLServerException + * if an exception occurs */ public static Geography parse(String wkt) throws SQLServerException { return new Geography(wkt, 4326); } - + /** * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. * - * @param x - * x coordinate + * @param x + * x coordinate * @param y - * y coordinate + * y coordinate * @param srid - * SRID - * @return Geography Geography instance - * @throws SQLServerException - * if an exception occurs + * SRID + * @return Geography + * Geography instance + * @throws SQLServerException + * if an exception occurs */ public static Geography point(double x, double y, int srid) throws SQLServerException { return new Geography("POINT (" + x + " " + y + ")", srid); } /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance. This - * text will not contain any Z (elevation) or M (measure) values carried by the instance. + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a + * Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance. * - * @return the WKT representation without the Z and M values. - * @throws SQLServerException - * if an exception occurs + * @return + * the WKT representation without the Z and M values. + * @throws SQLServerException + * if an exception occurs */ public String STAsText() throws SQLServerException { if (null == wktNoZM) { buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); @@ -158,11 +166,11 @@ public String STAsText() throws SQLServerException { } return wktNoZM; } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance. This - * value will not contain any Z or M values carried by the instance. - * + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a + * Geography instance. This value will not contain any Z or M values carried by the instance. + * * @return byte array representation of the Geography object. */ public byte[] STAsBinary() { @@ -171,16 +179,16 @@ public byte[] STAsBinary() { } return wkbNoZM; } - + /** - * Returns the bytes that represent an internal SQL Server format of Geography type. + * Returns the bytes that represent an internal SQL Server format of Geography type. * * @return byte array representation of the Geography object. */ public byte[] serialize() { return wkb; } - + /** * Returns if the object contains a M (measure) value. * @@ -189,7 +197,7 @@ public byte[] serialize() { public boolean hasM() { return hasMvalues; } - + /** * Returns if the object contains a Z (elevation) value. * @@ -198,7 +206,7 @@ public boolean hasM() { public boolean hasZ() { return hasZvalues; } - + /** * Returns the X coordinate value. * @@ -210,7 +218,7 @@ public Double getX() { } return null; } - + /** * Returns the Y coordinate value. * @@ -222,7 +230,7 @@ public Double getY() { } return null; } - + /** * Returns the M (measure) value of the object. * @@ -234,7 +242,7 @@ public Double getM() { } return null; } - + /** * Returns the Z (elevation) value of the object. * @@ -255,7 +263,7 @@ public Double getZ() { public int getSrid() { return srid; } - + /** * Returns if the Geography object is null. * @@ -264,7 +272,7 @@ public int getSrid() { public boolean isNull() { return isNull; } - + /** * Returns the number of points in the Geography object. * @@ -285,16 +293,16 @@ public String STGeographyType() { } return null; } - + /** - * Returns the Well-Known Text (WKT) representation of the Geography object. + * Returns the Well-Known Text (WKT) representation of the Geography object. * * @return String that contains the WKT representation of the Geography object. */ public String asTextZM() { return wkt; } - + /** * Returns the String representation of the Geography object. * @@ -308,21 +316,21 @@ public String toString() { protected void serializeToWkb(boolean noZM) { ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); createSerializationProperties(); - + buf.order(ByteOrder.LITTLE_ENDIAN); buf.putInt(srid); buf.put(version); buf.put(serializationProperties); - + if (!isSinglePoint && !isSingleLineSegment) { buf.putInt(numberOfPoints); } - + for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(points[2 * i + 1]); buf.putDouble(points[2 * i]); } - + if (!noZM) { if (hasZvalues) { for (int i = 0; i < numberOfPoints; i++) { @@ -335,33 +343,33 @@ protected void serializeToWkb(boolean noZM) { } } } - + if (isSinglePoint || isSingleLineSegment) { wkb = buf.array(); return; } - + buf.putInt(numberOfFigures); for (int i = 0; i < numberOfFigures; i++) { buf.put(figures[i].getFiguresAttribute()); buf.putInt(figures[i].getPointOffset()); } - + buf.putInt(numberOfShapes); for (int i = 0; i < numberOfShapes; i++) { buf.putInt(shapes[i].getParentOffset()); buf.putInt(shapes[i].getFigureOffset()); buf.put(shapes[i].getOpenGISType()); } - + if (version == 2 && null != segments) { buf.putInt(numberOfSegments); for (int i = 0; i < numberOfSegments; i++) { buf.put(segments[i].getSegmentType()); } } - - if (noZM) { + + if (noZM) { wkbNoZM = buf.array(); } else { wkb = buf.array(); @@ -369,31 +377,31 @@ protected void serializeToWkb(boolean noZM) { } return; } - + protected void parseWkb() { srid = buffer.getInt(); version = buffer.get(); serializationProperties = buffer.get(); - + interpretSerializationPropBytes(); readNumberOfPoints(); readPoints(); - + if (hasZvalues) { readZvalues(); } - + if (hasMvalues) { readMvalues(); } - + if (!(isSinglePoint || isSingleLineSegment)) { readNumberOfFigures(); readFigures(); readNumberOfShapes(); readShapes(); } - + determineInternalType(); if (buffer.hasRemaining()) { @@ -403,7 +411,7 @@ protected void parseWkb() { } } } - + private void readPoints() { points = new double[2 * numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { @@ -411,4 +419,4 @@ private void readPoints() { points[2 * i] = buffer.getDouble(); } } -} +} \ No newline at end of file diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java index 1332c60193..45d8939f40 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java @@ -8,13 +8,11 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; -/** - * Represents a Geometry spatial data type. - */ + public class Geometry extends SQLServerSpatialDatatype { /** - * Construct a Geometry object from WKT and srid. + * Private constructor used for creating a Geometry object from WKT and srid. * * @param WellKnownText * Well-Known Text (WKT) provided by the user. @@ -39,7 +37,7 @@ private Geometry(String WellKnownText, int srid) throws SQLServerException { } /** - * Constructs a Geometry object from WKB. + * Private constructor used for creating a Geometry object from WKB. * * @param wkb * Well-Known Binary (WKB) provided by the user. diff --git a/src/main/java/microsoft/sql/DateTimeOffset.java b/src/main/java/microsoft/sql/DateTimeOffset.java index 5c45ad12c6..fc5135b43d 100644 --- a/src/main/java/microsoft/sql/DateTimeOffset.java +++ b/src/main/java/microsoft/sql/DateTimeOffset.java @@ -262,8 +262,7 @@ private static class SerializationProxy implements java.io.Serializable { private Object readResolve() { java.sql.Timestamp timestamp = new java.sql.Timestamp(utcMillis); timestamp.setNanos(nanos); - r -turn new DateTimeOffset(timestamp, minutesOffset); + return new DateTimeOffset(timestamp, minutesOffset); } } From 4b2a4b1a2ae02bab4e345c8c89bea9a923b113fd Mon Sep 17 00:00:00 2001 From: susanh Date: Mon, 23 Jul 2018 12:17:29 -0700 Subject: [PATCH 3/9] undo changes to Geography and Geometry as they will be updated in another PR --- .../microsoft/sqlserver/jdbc/Geography.java | 153 ++-------- .../microsoft/sqlserver/jdbc/Geometry.java | 270 ++++++------------ 2 files changed, 125 insertions(+), 298 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java index 8726cb0013..0790a06912 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java @@ -15,15 +15,8 @@ public class Geography extends SQLServerSpatialDatatype { /** * Private constructor used for creating a Geography object from WKT and srid. - * - * @param WellKnownText - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @throws SQLServerException - * if an exception occurs */ - private Geography(String WellKnownText, int srid) throws SQLServerException { + private Geography(String WellKnownText, int srid) { this.wkt = WellKnownText; this.srid = srid; @@ -31,8 +24,7 @@ private Geography(String WellKnownText, int srid) throws SQLServerException { parseWKTForSerialization(this, currentWktPos, -1, false); } catch (StringIndexOutOfBoundsException e) { - String strError = SQLServerException.getErrString("R_illegalWKT"); - throw new SQLServerException(strError, null, 0, null); + throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid."); } serializeToWkb(false); @@ -41,13 +33,8 @@ private Geography(String WellKnownText, int srid) throws SQLServerException { /** * Private constructor used for creating a Geography object from WKB. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @throws SQLServerException - * if an exception occurs */ - private Geography(byte[] wkb) throws SQLServerException { + private Geography(byte[] wkb) { this.wkb = wkb; buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); @@ -64,20 +51,19 @@ private Geography(byte[] wkb) throws SQLServerException { isNull = false; } + public Geography() { + // TODO Auto-generated constructor stub + } + /** * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) * representation augmented with any Z (elevation) and M (measure) values carried by the instance. * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @return Geography - * Geography instance created from WKT and SRID - * @throws SQLServerException - * if an exception occurs + * @param wkt WKT + * @param srid SRID + * @return Geography instance */ - public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException { + public static Geography STGeomFromText(String wkt, int srid) { return new Geography(wkt, srid); } @@ -85,28 +71,20 @@ public static Geography STGeomFromText(String wkt, int srid) throws SQLServerExc * Returns a Geography instance from an Open Geospatial Consortium (OGC) * Well-Known Binary (WKB) representation. * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography - * Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs + * @param wkb WKB + * @return Geography instance */ - public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException { + public static Geography STGeomFromWKB(byte[] wkb) { return new Geography(wkb); } /** * Returns a constructed Geography from an internal SQL Server format for spatial data. * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography - * Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs + * @param wkb WKB + * @return Geography instance */ - public static Geography deserialize(byte[] wkb) throws SQLServerException { + public static Geography deserialize(byte[] wkb) { return new Geography(wkb); } @@ -114,32 +92,22 @@ public static Geography deserialize(byte[] wkb) throws SQLServerException { * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. * SRID is defaulted to 4326. * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @return Geography - * Geography instance created from WKT - * @throws SQLServerException - * if an exception occurs + * @param wkt WKt + * @return Geography instance */ - public static Geography parse(String wkt) throws SQLServerException { + public static Geography parse(String wkt) { return new Geography(wkt, 4326); } /** * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. * - * @param x - * x coordinate - * @param y - * y coordinate - * @param srid - * SRID - * @return Geography - * Geography instance - * @throws SQLServerException - * if an exception occurs + * @param x x coordinate + * @param y y coordinate + * @param srid SRID + * @return Geography instance */ - public static Geography point(double x, double y, int srid) throws SQLServerException { + public static Geography point(double x, double y, int srid) { return new Geography("POINT (" + x + " " + y + ")", srid); } @@ -147,12 +115,9 @@ public static Geography point(double x, double y, int srid) throws SQLServerExce * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a * Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance. * - * @return - * the WKT representation without the Z and M values. - * @throws SQLServerException - * if an exception occurs + * @return the WKT representation without the Z and M values. */ - public String STAsText() throws SQLServerException { + public String STAsText() { if (null == wktNoZM) { buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); @@ -170,8 +135,7 @@ public String STAsText() throws SQLServerException { /** * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a * Geography instance. This value will not contain any Z or M values carried by the instance. - * - * @return byte array representation of the Geography object. + * @return WKB */ public byte[] STAsBinary() { if (null == wkbNoZM) { @@ -183,35 +147,20 @@ public byte[] STAsBinary() { /** * Returns the bytes that represent an internal SQL Server format of Geography type. * - * @return byte array representation of the Geography object. + * @return WKB */ public byte[] serialize() { return wkb; } - /** - * Returns if the object contains a M (measure) value. - * - * @return boolean that indicates if the object contains M value. - */ public boolean hasM() { return hasMvalues; } - /** - * Returns if the object contains a Z (elevation) value. - * - * @return boolean that indicates if the object contains Z value. - */ public boolean hasZ() { return hasZvalues; } - /** - * Returns the X coordinate value. - * - * @return double value that represents the X coordinate. - */ public Double getX() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[0]; @@ -219,11 +168,6 @@ public Double getX() { return null; } - /** - * Returns the Y coordinate value. - * - * @return double value that represents the Y coordinate. - */ public Double getY() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[1]; @@ -231,11 +175,6 @@ public Double getY() { return null; } - /** - * Returns the M (measure) value of the object. - * - * @return double value that represents the M value. - */ public Double getM() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { return mValues[0]; @@ -243,11 +182,6 @@ public Double getM() { return null; } - /** - * Returns the Z (elevation) value of the object. - * - * @return double value that represents the Z value. - */ public Double getZ() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { return zValues[0]; @@ -255,29 +189,14 @@ public Double getZ() { return null; } - /** - * Returns the Spatial Reference Identifier (SRID) value. - * - * @return int value of SRID. - */ public int getSrid() { return srid; } - /** - * Returns if the Geography object is null. - * - * @return boolean that indicates if the object is null. - */ public boolean isNull() { return isNull; } - /** - * Returns the number of points in the Geography object. - * - * @return int that indicates the number of points in the Geography object. - */ public int STNumPoints() { return numberOfPoints; } @@ -285,7 +204,7 @@ public int STNumPoints() { /** * Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance. * - * @return String that contains the Geography object's type name + * @return type name */ public String STGeographyType() { if (null != internalType) { @@ -294,21 +213,10 @@ public String STGeographyType() { return null; } - /** - * Returns the Well-Known Text (WKT) representation of the Geography object. - * - * @return String that contains the WKT representation of the Geography object. - */ public String asTextZM() { return wkt; } - /** - * Returns the String representation of the Geography object. - * - * @return String that contains the WKT representation of the Geography object. - */ - @Override public String toString() { return wkt; } @@ -337,6 +245,7 @@ protected void serializeToWkb(boolean noZM) { buf.putDouble(zValues[i]); } } + if (hasMvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(mValues[i]); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java index 45d8939f40..90f4427a5a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java @@ -1,6 +1,9 @@ /* - * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made - * available under the terms of the MIT License. See the LICENSE file in the project root for more information. + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) Microsoft Corporation All rights reserved. + * + * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. */ package com.microsoft.sqlserver.jdbc; @@ -8,147 +11,119 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; - public class Geometry extends SQLServerSpatialDatatype { - + /** * Private constructor used for creating a Geometry object from WKT and srid. - * - * @param WellKnownText - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @throws SQLServerException - * if an exception occurs */ - private Geometry(String WellKnownText, int srid) throws SQLServerException { + private Geometry(String WellKnownText, int srid) { this.wkt = WellKnownText; this.srid = srid; - + try { parseWKTForSerialization(this, currentWktPos, -1, false); - } catch (StringIndexOutOfBoundsException e) { - String strError = SQLServerException.getErrString("R_illegalWKT"); - throw new SQLServerException(strError, null, 0, null); } - + catch (StringIndexOutOfBoundsException e) { + throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid."); + } + serializeToWkb(false); isNull = false; } /** * Private constructor used for creating a Geometry object from WKB. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @throws SQLServerException - * if an exception occurs */ - private Geometry(byte[] wkb) throws SQLServerException { + private Geometry(byte[] wkb) { this.wkb = wkb; buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); - + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - + wkt = WKTsb.toString(); wktNoZM = WKTsbNoZM.toString(); isNull = false; } - + + public Geometry() { + // TODO Auto-generated constructor stub + } + /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation - * augmented with any Z (elevation) and M (measure) values carried by the instance. - * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @return Geometry Geometry instance created from WKT and SRID - * @throws SQLServerException - * if an exception occurs + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) + * representation augmented with any Z (elevation) and M (measure) values carried by the instance. + * + * @param wkt WKT + * @param srid SRID + * @return Geometry instance */ - public static Geometry STGeomFromText(String wkt, int srid) throws SQLServerException { + public static Geometry STGeomFromText(String wkt, int srid) { return new Geometry(wkt, srid); } - + /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) + * Well-Known Binary (WKB) representation. * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geometry Geometry instance created from WKB - * @throws SQLServerException - * if an exception occurs + * @param wkb WKB + * @return Geometry instance */ - public static Geometry STGeomFromWKB(byte[] wkb) throws SQLServerException { + public static Geometry STGeomFromWKB(byte[] wkb) { return new Geometry(wkb); } - + /** * Returns a constructed Geometry from an internal SQL Server format for spatial data. * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geometry Geometry instance created from WKB - * @throws SQLServerException - * if an exception occurs + * @param wkb WKB + * @return Geometry instance */ - public static Geometry deserialize(byte[] wkb) throws SQLServerException { + public static Geometry deserialize(byte[] wkb) { return new Geometry(wkb); } /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID - * is defaulted to 0. + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. + * SRID is defaulted to 0. * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @return Geometry Geometry instance created from WKT - * @throws SQLServerException - * if an exception occurs + * @param wkt WKT + * @return Geometry instance */ - public static Geometry parse(String wkt) throws SQLServerException { + public static Geometry parse(String wkt) { return new Geometry(wkt, 0); } - + /** * Constructs a Geometry instance that represents a Point instance from its X and Y values and an SRID. * - * @param x - * x coordinate - * @param y - * y coordinate - * @param srid - * SRID - * @return Geometry Geography instance - * @throws SQLServerException - * if an exception occurs + * @param x x coordinate + * @param y y coordinate + * @param srid SRID + * @return Geometry instance */ - public static Geometry point(double x, double y, int srid) throws SQLServerException { + public static Geometry point(double x, double y, int srid) { return new Geometry("POINT (" + x + " " + y + ")", srid); } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance. This - * text will not contain any Z (elevation) or M (measure) values carried by the instance. + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a + * Geometry instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance. * * @return the WKT representation without the Z and M values. - * @throws SQLServerException - * if an exception occurs */ - public String STAsText() throws SQLServerException { + public String STAsText() { if (null == wktNoZM) { buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); @@ -156,12 +131,11 @@ public String STAsText() throws SQLServerException { } return wktNoZM; } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance. This - * value will not contain any Z or M values carried by the instance. - * - * @return byte array representation of the Geometry object. + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a + * Geometry instance. This value will not contain any Z or M values carried by the instance. + * @return WKB */ public byte[] STAsBinary() { if (null == wkbNoZM) { @@ -169,75 +143,45 @@ public byte[] STAsBinary() { } return wkbNoZM; } - + /** - * Returns the bytes that represent an internal SQL Server format of Geometry type. + * Returns the bytes that represent an internal SQL Server format of Geometry type. * - * @return byte array representation of the Geometry object. + * @return WKB */ public byte[] serialize() { return wkb; } - - /** - * Returns if the object contains a M (measure) value. - * - * @return boolean that indicates if the object contains M value. - */ + public boolean hasM() { return hasMvalues; } - - /** - * Returns if the object contains a Z (elevation) value. - * - * @return boolean that indicates if the object contains Z value. - */ + public boolean hasZ() { return hasZvalues; } - - /** - * Returns the X coordinate value. - * - * @return double value that represents the X coordinate. - */ + public Double getX() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[0]; } return null; } - - /** - * Returns the Y coordinate value. - * - * @return double value that represents the Y coordinate. - */ + public Double getY() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[1]; } return null; } - - /** - * Returns the M (measure) value of the object. - * - * @return double value that represents the M value. - */ + public Double getM() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { return mValues[0]; } return null; } - - /** - * Returns the Z (elevation) value of the object. - * - * @return double value that represents the Z value. - */ + public Double getZ() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { return zValues[0]; @@ -245,29 +189,14 @@ public Double getZ() { return null; } - /** - * Returns the Spatial Reference Identifier (SRID) value. - * - * @return int value of SRID. - */ public int getSrid() { return srid; } - - /** - * Returns if the Geometry object is null. - * - * @return boolean that indicates if the object is null. - */ + public boolean isNull() { return isNull; } - - /** - * Returns the number of points in the Geometry object. - * - * @return int that indicates the number of points in the Geometry object. - */ + public int STNumPoints() { return numberOfPoints; } @@ -275,7 +204,7 @@ public int STNumPoints() { /** * Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance. * - * @return String that contains the Geometry object's type name + * @return type name */ public String STGeometryType() { if (null != internalType) { @@ -283,84 +212,73 @@ public String STGeometryType() { } return null; } - - /** - * Returns the Well-Known Text (WKT) representation of the Geometry object. - * - * @return String that contains the WKT representation of the Geometry object. - */ + public String asTextZM() { return wkt; } - - /** - * Returns the String representation of the Geometry object. - * - * @return String that contains the WKT representation of the Geometry object. - */ - @Override + public String toString() { return wkt; } - + protected void serializeToWkb(boolean noZM) { ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); createSerializationProperties(); - + buf.order(ByteOrder.LITTLE_ENDIAN); buf.putInt(srid); buf.put(version); buf.put(serializationProperties); - + if (!isSinglePoint && !isSingleLineSegment) { buf.putInt(numberOfPoints); } - + for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(points[2 * i]); buf.putDouble(points[2 * i + 1]); } - - if (!noZM) { + + if (!noZM ) { if (hasZvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(zValues[i]); } } - + if (hasMvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(mValues[i]); } } } - + if (isSinglePoint || isSingleLineSegment) { wkb = buf.array(); return; } - + buf.putInt(numberOfFigures); for (int i = 0; i < numberOfFigures; i++) { buf.put(figures[i].getFiguresAttribute()); buf.putInt(figures[i].getPointOffset()); } - + buf.putInt(numberOfShapes); for (int i = 0; i < numberOfShapes; i++) { buf.putInt(shapes[i].getParentOffset()); buf.putInt(shapes[i].getFigureOffset()); buf.put(shapes[i].getOpenGISType()); } - + if (version == 2 && null != segments) { buf.putInt(numberOfSegments); for (int i = 0; i < numberOfSegments; i++) { buf.put(segments[i].getSegmentType()); } } - - if (noZM) { + + if (noZM) { wkbNoZM = buf.array(); } else { wkb = buf.array(); @@ -368,31 +286,31 @@ protected void serializeToWkb(boolean noZM) { } return; } - + protected void parseWkb() { srid = buffer.getInt(); version = buffer.get(); serializationProperties = buffer.get(); - + interpretSerializationPropBytes(); readNumberOfPoints(); readPoints(); - + if (hasZvalues) { readZvalues(); } - + if (hasMvalues) { readMvalues(); } - + if (!(isSinglePoint || isSingleLineSegment)) { readNumberOfFigures(); readFigures(); readNumberOfShapes(); readShapes(); } - + determineInternalType(); if (buffer.hasRemaining()) { @@ -402,7 +320,7 @@ protected void parseWkb() { } } } - + private void readPoints() { points = new double[2 * numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { From df890eba048a54273487c3d37decadda88087f97 Mon Sep 17 00:00:00 2001 From: susanh Date: Mon, 23 Jul 2018 12:44:27 -0700 Subject: [PATCH 4/9] review updates --- .../microsoft/sqlserver/jdbc/DataTypes.java | 92 ++++++++++--------- .../sqlserver/jdbc/ISQLServerBulkRecord.java | 2 +- .../sqlserver/jdbc/SQLServerBulkCopy.java | 78 ++++++++-------- .../jdbc/SQLServerParameterMetaData.java | 2 +- .../microsoft/sqlserver/jdbc/StreamDone.java | 1 - 5 files changed, 95 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java index b183470bad..93459e5493 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java @@ -531,11 +531,12 @@ static JavaType of(Object obj) { return JavaType.OBJECT; } - // Returns the JDBC type to use with this Java type. By default we use the static JDBC type - // associated with the Java type, ignoring the JDBC type specified by the application. - // But this behavior is overridden for certain Java types, like InputStream, which - // require the JDBC type to be specified externally to be able to distinguish between - // ASCII and binary streams. + /** + * Returns the JDBC type to use with this Java type. We use the static JDBC type associated + * with the Java type by default, ignoring the JDBC type specified by the application. This + * behavior is overridden for certain Java types, such as InputStream, which requires the JDBC + * type to be specified externally in order to distinguish between. + */ JDBCType getJDBCType(SSType ssType, JDBCType jdbcTypeFromApp) { return jdbcTypeFromJavaType; } @@ -1093,51 +1094,60 @@ static final void throwConversionError(String fromType, String toType) throws SQ SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, true); } - // Max length in Unicode characters allowed by the "short" NVARCHAR type. - // Values longer than this must use NVARCHAR(max) (Yukon or later) or NTEXT (Shiloh) + /** + * Max length in Unicode characters allowed by the "short" NVARCHAR type. + * Values longer than this must use NVARCHAR(max) (Yukon or later) or NTEXT (Shiloh) + */ final static int SHORT_VARTYPE_MAX_CHARS = 4000; - // Max length in bytes allowed by the "short" VARBINARY/VARCHAR types. - // Values longer than this must use VARBINARY(max)/VARCHAR(max) (Yukon or later) or IMAGE/TEXT (Shiloh) + /** + * Max length in bytes allowed by the "short" VARBINARY/VARCHAR types. + * Values longer than this must use VARBINARY(max)/VARCHAR(max) (Yukon or later) or IMAGE/TEXT (Shiloh) + */ final static int SHORT_VARTYPE_MAX_BYTES = 8000; - // A type with unlimited max size, known as varchar(max), varbinary(max) and nvarchar(max), - // which has a max size of 0xFFFF, defined by PARTLENTYPE. + /** + * A type with unlimited max size, known as varchar(max), varbinary(max) and nvarchar(max), + * which has a max size of 0xFFFF, defined by PARTLENTYPE. + */ final static int SQL_USHORTVARMAXLEN = 65535; // 0xFFFF - // From SQL Server 2005 Books Online : ntext, text, and image (Transact-SQL) - // http://msdn.microsoft.com/en-us/library/ms187993.aspx - // - // image - // "... through 2^31 - 1 (2,147,483,687) bytes." - // - // text - // "... maximum length of 2^31 - 1 (2,147,483,687) characters." - // - // ntext - // "... maximum length of 2^30 - 1 (1,073,741,823) characters." + /** + * From SQL Server 2005 Books Online : ntext, text, and image (Transact-SQL) + * http://msdn.microsoft.com/en-us/library/ms187993.aspx + * + * image + * "... through 2^31 - 1 (2,147,483,687) bytes." + * + * text + * "... maximum length of 2^31 - 1 (2,147,483,687) characters." + * + * ntext + * "... maximum length of 2^30 - 1 (1,073,741,823) characters." + */ final static int NTEXT_MAX_CHARS = 0x3FFFFFFF; final static int IMAGE_TEXT_MAX_BYTES = 0x7FFFFFFF; - // From SQL Server 2005 Books Online : Transact-SQL Data Types - // http://msdn.microsoft.com/en-us/library/ms179910.aspx - // - // varbinary(max) - // "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual - // length of the data entered + 2 bytes." - // - // varchar(max) - // "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual - // length of the data entered + 2 bytes." - // - // nvarchar(max) - // "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size, in bytes, - // is two times the number of characters entered + 2 bytes." - // - // Normally, that would mean that the maximum length of nvarchar(max) data is 0x3FFFFFFE characters - // and that the maximum length of varchar(max) or varbinary(max) data is 0x3FFFFFFD bytes. However... - // Despite the documentation, SQL Server returns 2^30 - 1 and 2^31 - 1 respectively as the PRECISION - // of these types, so use that instead. + /** + * Transact-SQL Data Types: http://msdn.microsoft.com/en-us/library/ms179910.aspx + * + * varbinary(max) + * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual + * length of the data entered + 2 bytes." + * + * varchar(max) + * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual + * length of the data entered + 2 bytes." + * + * nvarchar(max) + * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size, in bytes, + * is two times the number of characters entered + 2 bytes." + + * Normally, that would mean that the maximum length of nvarchar(max) data is 0x3FFFFFFE characters + * and that the maximum length of varchar(max) or varbinary(max) data is 0x3FFFFFFD bytes. However... + * Despite the documentation, SQL Server returns 2^30 - 1 and 2^31 - 1 respectively as the PRECISION + * of these types, so use that instead. + */ final static int MAX_VARTYPE_MAX_CHARS = 0x3FFFFFFF; final static int MAX_VARTYPE_MAX_BYTES = 0x7FFFFFFF; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java index cf1eaa2397..020055c809 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java @@ -10,7 +10,7 @@ /** * Provides an interface used to create classes that read in data from any source (such as a file) - * and allow a SQLServerBulkCopy class to write the data to SQL Server tables. + * and allows a SQLServerBulkCopy class to write the data to SQL Server tables. * * This interface is implemented by {@link SQLServerBulkCommon} Class */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index b464255806..793635e234 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -96,39 +96,39 @@ private class ColumnMapping { } } - /* + /** * Class name for logging. */ private static final String loggerClassName = "com.microsoft.sqlserver.jdbc.SQLServerBulkCopy"; private static final int SQL_SERVER_2016_VERSION = 13; - /* + /** * Logger */ private static final java.util.logging.Logger loggerExternal = java.util.logging.Logger.getLogger(loggerClassName); - /* + /** * Destination server connection. */ private SQLServerConnection connection; - /* + /** * Options to control how the WriteToServer methods behave. */ private SQLServerBulkCopyOptions copyOptions; - /* + /** * Mappings between columns in the data source and columns in the destination */ private List columnMappings; - /* + /** * Flag if SQLServerBulkCopy owns the connection and should close it when Close is called */ private boolean ownsConnection; - /* + /** * Name of destination table on server. If destinationTable has not been set when WriteToServer is called, an * Exception is thrown. destinationTable is a three-part name (..). You can qualify * the table name with its database and owning schema if you choose. However, if the table name uses an underscore @@ -138,30 +138,34 @@ private class ColumnMapping { */ private String destinationTableName; - /* + /** * Source data (from a Record). Is null unless the corresponding version of writeToServer is called. */ private ISQLServerBulkRecord sourceBulkRecord; - /* + /** * Source data (from ResultSet). Is null unless the corresponding version of writeToServer is called. */ private ResultSet sourceResultSet; - /* + /** * Metadata for the source table columns */ private ResultSetMetaData sourceResultSetMetaData; - /* The CekTable for the destination table. */ + /** + * The CekTable for the destination table. + */ private CekTable destCekTable = null; - /* Statement level encryption setting needed for querying against encrypted columns. */ + /** + * Statement level encryption setting needed for querying against encrypted columns. + */ private SQLServerStatementColumnEncryptionSetting stmtColumnEncriptionSetting = SQLServerStatementColumnEncryptionSetting.UseConnectionSetting; private ResultSet destinationTableMetadata; - /* + /** * Metadata for the destination table columns */ class BulkColumnMetaData { @@ -222,27 +226,27 @@ class BulkColumnMetaData { } }; - /* + /** * A map to store the metadata information for the destination table. */ private Map destColumnMetadata; - /* + /** * A map to store the metadata information for the source table. */ private Map srcColumnMetadata; - /* + /** * Variable to store destination column count. */ private int destColumnCount; - /* + /** * Variable to store source column count. */ private int srcColumnCount; - /* + /** * Timer for the bulk copy operation. The other timeout timers in the TDS layer only measure the response of the * first packet from SQL Server. */ @@ -663,7 +667,7 @@ public void writeToServer(ISQLServerBulkRecord sourceData) throws SQLServerExcep loggerExternal.exiting(loggerClassName, "writeToServer"); } - /* + /** * Initializes the defaults for member variables that require it. */ private void initializeDefaults() { @@ -729,7 +733,7 @@ final boolean doExecute() throws SQLServerException { connection.executeCommand(new InsertBulk()); } - /* + /** * write ColumnData token in COLMETADATA header */ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter, int idx) throws SQLServerException { @@ -750,13 +754,13 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter, int idx) throws userType[3] = (byte) 0x00; tdsWriter.writeBytes(userType); - /* + /** * Flags token - Bit flags in least significant bit order https://msdn.microsoft.com/en-us/library/dd357363.aspx * flags[0] = (byte) 0x05; flags[1] = (byte) 0x00; */ int destColumnIndex = columnMappings.get(idx).destinationColumnOrdinal; - /* + /** * TYPE_INFO FIXEDLENTYPE Example INT: tdsWriter.writeByte((byte) 0x38); */ srcColumnIndex = columnMappings.get(idx).sourceColumnOrdinal; @@ -1119,7 +1123,7 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i } } - /* + /** * Writes the CEK table needed for AE. Cek table (with 0 entries) will be present if AE was enabled and server * supports it! OR if encryption was disabled in connection options */ @@ -1147,7 +1151,7 @@ private void writeCekTable(TDSWriter tdsWriter) throws SQLServerException { } } - /* + /** * ... */ private void writeColumnMetaData(TDSWriter tdsWriter) throws SQLServerException { @@ -1181,7 +1185,7 @@ private void writeColumnMetaData(TDSWriter tdsWriter) throws SQLServerException } } - /* + /** * Helper method that throws a timeout exception if the cause of the exception was that the query was cancelled */ private void checkForTimeoutException(SQLException e, BulkTimeoutTimer timeoutTimer) throws SQLServerException { @@ -1197,7 +1201,7 @@ private void checkForTimeoutException(SQLException e, BulkTimeoutTimer timeoutTi } } - /* + /** * Validates whether the source JDBC types are compatible with the destination table data types. We need to do this * only once for the whole bulk copy session. */ @@ -1624,7 +1628,7 @@ private void writePacketDataDone(TDSWriter tdsWriter) throws SQLServerException tdsWriter.writeInt(0); } - /* + /** * Helper method to throw a SQLServerExeption with the invalidArgument message and given argument. */ private void throwInvalidArgument(String argument) throws SQLServerException { @@ -1633,7 +1637,7 @@ private void throwInvalidArgument(String argument) throws SQLServerException { SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, false); } - /* + /** * Helper method to throw a SQLServerExeption with the errorConvertingValue message and given arguments. */ private void throwInvalidJavaToJDBC(String javaClassName, int jdbcType) throws SQLServerException { @@ -1641,7 +1645,7 @@ private void throwInvalidJavaToJDBC(String javaClassName, int jdbcType) throws S throw new SQLServerException(form.format(new Object[] {javaClassName, jdbcType}), null, 0, null); } - /* + /** * The bulk copy operation */ private void writeToServer() throws SQLServerException { @@ -1769,7 +1773,7 @@ private void getDestinationMetadata() throws SQLServerException { } } - /* + /** * Returns the column metadata for the source (and saves it for later). Retrieving source metadata in * BulkColumnMetaData object helps to access source metadata from the same place for both ResultSet and File. */ @@ -1812,7 +1816,7 @@ private void getSourceMetadata() throws SQLServerException { } } - /* + /** * Oracle 12c database returns precision = 0 for char/varchar data types. */ private int validateSourcePrecision(int srcPrecision, int srcJdbcType, int destPrecision) { @@ -1822,7 +1826,7 @@ private int validateSourcePrecision(int srcPrecision, int srcJdbcType, int destP return srcPrecision; } - /* + /** * Validates the column mappings */ private void validateColumnMappings() throws SQLServerException { @@ -2884,7 +2888,7 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole } } - /* + /** * Reads the given column from the result set current row and writes the data to tdsWriter. */ private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal, @@ -3011,8 +3015,10 @@ else if (null != sourceBulkRecord && (null == destCryptoMeta)) { destColOrdinal, isStreaming, colValue); } - // this method is called against jdbc41, but it require jdbc42 to work - // therefore, we will throw exception. + /** + * this method is called against jdbc41, but it require jdbc42 to work + * therefore, we will throw exception. + */ protected Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed, int srcJdbcType, int srcColOrdinal, DateTimeFormatter dateTimeFormatter) throws SQLServerException { try { @@ -3493,7 +3499,7 @@ private boolean goToNextRow() throws SQLServerException { } } - /* + /** * Writes data for a batch of rows to the TDSWriter object. Writes the following part in the BulkLoadBCP stream * (https://msdn.microsoft.com/en-us/library/dd340549.aspx) ... */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index a33fc8a5da..f7e785a63c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -21,7 +21,7 @@ /** - * Provides JDBC 3.0 meta data for prepared statement parameters. + * Provides meta data for prepared statement parameters. * * 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java index 1d0f4fc6ac..282f9f11e4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamDone.java @@ -241,7 +241,6 @@ final boolean cmdIsDMLOrDDL() { case CMD_SELECTINTO: // DDL - // Lifted from SQL Server 2005 Books Online at: // http://msdn2.microsoft.com/en-us/library/ms180824.aspx case CMD_CNST_CREATE: case CMD_DENY: From b948142e16579a62e68f992124a30d291a224d0c Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Mon, 23 Jul 2018 16:09:21 -0700 Subject: [PATCH 5/9] revert Geography and Geometry again --- Geography.java | 412 ++++++++++++++++++++++++++++++++++++++++++++++++ Geometry.java | 413 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 825 insertions(+) create mode 100644 Geography.java create mode 100644 Geometry.java diff --git a/Geography.java b/Geography.java new file mode 100644 index 0000000000..1bcac796cd --- /dev/null +++ b/Geography.java @@ -0,0 +1,412 @@ +/* + * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made + * available under the terms of the MIT License. See the LICENSE file in the project root for more information. + */ + +package com.microsoft.sqlserver.jdbc; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + + +public class Geography extends SQLServerSpatialDatatype { + + /** + * Private constructor used for creating a Geography object from WKT and srid. + * + * @param WellKnownText + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @throws SQLServerException + * if an exception occurs + */ + private Geography(String WellKnownText, int srid) throws SQLServerException { + this.wkt = WellKnownText; + this.srid = srid; + + try { + parseWKTForSerialization(this, currentWktPos, -1, false); + } catch (StringIndexOutOfBoundsException e) { + String strError = SQLServerException.getErrString("R_illegalWKT"); + throw new SQLServerException(strError, null, 0, null); + } + + serializeToWkb(false); + isNull = false; + } + + /** + * Private constructor used for creating a Geography object from WKB. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @throws SQLServerException + * if an exception occurs + */ + private Geography(byte[] wkb) throws SQLServerException { + this.wkb = wkb; + buffer = ByteBuffer.wrap(wkb); + buffer.order(ByteOrder.LITTLE_ENDIAN); + + parseWkb(); + + WKTsb = new StringBuffer(); + WKTsbNoZM = new StringBuffer(); + + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); + + wkt = WKTsb.toString(); + wktNoZM = WKTsbNoZM.toString(); + isNull = false; + } + + /** + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation + * augmented with any Z (elevation) and M (measure) values carried by the instance. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @return Geography Geography instance created from WKT and SRID + * @throws SQLServerException + * if an exception occurs + */ + public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException { + return new Geography(wkt, srid); + } + + /** + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geography Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs + */ + public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException { + return new Geography(wkb); + } + + /** + * Returns a constructed Geography from an internal SQL Server format for spatial data. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geography Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs + */ + public static Geography deserialize(byte[] wkb) throws SQLServerException { + return new Geography(wkb); + } + + /** + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID + * is defaulted to 4326. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @return Geography Geography instance created from WKT + * @throws SQLServerException + * if an exception occurs + */ + public static Geography parse(String wkt) throws SQLServerException { + return new Geography(wkt, 4326); + } + + /** + * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. + * + * @param x + * x coordinate + * @param y + * y coordinate + * @param srid + * SRID + * @return Geography Geography instance + * @throws SQLServerException + * if an exception occurs + */ + public static Geography point(double x, double y, int srid) throws SQLServerException { + return new Geography("POINT (" + x + " " + y + ")", srid); + } + + /** + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance. This + * text will not contain any Z (elevation) or M (measure) values carried by the instance. + * + * @return the WKT representation without the Z and M values. + * @throws SQLServerException + * if an exception occurs + */ + public String STAsText() throws SQLServerException { + if (null == wktNoZM) { + buffer = ByteBuffer.wrap(wkb); + buffer.order(ByteOrder.LITTLE_ENDIAN); + + parseWkb(); + + WKTsb = new StringBuffer(); + WKTsbNoZM = new StringBuffer(); + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); + wktNoZM = WKTsbNoZM.toString(); + } + return wktNoZM; + } + + /** + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance. This + * value will not contain any Z or M values carried by the instance. + * + * @return byte array representation of the Geography object. + */ + public byte[] STAsBinary() { + if (null == wkbNoZM) { + serializeToWkb(true); + } + return wkbNoZM; + } + + /** + * Returns the bytes that represent an internal SQL Server format of Geography type. + * + * @return byte array representation of the Geography object. + */ + public byte[] serialize() { + return wkb; + } + + /** + * Returns if the object contains a M (measure) value. + * + * @return boolean that indicates if the object contains M value. + */ + public boolean hasM() { + return hasMvalues; + } + + /** + * Returns if the object contains a Z (elevation) value. + * + * @return boolean that indicates if the object contains Z value. + */ + public boolean hasZ() { + return hasZvalues; + } + + /** + * Returns the X coordinate value. + * + * @return double value that represents the X coordinate. + */ + public Double getX() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { + return points[0]; + } + return null; + } + + /** + * Returns the Y coordinate value. + * + * @return double value that represents the Y coordinate. + */ + public Double getY() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { + return points[1]; + } + return null; + } + + /** + * Returns the M (measure) value of the object. + * + * @return double value that represents the M value. + */ + public Double getM() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { + return mValues[0]; + } + return null; + } + + /** + * Returns the Z (elevation) value of the object. + * + * @return double value that represents the Z value. + */ + public Double getZ() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { + return zValues[0]; + } + return null; + } + + /** + * Returns the Spatial Reference Identifier (SRID) value. + * + * @return int value of SRID. + */ + public int getSrid() { + return srid; + } + + /** + * Returns if the Geography object is null. + * + * @return boolean that indicates if the object is null. + */ + public boolean isNull() { + return isNull; + } + + /** + * Returns the number of points in the Geography object. + * + * @return int that indicates the number of points in the Geography object. + */ + public int STNumPoints() { + return numberOfPoints; + } + + /** + * Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance. + * + * @return String that contains the Geography object's type name + */ + public String STGeographyType() { + if (null != internalType) { + return internalType.getTypeName(); + } + return null; + } + + /** + * Returns the Well-Known Text (WKT) representation of the Geography object. + * + * @return String that contains the WKT representation of the Geography object. + */ + public String asTextZM() { + return wkt; + } + + /** + * Returns the String representation of the Geography object. + * + * @return String that contains the WKT representation of the Geography object. + */ + @Override + public String toString() { + return wkt; + } + + protected void serializeToWkb(boolean noZM) { + ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); + createSerializationProperties(); + + buf.order(ByteOrder.LITTLE_ENDIAN); + buf.putInt(srid); + buf.put(version); + buf.put(serializationProperties); + + if (!isSinglePoint && !isSingleLineSegment) { + buf.putInt(numberOfPoints); + } + + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(points[2 * i + 1]); + buf.putDouble(points[2 * i]); + } + + if (!noZM) { + if (hasZvalues) { + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(zValues[i]); + } + } + if (hasMvalues) { + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(mValues[i]); + } + } + } + + if (isSinglePoint || isSingleLineSegment) { + wkb = buf.array(); + return; + } + + buf.putInt(numberOfFigures); + for (int i = 0; i < numberOfFigures; i++) { + buf.put(figures[i].getFiguresAttribute()); + buf.putInt(figures[i].getPointOffset()); + } + + buf.putInt(numberOfShapes); + for (int i = 0; i < numberOfShapes; i++) { + buf.putInt(shapes[i].getParentOffset()); + buf.putInt(shapes[i].getFigureOffset()); + buf.put(shapes[i].getOpenGISType()); + } + + if (version == 2 && null != segments) { + buf.putInt(numberOfSegments); + for (int i = 0; i < numberOfSegments; i++) { + buf.put(segments[i].getSegmentType()); + } + } + + if (noZM) { + wkbNoZM = buf.array(); + } else { + wkb = buf.array(); + + } + return; + } + + protected void parseWkb() { + srid = buffer.getInt(); + version = buffer.get(); + serializationProperties = buffer.get(); + + interpretSerializationPropBytes(); + readNumberOfPoints(); + readPoints(); + + if (hasZvalues) { + readZvalues(); + } + + if (hasMvalues) { + readMvalues(); + } + + if (!(isSinglePoint || isSingleLineSegment)) { + readNumberOfFigures(); + readFigures(); + readNumberOfShapes(); + readShapes(); + } + + determineInternalType(); + + if (buffer.hasRemaining()) { + if (version == 2 && internalType.getTypeCode() != 8 && internalType.getTypeCode() != 11) { + readNumberOfSegments(); + readSegments(); + } + } + } + + private void readPoints() { + points = new double[2 * numberOfPoints]; + for (int i = 0; i < numberOfPoints; i++) { + points[2 * i + 1] = buffer.getDouble(); + points[2 * i] = buffer.getDouble(); + } + } +} \ No newline at end of file diff --git a/Geometry.java b/Geometry.java new file mode 100644 index 0000000000..45d8939f40 --- /dev/null +++ b/Geometry.java @@ -0,0 +1,413 @@ +/* + * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made + * available under the terms of the MIT License. See the LICENSE file in the project root for more information. + */ + +package com.microsoft.sqlserver.jdbc; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + + +public class Geometry extends SQLServerSpatialDatatype { + + /** + * Private constructor used for creating a Geometry object from WKT and srid. + * + * @param WellKnownText + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @throws SQLServerException + * if an exception occurs + */ + private Geometry(String WellKnownText, int srid) throws SQLServerException { + this.wkt = WellKnownText; + this.srid = srid; + + try { + parseWKTForSerialization(this, currentWktPos, -1, false); + } catch (StringIndexOutOfBoundsException e) { + String strError = SQLServerException.getErrString("R_illegalWKT"); + throw new SQLServerException(strError, null, 0, null); + } + + serializeToWkb(false); + isNull = false; + } + + /** + * Private constructor used for creating a Geometry object from WKB. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @throws SQLServerException + * if an exception occurs + */ + private Geometry(byte[] wkb) throws SQLServerException { + this.wkb = wkb; + buffer = ByteBuffer.wrap(wkb); + buffer.order(ByteOrder.LITTLE_ENDIAN); + + parseWkb(); + + WKTsb = new StringBuffer(); + WKTsbNoZM = new StringBuffer(); + + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); + + wkt = WKTsb.toString(); + wktNoZM = WKTsbNoZM.toString(); + isNull = false; + } + + /** + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation + * augmented with any Z (elevation) and M (measure) values carried by the instance. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @return Geometry Geometry instance created from WKT and SRID + * @throws SQLServerException + * if an exception occurs + */ + public static Geometry STGeomFromText(String wkt, int srid) throws SQLServerException { + return new Geometry(wkt, srid); + } + + /** + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geometry Geometry instance created from WKB + * @throws SQLServerException + * if an exception occurs + */ + public static Geometry STGeomFromWKB(byte[] wkb) throws SQLServerException { + return new Geometry(wkb); + } + + /** + * Returns a constructed Geometry from an internal SQL Server format for spatial data. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geometry Geometry instance created from WKB + * @throws SQLServerException + * if an exception occurs + */ + public static Geometry deserialize(byte[] wkb) throws SQLServerException { + return new Geometry(wkb); + } + + /** + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID + * is defaulted to 0. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @return Geometry Geometry instance created from WKT + * @throws SQLServerException + * if an exception occurs + */ + public static Geometry parse(String wkt) throws SQLServerException { + return new Geometry(wkt, 0); + } + + /** + * Constructs a Geometry instance that represents a Point instance from its X and Y values and an SRID. + * + * @param x + * x coordinate + * @param y + * y coordinate + * @param srid + * SRID + * @return Geometry Geography instance + * @throws SQLServerException + * if an exception occurs + */ + public static Geometry point(double x, double y, int srid) throws SQLServerException { + return new Geometry("POINT (" + x + " " + y + ")", srid); + } + + /** + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance. This + * text will not contain any Z (elevation) or M (measure) values carried by the instance. + * + * @return the WKT representation without the Z and M values. + * @throws SQLServerException + * if an exception occurs + */ + public String STAsText() throws SQLServerException { + if (null == wktNoZM) { + buffer = ByteBuffer.wrap(wkb); + buffer.order(ByteOrder.LITTLE_ENDIAN); + + parseWkb(); + + WKTsb = new StringBuffer(); + WKTsbNoZM = new StringBuffer(); + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); + wktNoZM = WKTsbNoZM.toString(); + } + return wktNoZM; + } + + /** + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance. This + * value will not contain any Z or M values carried by the instance. + * + * @return byte array representation of the Geometry object. + */ + public byte[] STAsBinary() { + if (null == wkbNoZM) { + serializeToWkb(true); + } + return wkbNoZM; + } + + /** + * Returns the bytes that represent an internal SQL Server format of Geometry type. + * + * @return byte array representation of the Geometry object. + */ + public byte[] serialize() { + return wkb; + } + + /** + * Returns if the object contains a M (measure) value. + * + * @return boolean that indicates if the object contains M value. + */ + public boolean hasM() { + return hasMvalues; + } + + /** + * Returns if the object contains a Z (elevation) value. + * + * @return boolean that indicates if the object contains Z value. + */ + public boolean hasZ() { + return hasZvalues; + } + + /** + * Returns the X coordinate value. + * + * @return double value that represents the X coordinate. + */ + public Double getX() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { + return points[0]; + } + return null; + } + + /** + * Returns the Y coordinate value. + * + * @return double value that represents the Y coordinate. + */ + public Double getY() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { + return points[1]; + } + return null; + } + + /** + * Returns the M (measure) value of the object. + * + * @return double value that represents the M value. + */ + public Double getM() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { + return mValues[0]; + } + return null; + } + + /** + * Returns the Z (elevation) value of the object. + * + * @return double value that represents the Z value. + */ + public Double getZ() { + if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { + return zValues[0]; + } + return null; + } + + /** + * Returns the Spatial Reference Identifier (SRID) value. + * + * @return int value of SRID. + */ + public int getSrid() { + return srid; + } + + /** + * Returns if the Geometry object is null. + * + * @return boolean that indicates if the object is null. + */ + public boolean isNull() { + return isNull; + } + + /** + * Returns the number of points in the Geometry object. + * + * @return int that indicates the number of points in the Geometry object. + */ + public int STNumPoints() { + return numberOfPoints; + } + + /** + * Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance. + * + * @return String that contains the Geometry object's type name + */ + public String STGeometryType() { + if (null != internalType) { + return internalType.getTypeName(); + } + return null; + } + + /** + * Returns the Well-Known Text (WKT) representation of the Geometry object. + * + * @return String that contains the WKT representation of the Geometry object. + */ + public String asTextZM() { + return wkt; + } + + /** + * Returns the String representation of the Geometry object. + * + * @return String that contains the WKT representation of the Geometry object. + */ + @Override + public String toString() { + return wkt; + } + + protected void serializeToWkb(boolean noZM) { + ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); + createSerializationProperties(); + + buf.order(ByteOrder.LITTLE_ENDIAN); + buf.putInt(srid); + buf.put(version); + buf.put(serializationProperties); + + if (!isSinglePoint && !isSingleLineSegment) { + buf.putInt(numberOfPoints); + } + + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(points[2 * i]); + buf.putDouble(points[2 * i + 1]); + } + + if (!noZM) { + if (hasZvalues) { + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(zValues[i]); + } + } + + if (hasMvalues) { + for (int i = 0; i < numberOfPoints; i++) { + buf.putDouble(mValues[i]); + } + } + } + + if (isSinglePoint || isSingleLineSegment) { + wkb = buf.array(); + return; + } + + buf.putInt(numberOfFigures); + for (int i = 0; i < numberOfFigures; i++) { + buf.put(figures[i].getFiguresAttribute()); + buf.putInt(figures[i].getPointOffset()); + } + + buf.putInt(numberOfShapes); + for (int i = 0; i < numberOfShapes; i++) { + buf.putInt(shapes[i].getParentOffset()); + buf.putInt(shapes[i].getFigureOffset()); + buf.put(shapes[i].getOpenGISType()); + } + + if (version == 2 && null != segments) { + buf.putInt(numberOfSegments); + for (int i = 0; i < numberOfSegments; i++) { + buf.put(segments[i].getSegmentType()); + } + } + + if (noZM) { + wkbNoZM = buf.array(); + } else { + wkb = buf.array(); + + } + return; + } + + protected void parseWkb() { + srid = buffer.getInt(); + version = buffer.get(); + serializationProperties = buffer.get(); + + interpretSerializationPropBytes(); + readNumberOfPoints(); + readPoints(); + + if (hasZvalues) { + readZvalues(); + } + + if (hasMvalues) { + readMvalues(); + } + + if (!(isSinglePoint || isSingleLineSegment)) { + readNumberOfFigures(); + readFigures(); + readNumberOfShapes(); + readShapes(); + } + + determineInternalType(); + + if (buffer.hasRemaining()) { + if (version == 2 && internalType.getTypeCode() != 8 && internalType.getTypeCode() != 11) { + readNumberOfSegments(); + readSegments(); + } + } + } + + private void readPoints() { + points = new double[2 * numberOfPoints]; + for (int i = 0; i < numberOfPoints; i++) { + points[2 * i] = buffer.getDouble(); + points[2 * i + 1] = buffer.getDouble(); + } + } +} From 20c3b9195e70db383cbac5a3a8641537e0284bb0 Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Mon, 23 Jul 2018 16:19:18 -0700 Subject: [PATCH 6/9] fixed typo --- Geography.java | 412 ----------------- Geometry.java | 413 ------------------ .../microsoft/sqlserver/jdbc/Geography.java | 263 +++++++---- .../microsoft/sqlserver/jdbc/Geometry.java | 270 ++++++++---- 4 files changed, 348 insertions(+), 1010 deletions(-) delete mode 100644 Geography.java delete mode 100644 Geometry.java diff --git a/Geography.java b/Geography.java deleted file mode 100644 index 1bcac796cd..0000000000 --- a/Geography.java +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made - * available under the terms of the MIT License. See the LICENSE file in the project root for more information. - */ - -package com.microsoft.sqlserver.jdbc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -public class Geography extends SQLServerSpatialDatatype { - - /** - * Private constructor used for creating a Geography object from WKT and srid. - * - * @param WellKnownText - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @throws SQLServerException - * if an exception occurs - */ - private Geography(String WellKnownText, int srid) throws SQLServerException { - this.wkt = WellKnownText; - this.srid = srid; - - try { - parseWKTForSerialization(this, currentWktPos, -1, false); - } catch (StringIndexOutOfBoundsException e) { - String strError = SQLServerException.getErrString("R_illegalWKT"); - throw new SQLServerException(strError, null, 0, null); - } - - serializeToWkb(false); - isNull = false; - } - - /** - * Private constructor used for creating a Geography object from WKB. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @throws SQLServerException - * if an exception occurs - */ - private Geography(byte[] wkb) throws SQLServerException { - this.wkb = wkb; - buffer = ByteBuffer.wrap(wkb); - buffer.order(ByteOrder.LITTLE_ENDIAN); - - parseWkb(); - - WKTsb = new StringBuffer(); - WKTsbNoZM = new StringBuffer(); - - constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - - wkt = WKTsb.toString(); - wktNoZM = WKTsbNoZM.toString(); - isNull = false; - } - - /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation - * augmented with any Z (elevation) and M (measure) values carried by the instance. - * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @return Geography Geography instance created from WKT and SRID - * @throws SQLServerException - * if an exception occurs - */ - public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException { - return new Geography(wkt, srid); - } - - /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs - */ - public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException { - return new Geography(wkb); - } - - /** - * Returns a constructed Geography from an internal SQL Server format for spatial data. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geography Geography instance created from WKB - * @throws SQLServerException - * if an exception occurs - */ - public static Geography deserialize(byte[] wkb) throws SQLServerException { - return new Geography(wkb); - } - - /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID - * is defaulted to 4326. - * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @return Geography Geography instance created from WKT - * @throws SQLServerException - * if an exception occurs - */ - public static Geography parse(String wkt) throws SQLServerException { - return new Geography(wkt, 4326); - } - - /** - * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. - * - * @param x - * x coordinate - * @param y - * y coordinate - * @param srid - * SRID - * @return Geography Geography instance - * @throws SQLServerException - * if an exception occurs - */ - public static Geography point(double x, double y, int srid) throws SQLServerException { - return new Geography("POINT (" + x + " " + y + ")", srid); - } - - /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance. This - * text will not contain any Z (elevation) or M (measure) values carried by the instance. - * - * @return the WKT representation without the Z and M values. - * @throws SQLServerException - * if an exception occurs - */ - public String STAsText() throws SQLServerException { - if (null == wktNoZM) { - buffer = ByteBuffer.wrap(wkb); - buffer.order(ByteOrder.LITTLE_ENDIAN); - - parseWkb(); - - WKTsb = new StringBuffer(); - WKTsbNoZM = new StringBuffer(); - constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - wktNoZM = WKTsbNoZM.toString(); - } - return wktNoZM; - } - - /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance. This - * value will not contain any Z or M values carried by the instance. - * - * @return byte array representation of the Geography object. - */ - public byte[] STAsBinary() { - if (null == wkbNoZM) { - serializeToWkb(true); - } - return wkbNoZM; - } - - /** - * Returns the bytes that represent an internal SQL Server format of Geography type. - * - * @return byte array representation of the Geography object. - */ - public byte[] serialize() { - return wkb; - } - - /** - * Returns if the object contains a M (measure) value. - * - * @return boolean that indicates if the object contains M value. - */ - public boolean hasM() { - return hasMvalues; - } - - /** - * Returns if the object contains a Z (elevation) value. - * - * @return boolean that indicates if the object contains Z value. - */ - public boolean hasZ() { - return hasZvalues; - } - - /** - * Returns the X coordinate value. - * - * @return double value that represents the X coordinate. - */ - public Double getX() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { - return points[0]; - } - return null; - } - - /** - * Returns the Y coordinate value. - * - * @return double value that represents the Y coordinate. - */ - public Double getY() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { - return points[1]; - } - return null; - } - - /** - * Returns the M (measure) value of the object. - * - * @return double value that represents the M value. - */ - public Double getM() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { - return mValues[0]; - } - return null; - } - - /** - * Returns the Z (elevation) value of the object. - * - * @return double value that represents the Z value. - */ - public Double getZ() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { - return zValues[0]; - } - return null; - } - - /** - * Returns the Spatial Reference Identifier (SRID) value. - * - * @return int value of SRID. - */ - public int getSrid() { - return srid; - } - - /** - * Returns if the Geography object is null. - * - * @return boolean that indicates if the object is null. - */ - public boolean isNull() { - return isNull; - } - - /** - * Returns the number of points in the Geography object. - * - * @return int that indicates the number of points in the Geography object. - */ - public int STNumPoints() { - return numberOfPoints; - } - - /** - * Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance. - * - * @return String that contains the Geography object's type name - */ - public String STGeographyType() { - if (null != internalType) { - return internalType.getTypeName(); - } - return null; - } - - /** - * Returns the Well-Known Text (WKT) representation of the Geography object. - * - * @return String that contains the WKT representation of the Geography object. - */ - public String asTextZM() { - return wkt; - } - - /** - * Returns the String representation of the Geography object. - * - * @return String that contains the WKT representation of the Geography object. - */ - @Override - public String toString() { - return wkt; - } - - protected void serializeToWkb(boolean noZM) { - ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); - createSerializationProperties(); - - buf.order(ByteOrder.LITTLE_ENDIAN); - buf.putInt(srid); - buf.put(version); - buf.put(serializationProperties); - - if (!isSinglePoint && !isSingleLineSegment) { - buf.putInt(numberOfPoints); - } - - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(points[2 * i + 1]); - buf.putDouble(points[2 * i]); - } - - if (!noZM) { - if (hasZvalues) { - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(zValues[i]); - } - } - if (hasMvalues) { - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(mValues[i]); - } - } - } - - if (isSinglePoint || isSingleLineSegment) { - wkb = buf.array(); - return; - } - - buf.putInt(numberOfFigures); - for (int i = 0; i < numberOfFigures; i++) { - buf.put(figures[i].getFiguresAttribute()); - buf.putInt(figures[i].getPointOffset()); - } - - buf.putInt(numberOfShapes); - for (int i = 0; i < numberOfShapes; i++) { - buf.putInt(shapes[i].getParentOffset()); - buf.putInt(shapes[i].getFigureOffset()); - buf.put(shapes[i].getOpenGISType()); - } - - if (version == 2 && null != segments) { - buf.putInt(numberOfSegments); - for (int i = 0; i < numberOfSegments; i++) { - buf.put(segments[i].getSegmentType()); - } - } - - if (noZM) { - wkbNoZM = buf.array(); - } else { - wkb = buf.array(); - - } - return; - } - - protected void parseWkb() { - srid = buffer.getInt(); - version = buffer.get(); - serializationProperties = buffer.get(); - - interpretSerializationPropBytes(); - readNumberOfPoints(); - readPoints(); - - if (hasZvalues) { - readZvalues(); - } - - if (hasMvalues) { - readMvalues(); - } - - if (!(isSinglePoint || isSingleLineSegment)) { - readNumberOfFigures(); - readFigures(); - readNumberOfShapes(); - readShapes(); - } - - determineInternalType(); - - if (buffer.hasRemaining()) { - if (version == 2 && internalType.getTypeCode() != 8 && internalType.getTypeCode() != 11) { - readNumberOfSegments(); - readSegments(); - } - } - } - - private void readPoints() { - points = new double[2 * numberOfPoints]; - for (int i = 0; i < numberOfPoints; i++) { - points[2 * i + 1] = buffer.getDouble(); - points[2 * i] = buffer.getDouble(); - } - } -} \ No newline at end of file diff --git a/Geometry.java b/Geometry.java deleted file mode 100644 index 45d8939f40..0000000000 --- a/Geometry.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made - * available under the terms of the MIT License. See the LICENSE file in the project root for more information. - */ - -package com.microsoft.sqlserver.jdbc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -public class Geometry extends SQLServerSpatialDatatype { - - /** - * Private constructor used for creating a Geometry object from WKT and srid. - * - * @param WellKnownText - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @throws SQLServerException - * if an exception occurs - */ - private Geometry(String WellKnownText, int srid) throws SQLServerException { - this.wkt = WellKnownText; - this.srid = srid; - - try { - parseWKTForSerialization(this, currentWktPos, -1, false); - } catch (StringIndexOutOfBoundsException e) { - String strError = SQLServerException.getErrString("R_illegalWKT"); - throw new SQLServerException(strError, null, 0, null); - } - - serializeToWkb(false); - isNull = false; - } - - /** - * Private constructor used for creating a Geometry object from WKB. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @throws SQLServerException - * if an exception occurs - */ - private Geometry(byte[] wkb) throws SQLServerException { - this.wkb = wkb; - buffer = ByteBuffer.wrap(wkb); - buffer.order(ByteOrder.LITTLE_ENDIAN); - - parseWkb(); - - WKTsb = new StringBuffer(); - WKTsbNoZM = new StringBuffer(); - - constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - - wkt = WKTsb.toString(); - wktNoZM = WKTsbNoZM.toString(); - isNull = false; - } - - /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation - * augmented with any Z (elevation) and M (measure) values carried by the instance. - * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @param srid - * Spatial Reference Identifier (SRID) provided by the user. - * @return Geometry Geometry instance created from WKT and SRID - * @throws SQLServerException - * if an exception occurs - */ - public static Geometry STGeomFromText(String wkt, int srid) throws SQLServerException { - return new Geometry(wkt, srid); - } - - /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geometry Geometry instance created from WKB - * @throws SQLServerException - * if an exception occurs - */ - public static Geometry STGeomFromWKB(byte[] wkb) throws SQLServerException { - return new Geometry(wkb); - } - - /** - * Returns a constructed Geometry from an internal SQL Server format for spatial data. - * - * @param wkb - * Well-Known Binary (WKB) provided by the user. - * @return Geometry Geometry instance created from WKB - * @throws SQLServerException - * if an exception occurs - */ - public static Geometry deserialize(byte[] wkb) throws SQLServerException { - return new Geometry(wkb); - } - - /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID - * is defaulted to 0. - * - * @param wkt - * Well-Known Text (WKT) provided by the user. - * @return Geometry Geometry instance created from WKT - * @throws SQLServerException - * if an exception occurs - */ - public static Geometry parse(String wkt) throws SQLServerException { - return new Geometry(wkt, 0); - } - - /** - * Constructs a Geometry instance that represents a Point instance from its X and Y values and an SRID. - * - * @param x - * x coordinate - * @param y - * y coordinate - * @param srid - * SRID - * @return Geometry Geography instance - * @throws SQLServerException - * if an exception occurs - */ - public static Geometry point(double x, double y, int srid) throws SQLServerException { - return new Geometry("POINT (" + x + " " + y + ")", srid); - } - - /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance. This - * text will not contain any Z (elevation) or M (measure) values carried by the instance. - * - * @return the WKT representation without the Z and M values. - * @throws SQLServerException - * if an exception occurs - */ - public String STAsText() throws SQLServerException { - if (null == wktNoZM) { - buffer = ByteBuffer.wrap(wkb); - buffer.order(ByteOrder.LITTLE_ENDIAN); - - parseWkb(); - - WKTsb = new StringBuffer(); - WKTsbNoZM = new StringBuffer(); - constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - wktNoZM = WKTsbNoZM.toString(); - } - return wktNoZM; - } - - /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance. This - * value will not contain any Z or M values carried by the instance. - * - * @return byte array representation of the Geometry object. - */ - public byte[] STAsBinary() { - if (null == wkbNoZM) { - serializeToWkb(true); - } - return wkbNoZM; - } - - /** - * Returns the bytes that represent an internal SQL Server format of Geometry type. - * - * @return byte array representation of the Geometry object. - */ - public byte[] serialize() { - return wkb; - } - - /** - * Returns if the object contains a M (measure) value. - * - * @return boolean that indicates if the object contains M value. - */ - public boolean hasM() { - return hasMvalues; - } - - /** - * Returns if the object contains a Z (elevation) value. - * - * @return boolean that indicates if the object contains Z value. - */ - public boolean hasZ() { - return hasZvalues; - } - - /** - * Returns the X coordinate value. - * - * @return double value that represents the X coordinate. - */ - public Double getX() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { - return points[0]; - } - return null; - } - - /** - * Returns the Y coordinate value. - * - * @return double value that represents the Y coordinate. - */ - public Double getY() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { - return points[1]; - } - return null; - } - - /** - * Returns the M (measure) value of the object. - * - * @return double value that represents the M value. - */ - public Double getM() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { - return mValues[0]; - } - return null; - } - - /** - * Returns the Z (elevation) value of the object. - * - * @return double value that represents the Z value. - */ - public Double getZ() { - if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { - return zValues[0]; - } - return null; - } - - /** - * Returns the Spatial Reference Identifier (SRID) value. - * - * @return int value of SRID. - */ - public int getSrid() { - return srid; - } - - /** - * Returns if the Geometry object is null. - * - * @return boolean that indicates if the object is null. - */ - public boolean isNull() { - return isNull; - } - - /** - * Returns the number of points in the Geometry object. - * - * @return int that indicates the number of points in the Geometry object. - */ - public int STNumPoints() { - return numberOfPoints; - } - - /** - * Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance. - * - * @return String that contains the Geometry object's type name - */ - public String STGeometryType() { - if (null != internalType) { - return internalType.getTypeName(); - } - return null; - } - - /** - * Returns the Well-Known Text (WKT) representation of the Geometry object. - * - * @return String that contains the WKT representation of the Geometry object. - */ - public String asTextZM() { - return wkt; - } - - /** - * Returns the String representation of the Geometry object. - * - * @return String that contains the WKT representation of the Geometry object. - */ - @Override - public String toString() { - return wkt; - } - - protected void serializeToWkb(boolean noZM) { - ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); - createSerializationProperties(); - - buf.order(ByteOrder.LITTLE_ENDIAN); - buf.putInt(srid); - buf.put(version); - buf.put(serializationProperties); - - if (!isSinglePoint && !isSingleLineSegment) { - buf.putInt(numberOfPoints); - } - - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(points[2 * i]); - buf.putDouble(points[2 * i + 1]); - } - - if (!noZM) { - if (hasZvalues) { - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(zValues[i]); - } - } - - if (hasMvalues) { - for (int i = 0; i < numberOfPoints; i++) { - buf.putDouble(mValues[i]); - } - } - } - - if (isSinglePoint || isSingleLineSegment) { - wkb = buf.array(); - return; - } - - buf.putInt(numberOfFigures); - for (int i = 0; i < numberOfFigures; i++) { - buf.put(figures[i].getFiguresAttribute()); - buf.putInt(figures[i].getPointOffset()); - } - - buf.putInt(numberOfShapes); - for (int i = 0; i < numberOfShapes; i++) { - buf.putInt(shapes[i].getParentOffset()); - buf.putInt(shapes[i].getFigureOffset()); - buf.put(shapes[i].getOpenGISType()); - } - - if (version == 2 && null != segments) { - buf.putInt(numberOfSegments); - for (int i = 0; i < numberOfSegments; i++) { - buf.put(segments[i].getSegmentType()); - } - } - - if (noZM) { - wkbNoZM = buf.array(); - } else { - wkb = buf.array(); - - } - return; - } - - protected void parseWkb() { - srid = buffer.getInt(); - version = buffer.get(); - serializationProperties = buffer.get(); - - interpretSerializationPropBytes(); - readNumberOfPoints(); - readPoints(); - - if (hasZvalues) { - readZvalues(); - } - - if (hasMvalues) { - readMvalues(); - } - - if (!(isSinglePoint || isSingleLineSegment)) { - readNumberOfFigures(); - readFigures(); - readNumberOfShapes(); - readShapes(); - } - - determineInternalType(); - - if (buffer.hasRemaining()) { - if (version == 2 && internalType.getTypeCode() != 8 && internalType.getTypeCode() != 11) { - readNumberOfSegments(); - readSegments(); - } - } - } - - private void readPoints() { - points = new double[2 * numberOfPoints]; - for (int i = 0; i < numberOfPoints; i++) { - points[2 * i] = buffer.getDouble(); - points[2 * i + 1] = buffer.getDouble(); - } - } -} diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java index 0790a06912..1bcac796cd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geography.java @@ -1,9 +1,6 @@ /* - * Microsoft JDBC Driver for SQL Server - * - * Copyright(c) Microsoft Corporation All rights reserved. - * - * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. + * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made + * available under the terms of the MIT License. See the LICENSE file in the project root for more information. */ package com.microsoft.sqlserver.jdbc; @@ -11,119 +8,147 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; + public class Geography extends SQLServerSpatialDatatype { - + /** * Private constructor used for creating a Geography object from WKT and srid. + * + * @param WellKnownText + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @throws SQLServerException + * if an exception occurs */ - private Geography(String WellKnownText, int srid) { + private Geography(String WellKnownText, int srid) throws SQLServerException { this.wkt = WellKnownText; this.srid = srid; - + try { parseWKTForSerialization(this, currentWktPos, -1, false); + } catch (StringIndexOutOfBoundsException e) { + String strError = SQLServerException.getErrString("R_illegalWKT"); + throw new SQLServerException(strError, null, 0, null); } - catch (StringIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid."); - } - + serializeToWkb(false); isNull = false; } /** * Private constructor used for creating a Geography object from WKB. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @throws SQLServerException + * if an exception occurs */ - private Geography(byte[] wkb) { + private Geography(byte[] wkb) throws SQLServerException { this.wkb = wkb; buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); - + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - + wkt = WKTsb.toString(); wktNoZM = WKTsbNoZM.toString(); isNull = false; } - - public Geography() { - // TODO Auto-generated constructor stub - } - + /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) - * representation augmented with any Z (elevation) and M (measure) values carried by the instance. - * - * @param wkt WKT - * @param srid SRID - * @return Geography instance + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation + * augmented with any Z (elevation) and M (measure) values carried by the instance. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @return Geography Geography instance created from WKT and SRID + * @throws SQLServerException + * if an exception occurs */ - public static Geography STGeomFromText(String wkt, int srid) { + public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException { return new Geography(wkt, srid); } - + /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) - * Well-Known Binary (WKB) representation. + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. * - * @param wkb WKB - * @return Geography instance + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geography Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs */ - public static Geography STGeomFromWKB(byte[] wkb) { + public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException { return new Geography(wkb); } - + /** * Returns a constructed Geography from an internal SQL Server format for spatial data. * - * @param wkb WKB - * @return Geography instance + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geography Geography instance created from WKB + * @throws SQLServerException + * if an exception occurs */ - public static Geography deserialize(byte[] wkb) { + public static Geography deserialize(byte[] wkb) throws SQLServerException { return new Geography(wkb); } /** - * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. - * SRID is defaulted to 4326. + * Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID + * is defaulted to 4326. * - * @param wkt WKt - * @return Geography instance + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @return Geography Geography instance created from WKT + * @throws SQLServerException + * if an exception occurs */ - public static Geography parse(String wkt) { + public static Geography parse(String wkt) throws SQLServerException { return new Geography(wkt, 4326); } - + /** * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. * - * @param x x coordinate - * @param y y coordinate - * @param srid SRID - * @return Geography instance + * @param x + * x coordinate + * @param y + * y coordinate + * @param srid + * SRID + * @return Geography Geography instance + * @throws SQLServerException + * if an exception occurs */ - public static Geography point(double x, double y, int srid) { + public static Geography point(double x, double y, int srid) throws SQLServerException { return new Geography("POINT (" + x + " " + y + ")", srid); } /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a - * Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance. + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geography instance. This + * text will not contain any Z (elevation) or M (measure) values carried by the instance. * * @return the WKT representation without the Z and M values. + * @throws SQLServerException + * if an exception occurs */ - public String STAsText() { + public String STAsText() throws SQLServerException { if (null == wktNoZM) { buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); @@ -131,11 +156,12 @@ public String STAsText() { } return wktNoZM; } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a - * Geography instance. This value will not contain any Z or M values carried by the instance. - * @return WKB + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geography instance. This + * value will not contain any Z or M values carried by the instance. + * + * @return byte array representation of the Geography object. */ public byte[] STAsBinary() { if (null == wkbNoZM) { @@ -143,45 +169,75 @@ public byte[] STAsBinary() { } return wkbNoZM; } - + /** - * Returns the bytes that represent an internal SQL Server format of Geography type. + * Returns the bytes that represent an internal SQL Server format of Geography type. * - * @return WKB + * @return byte array representation of the Geography object. */ public byte[] serialize() { return wkb; } - + + /** + * Returns if the object contains a M (measure) value. + * + * @return boolean that indicates if the object contains M value. + */ public boolean hasM() { return hasMvalues; } - + + /** + * Returns if the object contains a Z (elevation) value. + * + * @return boolean that indicates if the object contains Z value. + */ public boolean hasZ() { return hasZvalues; } - + + /** + * Returns the X coordinate value. + * + * @return double value that represents the X coordinate. + */ public Double getX() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[0]; } return null; } - + + /** + * Returns the Y coordinate value. + * + * @return double value that represents the Y coordinate. + */ public Double getY() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[1]; } return null; } - + + /** + * Returns the M (measure) value of the object. + * + * @return double value that represents the M value. + */ public Double getM() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { return mValues[0]; } return null; } - + + /** + * Returns the Z (elevation) value of the object. + * + * @return double value that represents the Z value. + */ public Double getZ() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { return zValues[0]; @@ -189,14 +245,29 @@ public Double getZ() { return null; } + /** + * Returns the Spatial Reference Identifier (SRID) value. + * + * @return int value of SRID. + */ public int getSrid() { return srid; } - + + /** + * Returns if the Geography object is null. + * + * @return boolean that indicates if the object is null. + */ public boolean isNull() { return isNull; } - + + /** + * Returns the number of points in the Geography object. + * + * @return int that indicates the number of points in the Geography object. + */ public int STNumPoints() { return numberOfPoints; } @@ -204,7 +275,7 @@ public int STNumPoints() { /** * Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance. * - * @return type name + * @return String that contains the Geography object's type name */ public String STGeographyType() { if (null != internalType) { @@ -212,11 +283,22 @@ public String STGeographyType() { } return null; } - + + /** + * Returns the Well-Known Text (WKT) representation of the Geography object. + * + * @return String that contains the WKT representation of the Geography object. + */ public String asTextZM() { return wkt; } - + + /** + * Returns the String representation of the Geography object. + * + * @return String that contains the WKT representation of the Geography object. + */ + @Override public String toString() { return wkt; } @@ -224,61 +306,60 @@ public String toString() { protected void serializeToWkb(boolean noZM) { ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); createSerializationProperties(); - + buf.order(ByteOrder.LITTLE_ENDIAN); buf.putInt(srid); buf.put(version); buf.put(serializationProperties); - + if (!isSinglePoint && !isSingleLineSegment) { buf.putInt(numberOfPoints); } - + for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(points[2 * i + 1]); buf.putDouble(points[2 * i]); } - + if (!noZM) { if (hasZvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(zValues[i]); } } - if (hasMvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(mValues[i]); } } } - + if (isSinglePoint || isSingleLineSegment) { wkb = buf.array(); return; } - + buf.putInt(numberOfFigures); for (int i = 0; i < numberOfFigures; i++) { buf.put(figures[i].getFiguresAttribute()); buf.putInt(figures[i].getPointOffset()); } - + buf.putInt(numberOfShapes); for (int i = 0; i < numberOfShapes; i++) { buf.putInt(shapes[i].getParentOffset()); buf.putInt(shapes[i].getFigureOffset()); buf.put(shapes[i].getOpenGISType()); } - + if (version == 2 && null != segments) { buf.putInt(numberOfSegments); for (int i = 0; i < numberOfSegments; i++) { buf.put(segments[i].getSegmentType()); } } - - if (noZM) { + + if (noZM) { wkbNoZM = buf.array(); } else { wkb = buf.array(); @@ -286,31 +367,31 @@ protected void serializeToWkb(boolean noZM) { } return; } - + protected void parseWkb() { srid = buffer.getInt(); version = buffer.get(); serializationProperties = buffer.get(); - + interpretSerializationPropBytes(); readNumberOfPoints(); readPoints(); - + if (hasZvalues) { readZvalues(); } - + if (hasMvalues) { readMvalues(); } - + if (!(isSinglePoint || isSingleLineSegment)) { readNumberOfFigures(); readFigures(); readNumberOfShapes(); readShapes(); } - + determineInternalType(); if (buffer.hasRemaining()) { @@ -320,7 +401,7 @@ protected void parseWkb() { } } } - + private void readPoints() { points = new double[2 * numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java index 90f4427a5a..45d8939f40 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java @@ -1,9 +1,6 @@ /* - * Microsoft JDBC Driver for SQL Server - * - * Copyright(c) Microsoft Corporation All rights reserved. - * - * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. + * Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made + * available under the terms of the MIT License. See the LICENSE file in the project root for more information. */ package com.microsoft.sqlserver.jdbc; @@ -11,119 +8,147 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; + public class Geometry extends SQLServerSpatialDatatype { - + /** * Private constructor used for creating a Geometry object from WKT and srid. + * + * @param WellKnownText + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @throws SQLServerException + * if an exception occurs */ - private Geometry(String WellKnownText, int srid) { + private Geometry(String WellKnownText, int srid) throws SQLServerException { this.wkt = WellKnownText; this.srid = srid; - + try { parseWKTForSerialization(this, currentWktPos, -1, false); + } catch (StringIndexOutOfBoundsException e) { + String strError = SQLServerException.getErrString("R_illegalWKT"); + throw new SQLServerException(strError, null, 0, null); } - catch (StringIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Reached unexpected end of WKT. Please make sure WKT is valid."); - } - + serializeToWkb(false); isNull = false; } /** * Private constructor used for creating a Geometry object from WKB. + * + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @throws SQLServerException + * if an exception occurs */ - private Geometry(byte[] wkb) { + private Geometry(byte[] wkb) throws SQLServerException { this.wkb = wkb; buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); - + constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); - + wkt = WKTsb.toString(); wktNoZM = WKTsbNoZM.toString(); isNull = false; } - - public Geometry() { - // TODO Auto-generated constructor stub - } - + /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) - * representation augmented with any Z (elevation) and M (measure) values carried by the instance. - * - * @param wkt WKT - * @param srid SRID - * @return Geometry instance + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation + * augmented with any Z (elevation) and M (measure) values carried by the instance. + * + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @param srid + * Spatial Reference Identifier (SRID) provided by the user. + * @return Geometry Geometry instance created from WKT and SRID + * @throws SQLServerException + * if an exception occurs */ - public static Geometry STGeomFromText(String wkt, int srid) { + public static Geometry STGeomFromText(String wkt, int srid) throws SQLServerException { return new Geometry(wkt, srid); } - + /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) - * Well-Known Binary (WKB) representation. + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation. * - * @param wkb WKB - * @return Geometry instance + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geometry Geometry instance created from WKB + * @throws SQLServerException + * if an exception occurs */ - public static Geometry STGeomFromWKB(byte[] wkb) { + public static Geometry STGeomFromWKB(byte[] wkb) throws SQLServerException { return new Geometry(wkb); } - + /** * Returns a constructed Geometry from an internal SQL Server format for spatial data. * - * @param wkb WKB - * @return Geometry instance + * @param wkb + * Well-Known Binary (WKB) provided by the user. + * @return Geometry Geometry instance created from WKB + * @throws SQLServerException + * if an exception occurs */ - public static Geometry deserialize(byte[] wkb) { + public static Geometry deserialize(byte[] wkb) throws SQLServerException { return new Geometry(wkb); } /** - * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. - * SRID is defaulted to 0. + * Returns a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation. SRID + * is defaulted to 0. * - * @param wkt WKT - * @return Geometry instance + * @param wkt + * Well-Known Text (WKT) provided by the user. + * @return Geometry Geometry instance created from WKT + * @throws SQLServerException + * if an exception occurs */ - public static Geometry parse(String wkt) { + public static Geometry parse(String wkt) throws SQLServerException { return new Geometry(wkt, 0); } - + /** * Constructs a Geometry instance that represents a Point instance from its X and Y values and an SRID. * - * @param x x coordinate - * @param y y coordinate - * @param srid SRID - * @return Geometry instance + * @param x + * x coordinate + * @param y + * y coordinate + * @param srid + * SRID + * @return Geometry Geography instance + * @throws SQLServerException + * if an exception occurs */ - public static Geometry point(double x, double y, int srid) { + public static Geometry point(double x, double y, int srid) throws SQLServerException { return new Geometry("POINT (" + x + " " + y + ")", srid); } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a - * Geometry instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance. + * Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a Geometry instance. This + * text will not contain any Z (elevation) or M (measure) values carried by the instance. * * @return the WKT representation without the Z and M values. + * @throws SQLServerException + * if an exception occurs */ - public String STAsText() { + public String STAsText() throws SQLServerException { if (null == wktNoZM) { buffer = ByteBuffer.wrap(wkb); buffer.order(ByteOrder.LITTLE_ENDIAN); - + parseWkb(); - + WKTsb = new StringBuffer(); WKTsbNoZM = new StringBuffer(); constructWKT(this, internalType, numberOfPoints, numberOfFigures, numberOfSegments, numberOfShapes); @@ -131,11 +156,12 @@ public String STAsText() { } return wktNoZM; } - + /** - * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a - * Geometry instance. This value will not contain any Z or M values carried by the instance. - * @return WKB + * Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a Geometry instance. This + * value will not contain any Z or M values carried by the instance. + * + * @return byte array representation of the Geometry object. */ public byte[] STAsBinary() { if (null == wkbNoZM) { @@ -143,45 +169,75 @@ public byte[] STAsBinary() { } return wkbNoZM; } - + /** - * Returns the bytes that represent an internal SQL Server format of Geometry type. + * Returns the bytes that represent an internal SQL Server format of Geometry type. * - * @return WKB + * @return byte array representation of the Geometry object. */ public byte[] serialize() { return wkb; } - + + /** + * Returns if the object contains a M (measure) value. + * + * @return boolean that indicates if the object contains M value. + */ public boolean hasM() { return hasMvalues; } - + + /** + * Returns if the object contains a Z (elevation) value. + * + * @return boolean that indicates if the object contains Z value. + */ public boolean hasZ() { return hasZvalues; } - + + /** + * Returns the X coordinate value. + * + * @return double value that represents the X coordinate. + */ public Double getX() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[0]; } return null; } - + + /** + * Returns the Y coordinate value. + * + * @return double value that represents the Y coordinate. + */ public Double getY() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) { return points[1]; } return null; } - + + /** + * Returns the M (measure) value of the object. + * + * @return double value that represents the M value. + */ public Double getM() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) { return mValues[0]; } return null; } - + + /** + * Returns the Z (elevation) value of the object. + * + * @return double value that represents the Z value. + */ public Double getZ() { if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) { return zValues[0]; @@ -189,14 +245,29 @@ public Double getZ() { return null; } + /** + * Returns the Spatial Reference Identifier (SRID) value. + * + * @return int value of SRID. + */ public int getSrid() { return srid; } - + + /** + * Returns if the Geometry object is null. + * + * @return boolean that indicates if the object is null. + */ public boolean isNull() { return isNull; } - + + /** + * Returns the number of points in the Geometry object. + * + * @return int that indicates the number of points in the Geometry object. + */ public int STNumPoints() { return numberOfPoints; } @@ -204,7 +275,7 @@ public int STNumPoints() { /** * Returns the Open Geospatial Consortium (OGC) type name represented by a geometry instance. * - * @return type name + * @return String that contains the Geometry object's type name */ public String STGeometryType() { if (null != internalType) { @@ -212,73 +283,84 @@ public String STGeometryType() { } return null; } - + + /** + * Returns the Well-Known Text (WKT) representation of the Geometry object. + * + * @return String that contains the WKT representation of the Geometry object. + */ public String asTextZM() { return wkt; } - + + /** + * Returns the String representation of the Geometry object. + * + * @return String that contains the WKT representation of the Geometry object. + */ + @Override public String toString() { return wkt; } - + protected void serializeToWkb(boolean noZM) { ByteBuffer buf = ByteBuffer.allocate(determineWkbCapacity()); createSerializationProperties(); - + buf.order(ByteOrder.LITTLE_ENDIAN); buf.putInt(srid); buf.put(version); buf.put(serializationProperties); - + if (!isSinglePoint && !isSingleLineSegment) { buf.putInt(numberOfPoints); } - + for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(points[2 * i]); buf.putDouble(points[2 * i + 1]); } - - if (!noZM ) { + + if (!noZM) { if (hasZvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(zValues[i]); } } - + if (hasMvalues) { for (int i = 0; i < numberOfPoints; i++) { buf.putDouble(mValues[i]); } } } - + if (isSinglePoint || isSingleLineSegment) { wkb = buf.array(); return; } - + buf.putInt(numberOfFigures); for (int i = 0; i < numberOfFigures; i++) { buf.put(figures[i].getFiguresAttribute()); buf.putInt(figures[i].getPointOffset()); } - + buf.putInt(numberOfShapes); for (int i = 0; i < numberOfShapes; i++) { buf.putInt(shapes[i].getParentOffset()); buf.putInt(shapes[i].getFigureOffset()); buf.put(shapes[i].getOpenGISType()); } - + if (version == 2 && null != segments) { buf.putInt(numberOfSegments); for (int i = 0; i < numberOfSegments; i++) { buf.put(segments[i].getSegmentType()); } } - - if (noZM) { + + if (noZM) { wkbNoZM = buf.array(); } else { wkb = buf.array(); @@ -286,31 +368,31 @@ protected void serializeToWkb(boolean noZM) { } return; } - + protected void parseWkb() { srid = buffer.getInt(); version = buffer.get(); serializationProperties = buffer.get(); - + interpretSerializationPropBytes(); readNumberOfPoints(); readPoints(); - + if (hasZvalues) { readZvalues(); } - + if (hasMvalues) { readMvalues(); } - + if (!(isSinglePoint || isSingleLineSegment)) { readNumberOfFigures(); readFigures(); readNumberOfShapes(); readShapes(); } - + determineInternalType(); if (buffer.hasRemaining()) { @@ -320,7 +402,7 @@ protected void parseWkb() { } } } - + private void readPoints() { points = new double[2 * numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { From 5dc54bd0390dd8ebb7cbb34bcdb174729e55614e Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Tue, 24 Jul 2018 16:21:13 -0700 Subject: [PATCH 7/9] review updates --- .../microsoft/sqlserver/jdbc/DataTypes.java | 50 ++- .../sqlserver/jdbc/ISQLServerBulkRecord.java | 6 +- .../jdbc/ISQLServerCallableStatement.java | 12 +- .../sqlserver/jdbc/ISQLServerConnection.java | 6 +- .../sqlserver/jdbc/ISQLServerDataRecord.java | 6 +- .../sqlserver/jdbc/ISQLServerDataSource.java | 111 +++--- .../jdbc/ISQLServerPreparedStatement.java | 29 +- .../sqlserver/jdbc/ISQLServerResultSet.java | 12 +- .../jdbc/ISQLServerResultSetMetaData.java | 2 +- .../sqlserver/jdbc/ISQLServerStatement.java | 4 +- .../jdbc/InternalSpatialDatatype.java | 2 - .../sqlserver/jdbc/KerbCallback.java | 3 +- .../jdbc/SQLServerBulkBatchInsertRecord.java | 4 +- .../jdbc/SQLServerBulkCSVFileRecord.java | 6 +- .../sqlserver/jdbc/SQLServerBulkCopy.java | 21 +- .../jdbc/SQLServerBulkCopyOptions.java | 2 +- .../sqlserver/jdbc/SQLServerClob.java | 59 ++- ...ColumnEncryptionAzureKeyVaultProvider.java | 22 +- ...umnEncryptionCertificateStoreProvider.java | 6 +- ...rColumnEncryptionJavaKeyStoreProvider.java | 6 +- ...erverColumnEncryptionKeyStoreProvider.java | 15 +- .../sqlserver/jdbc/SQLServerConnection.java | 177 +++++---- .../sqlserver/jdbc/SQLServerConnection43.java | 8 +- .../SQLServerConnectionPoolDataSource.java | 15 +- .../jdbc/SQLServerConnectionPoolProxy.java | 10 +- .../sqlserver/jdbc/SQLServerDataSource.java | 353 ++++++++++-------- .../SQLServerDataSourceObjectFactory.java | 9 +- .../sqlserver/jdbc/SQLServerDataTable.java | 10 +- .../jdbc/SQLServerDatabaseMetaData.java | 37 +- .../sqlserver/jdbc/SQLServerDriver.java | 39 +- .../sqlserver/jdbc/SQLServerException.java | 19 +- .../sqlserver/jdbc/SQLServerLob.java | 2 +- .../sqlserver/jdbc/SQLServerMetaData.java | 21 +- .../jdbc/SQLServerParameterMetaData.java | 4 +- .../jdbc/SQLServerPooledConnection.java | 15 +- .../jdbc/SQLServerPreparedStatement.java | 17 +- .../sqlserver/jdbc/SQLServerResultSet.java | 20 +- .../jdbc/SQLServerResultSetMetaData.java | 5 +- .../sqlserver/jdbc/SQLServerSQLXML.java | 25 +- .../sqlserver/jdbc/SQLServerSavepoint.java | 6 +- .../jdbc/SQLServerSpatialDatatype.java | 24 +- .../sqlserver/jdbc/SQLServerStatement.java | 63 ++-- .../sqlserver/jdbc/SQLServerXADataSource.java | 10 +- .../sqlserver/jdbc/SQLServerXAResource.java | 13 +- .../microsoft/sqlserver/jdbc/SqlVariant.java | 28 +- .../SensitivityClassification.java | 3 +- .../jdbc/dns/DNSKerberosLocator.java | 1 + .../resultset/DataClassificationTest.java | 3 +- 48 files changed, 665 insertions(+), 656 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java index 93459e5493..6b445ef852 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java @@ -532,10 +532,9 @@ static JavaType of(Object obj) { } /** - * Returns the JDBC type to use with this Java type. We use the static JDBC type associated - * with the Java type by default, ignoring the JDBC type specified by the application. This - * behavior is overridden for certain Java types, such as InputStream, which requires the JDBC - * type to be specified externally in order to distinguish between. + * Returns the JDBC type to use with this Java type. We use the static JDBC type associated with the Java type by + * default, ignoring the JDBC type specified by the application. This behavior is overridden for certain Java types, + * such as InputStream, which requires the JDBC type to be specified externally in order to distinguish between. */ JDBCType getJDBCType(SSType ssType, JDBCType jdbcTypeFromApp) { return jdbcTypeFromJavaType; @@ -956,7 +955,7 @@ boolean isTextual() { } /** - * Identify unsupported JDBC data types. + * Return if datat types are supported by JDBC * * @param jdbcType * the JDBC type to check @@ -1095,20 +1094,20 @@ static final void throwConversionError(String fromType, String toType) throws SQ } /** - * Max length in Unicode characters allowed by the "short" NVARCHAR type. - * Values longer than this must use NVARCHAR(max) (Yukon or later) or NTEXT (Shiloh) + * Max length in Unicode characters allowed by the "short" NVARCHAR type. Values longer than this must use + * NVARCHAR(max) (Yukon or later) or NTEXT (Shiloh) */ final static int SHORT_VARTYPE_MAX_CHARS = 4000; /** - * Max length in bytes allowed by the "short" VARBINARY/VARCHAR types. - * Values longer than this must use VARBINARY(max)/VARCHAR(max) (Yukon or later) or IMAGE/TEXT (Shiloh) + * Max length in bytes allowed by the "short" VARBINARY/VARCHAR types. Values longer than this must use + * VARBINARY(max)/VARCHAR(max) (Yukon or later) or IMAGE/TEXT (Shiloh) */ final static int SHORT_VARTYPE_MAX_BYTES = 8000; /** - * A type with unlimited max size, known as varchar(max), varbinary(max) and nvarchar(max), - * which has a max size of 0xFFFF, defined by PARTLENTYPE. + * A type with unlimited max size, known as varchar(max), varbinary(max) and nvarchar(max), which has a max size of + * 0xFFFF, defined by PARTLENTYPE. */ final static int SQL_USHORTVARMAXLEN = 65535; // 0xFFFF @@ -1116,14 +1115,11 @@ static final void throwConversionError(String fromType, String toType) throws SQ * From SQL Server 2005 Books Online : ntext, text, and image (Transact-SQL) * http://msdn.microsoft.com/en-us/library/ms187993.aspx * - * image - * "... through 2^31 - 1 (2,147,483,687) bytes." + * image "... through 2^31 - 1 (2,147,483,687) bytes." * - * text - * "... maximum length of 2^31 - 1 (2,147,483,687) characters." + * text "... maximum length of 2^31 - 1 (2,147,483,687) characters." * - * ntext - * "... maximum length of 2^30 - 1 (1,073,741,823) characters." + * ntext "... maximum length of 2^30 - 1 (1,073,741,823) characters." */ final static int NTEXT_MAX_CHARS = 0x3FFFFFFF; final static int IMAGE_TEXT_MAX_BYTES = 0x7FFFFFFF; @@ -1131,22 +1127,18 @@ static final void throwConversionError(String fromType, String toType) throws SQ /** * Transact-SQL Data Types: http://msdn.microsoft.com/en-us/library/ms179910.aspx * - * varbinary(max) - * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual + * varbinary(max) "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual * length of the data entered + 2 bytes." * - * varchar(max) - * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual + * varchar(max) "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size is the actual * length of the data entered + 2 bytes." * - * nvarchar(max) - * "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size, in bytes, - * is two times the number of characters entered + 2 bytes." - - * Normally, that would mean that the maximum length of nvarchar(max) data is 0x3FFFFFFE characters - * and that the maximum length of varchar(max) or varbinary(max) data is 0x3FFFFFFD bytes. However... - * Despite the documentation, SQL Server returns 2^30 - 1 and 2^31 - 1 respectively as the PRECISION - * of these types, so use that instead. + * nvarchar(max) "max indicates that the maximum storage size is 2^31 - 1 bytes. The storage size, in bytes, is two + * times the number of characters entered + 2 bytes." + * + * Normally, that would mean that the maximum length of nvarchar(max) data is 0x3FFFFFFE characters and that the + * maximum length of varchar(max) or varbinary(max) data is 0x3FFFFFFD bytes. However... Despite the documentation, + * SQL Server returns 2^30 - 1 and 2^31 - 1 respectively as the PRECISION of these types, so use that instead. */ final static int MAX_VARTYPE_MAX_CHARS = 0x3FFFFFFF; final static int MAX_VARTYPE_MAX_BYTES = 0x7FFFFFFF; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java index 020055c809..1f347cac99 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java @@ -9,8 +9,8 @@ /** - * Provides an interface used to create classes that read in data from any source (such as a file) - * and allows a SQLServerBulkCopy class to write the data to SQL Server tables. + * Provides an interface used to create classes that read in data from any source (such as a file) and allows a + * SQLServerBulkCopy class to write the data to SQL Server tables. * * This interface is implemented by {@link SQLServerBulkCommon} Class */ @@ -162,7 +162,7 @@ public void addColumnMetadata(int positionInFile, String name, int jdbcType, int public void setTimeWithTimezoneFormat(DateTimeFormatter dateTimeFormatter); /** - * Returns the dateTimeFormatter for the given column + * Returns the dateTimeFormatter for the given column. * * @param column * Column ordinal diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java index 3e10537c2f..da7d75fde5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java @@ -12,7 +12,7 @@ /** - * Provides an interface to the {@link SQLServerCallableStatement} class + * Provides an interface to the {@link SQLServerCallableStatement} class. */ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, ISQLServerPreparedStatement { @@ -127,7 +127,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public Timestamp getSmallDateTime(String name, Calendar cal) throws SQLServerException; /** - * Returns the DateTimeOffset value of parameter with index parameterIndex + * Returns the DateTimeOffset value of parameter with index parameterIndex. * * @param parameterIndex * the first parameter is 1, the second is 2, and so on @@ -139,7 +139,7 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement, public microsoft.sql.DateTimeOffset getDateTimeOffset(int parameterIndex) throws SQLServerException; /** - * Returns the DateTimeOffset value of parameter with name parameterName + * Returns the DateTimeOffset value of parameter with name parameterName. * * @param parameterName * the name of the parameter @@ -478,7 +478,7 @@ public void setTimestamp(String parameterName, java.sql.Timestamp value, int sca boolean forceEncrypt) throws SQLServerException; /** - * Sets parameter parameterName to DateTimeOffset x + * Sets parameter parameterName to DateTimeOffset value. * * @param parameterName * the name of the parameter @@ -490,7 +490,7 @@ public void setTimestamp(String parameterName, java.sql.Timestamp value, int sca public void setDateTimeOffset(String parameterName, microsoft.sql.DateTimeOffset value) throws SQLServerException; /** - * Sets parameter parameterName to DateTimeOffset x + * Sets parameter parameterName to DateTimeOffset value. * * @param parameterName * the name of the parameter @@ -505,7 +505,7 @@ public void setDateTimeOffset(String parameterName, microsoft.sql.DateTimeOffset int scale) throws SQLServerException; /** - * Sets parameter parameterName to DateTimeOffset x + * Sets parameter parameterName to DateTimeOffset value. * * @param parameterName * the name of the parameter diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java index 125ba8d2c8..44d9917824 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java @@ -215,8 +215,8 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException; /** - * Sets the value 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 + * Sets the value 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. * @@ -232,7 +232,7 @@ public CallableStatement prepareCall(String sql, int nType, int nConcur, int nHo public void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue) throws SQLServerException; /** - * Returns the value of the sendTimeAsDatetime property. + * Returns the value of the sendTimeAsDatetime property. * * @return boolean value of sendTimeAsDatetime * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java index 54a14c2cb0..7c45b84491 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataRecord.java @@ -6,12 +6,12 @@ package com.microsoft.sqlserver.jdbc; /** - * Provides an interface 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. + * Provides an interface to create classes that read in data from any source (such as a file) and allow a structured + * type to be sent to SQL Server tables. */ public interface ISQLServerDataRecord { /** - * Returns the column meta data + * Returns the column meta data. * * @param column * the first column is 1, the second is 2, and so on diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java index 8d93f20fa2..9e02e154c5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java @@ -9,8 +9,8 @@ /** - * Provides a factory to create connections to the data source represented by this object. This interface was added in SQL Server - * JDBC Driver 3.0. + * Provides a factory to create connections to the data source represented by this object. This interface was added in + * SQL Server JDBC Driver 3.0. * * This interface is implemented by {@link SQLServerDataSource} Class. */ @@ -117,13 +117,12 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public boolean getEncrypt(); /** - * Sets the value to enable/disable Transparent Netowrk IP Resolution (TNIR) - * 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. + * Sets the value to enable/disable Transparent Netowrk IP Resolution (TNIR) 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 *

@@ -168,7 +167,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTrustStoreType(String trustStoreType); /** - * Returns the keyStore Type for the trustStore + * Returns the keyStore Type for the trustStore. * * @return trustStoreType A String that contains the trust store type */ @@ -295,9 +294,8 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSendTimeAsDatetime(boolean sendTimeAsDatetime); /** - * Returns the value of the sendTimeAsDatetime connection property. - * This method was added in SQL Server JDBC Driver 3.0. Returns the setting of the sendTimeAsDatetime connection - * property. + * Returns the value of the sendTimeAsDatetime connection property. 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. @@ -313,14 +311,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode); /** - * Returns whether string parameters to the server in UNICODE format is enabled. + * Returns whether 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 whether the serverName will be translated from Unicode to ASCII Compatible Encoding (ACE) + * Sets whether the serverName will be translated from Unicode to ASCII Compatible Encoding (ACE). * * @param serverNameAsACE * if enabled the servername will be translated to ASCII Compatible Encoding (ACE) @@ -328,7 +326,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setServerNameAsACE(boolean serverNameAsACE); /** - * Returns if the serverName should be translated from Unicode to ASCII Compatible Encoding (ACE) + * Returns if the serverName should be translated from Unicode to ASCII Compatible Encoding (ACE). * * @return if enabled, will return true. Otherwise, false. */ @@ -478,7 +476,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setAuthenticationScheme(String authenticationScheme); /** - * Sets the authentication mode + * Sets the authentication mode. * * @param authentication * the authentication mode @@ -486,14 +484,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setAuthentication(String authentication); /** - * Returns the authentication mode + * Returns the authentication mode. * * @return the authentication value */ public String getAuthentication(); /** - * Sets the server spn + * Sets the server spn. * * @param serverSpn * A String that contains the server spn @@ -501,14 +499,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setServerSpn(String serverSpn); /** - * Returns the server spn + * Returns the server spn. * * @return A String that contains the server spn */ public String getServerSpn(); /** - * Sets GSSCredential + * Sets the GSSCredential. * * @param userCredential * the credential @@ -516,7 +514,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setGSSCredentials(GSSCredential userCredential); /** - * Returns the GSSCredential + * Returns the GSSCredential. * * @return GSSCredential */ @@ -538,7 +536,8 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getAccessToken(); /** - * Sets the value to enable/disable Always Encrypted functionality for the data source object. The default is Disabled. + * Sets the value to enable/disable 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. @@ -594,7 +593,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getKeyStoreLocation(); /** - * Setting the query timeout + * Setting the query timeout. * * @param queryTimeout * The number of seconds to wait before a timeout has occurred on a query. The default value is 0, which @@ -603,14 +602,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setQueryTimeout(int queryTimeout); /** - * Returns the query timeout + * Returns the query timeout. * * @return The number of seconds to wait before a timeout has occurred on a query. */ public int getQueryTimeout(); /** - * Setting the cancel timeout + * Sets the cancel timeout. * * @param cancelQueryTimeout * The number of seconds to wait before we wait for the query timeout to happen. @@ -618,7 +617,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setCancelQueryTimeout(int cancelQueryTimeout); /** - * Returns the cancel timeout + * Returns the cancel timeout. * * @return the number of seconds to wait before we wait for the query timeout to happen. */ @@ -626,11 +625,10 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { /** * Sets the value that enables/disables whether the first execution of a prepared statement will call sp_executesql - * and not prepare a statement. - * If this configuration is false the first execution of a prepared statement will call sp_executesql and not - * prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared - * statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared - * statement close if the statement is only executed once. + * and not prepare a statement. If this configuration is false the first execution of a prepared statement will call + * sp_executesql and not prepare a statement, once the second execution happens it will call sp_prepexec and + * actually setup a prepared statement handle. Following executions will call sp_execute. This relieves the need for + * sp_unprepare on prepared statement close if the statement is only executed once. * * @param enablePrepareOnFirstPreparedStatementCall * Changes the setting per the description. @@ -638,22 +636,21 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setEnablePrepareOnFirstPreparedStatementCall(boolean enablePrepareOnFirstPreparedStatementCall); /** - * Returns the value that indicates whether the first execution of a prepared statement will call sp_executesql - * and not prepare a statement. - * If this configuration returns false the first execution of a prepared statement will call sp_executesql and not - * prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared - * statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared - * statement close if the statement is only executed once. + * Returns the value that indicates whether the first execution of a prepared statement will call sp_executesql and + * not prepare a statement. If this configuration returns false the first execution of a prepared statement will + * call sp_executesql and not prepare a statement, once the second execution happens it will call sp_prepexec and + * actually setup a prepared statement handle. Following executions will call sp_execute. This relieves the need for + * sp_unprepare on prepared statement close if the statement is only executed once. * * @return Returns the current setting per the description. */ public boolean getEnablePrepareOnFirstPreparedStatementCall(); /** - * Sets the value that setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding - * per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is - * {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to - * {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too often. + * Sets the value that controls how many outstanding prepared statement discard actions (sp_unprepare) can be + * outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the + * setting is {@literal <=} 1 unprepare actions will be executed immedietely on prepared statement close. If it is + * set to {@literal >} 1 these calls will be batched together to avoid overhead of calling sp_unprepare too often. * * @param serverPreparedStatementDiscardThreshold * Changes the setting per the description. @@ -661,8 +658,9 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setServerPreparedStatementDiscardThreshold(int serverPreparedStatementDiscardThreshold); /** - * Returns the value of the setting that controls how many outstanding prepared statement discard actions (sp_unprepare) - * can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. + * Returns the value of the setting that controls how many outstanding prepared statement discard actions + * (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server + * is executed. * * @return Returns the current setting per the description. */ @@ -692,14 +690,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setDisableStatementPooling(boolean disableStatementPooling); /** - * Return whether statement pooling is disabled. + * Returns whether statement pooling is disabled. * * @return true if statement pooling is disabled, false if it is enabled. */ public boolean getDisableStatementPooling(); /** - * Sets the socket timeout + * Sets the socket timeout value. * * @param socketTimeout * The number of milliseconds to wait before a timeout is occurred on a socket read or accept. The default @@ -708,7 +706,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSocketTimeout(int socketTimeout); /** - * Returns the socket timeout + * Returns the socket timeout value. * * @return The number of milliseconds to wait before a timeout is occurred on a socket read or accept. */ @@ -731,7 +729,8 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public String getJASSConfigurationName(); /** - * Sets Fips Mode on the connection For FIPS enabled JVM this property should be true. + * Sets whether Fips Mode should be enabled/disabled on the connection. For FIPS enabled JVM this property should be + * true. * * @param fips * Boolean property to enable/disable fips @@ -739,7 +738,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setFIPS(boolean fips); /** - * Returns the value of connection property "fips" For FIPS enabled JVM this property should be true. + * Returns the value of connection property "fips". For FIPS enabled JVM this property should be true. * * @return fips boolean value */ @@ -756,14 +755,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setSSLProtocol(String sslProtocol); /** - * Returns the value of connection property 'sslProtocol' + * Returns the value of connection property 'sslProtocol'. * * @return sslProtocol property value */ public String getSSLProtocol(); /** - * Sets the connection property 'trustManagerClass' on the connection + * Sets the connection property 'trustManagerClass' on the connection. * * @param trustManagerClass * The fully qualified class name of a custom javax.net.ssl.TrustManager. @@ -771,14 +770,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTrustManagerClass(String trustManagerClass); /** - * Returns the value for the connection property 'trustManagerClass' + * Returns the value for the connection property 'trustManagerClass'. * * @return trustManagerClass property value */ public String getTrustManagerClass(); /** - * Sets Constructor Arguments to be provided on constructor of 'trustManagerClass' + * Sets Constructor Arguments to be provided on constructor of 'trustManagerClass'. * * @param trustManagerConstructorArg * 'trustManagerClass' constructor arguments @@ -786,21 +785,21 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource { public void setTrustManagerConstructorArg(String trustManagerConstructorArg); /** - * Returns the value for the connection property 'trustManagerConstructorArg' + * Returns the value for the connection property 'trustManagerConstructorArg'. * * @return trustManagerConstructorArg property value */ public String getTrustManagerConstructorArg(); /** - * Returns whether the use Bulk Copy API is used for Batch Insert + * Returns whether the use Bulk Copy API is used for Batch Insert. * * @return whether the driver should use Bulk Copy API for Batch Insert operations. */ public boolean getUseBulkCopyForBatchInsert(); /** - * Sets whether the use Bulk Copy API should be used for Batch Insert + * Sets whether the use Bulk Copy API should be used for Batch Insert. * * @param useBulkCopyForBatchInsert * indicates whether Bulk Copy API should be used for Batch Insert operations. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java index 712f2a8141..187d20821a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerPreparedStatement.java @@ -488,7 +488,7 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, Integer p public void setNString(int parameterIndex, String value, boolean forceEncrypt) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Time value + * Sets the designated parameter to the given java.sql.Time value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -502,7 +502,7 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, Integer p public void setTime(int parameterIndex, java.sql.Time x, int scale) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Time value + * Sets the designated parameter to the given java.sql.Time value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -520,7 +520,7 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, Integer p public void setTime(int parameterIndex, java.sql.Time x, int scale, boolean forceEncrypt) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -534,7 +534,7 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, Integer p public void setTimestamp(int parameterIndex, java.sql.Timestamp x, int scale) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -553,7 +553,7 @@ public void setTimestamp(int parameterIndex, java.sql.Timestamp x, int scale, boolean forceEncrypt) throws SQLServerException; /** - * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value + * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -568,7 +568,7 @@ public void setDateTimeOffset(int parameterIndex, microsoft.sql.DateTimeOffset x int scale) throws SQLServerException; /** - * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value + * Sets the designated parameter to the given microsoft.sql.DatetimeOffset value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -587,7 +587,7 @@ public void setDateTimeOffset(int parameterIndex, microsoft.sql.DateTimeOffset x boolean forceEncrypt) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -599,7 +599,7 @@ public void setDateTimeOffset(int parameterIndex, microsoft.sql.DateTimeOffset x public void setDateTime(int parameterIndex, java.sql.Timestamp x) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -615,7 +615,7 @@ public void setDateTimeOffset(int parameterIndex, microsoft.sql.DateTimeOffset x public void setDateTime(int parameterIndex, java.sql.Timestamp x, boolean forceEncrypt) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -627,7 +627,7 @@ public void setDateTimeOffset(int parameterIndex, microsoft.sql.DateTimeOffset x public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x) throws SQLServerException; /** - * Sets the designated parameter to the given java.sql.Timestamp value + * Sets the designated parameter to the given java.sql.Timestamp value. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -644,7 +644,7 @@ public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x, boolean forceEncrypt) throws SQLServerException; /** - * Sets the data table to populates a table valued parameter + * Sets the data table to populates a table valued parameter. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -655,10 +655,11 @@ public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x, * @throws SQLServerException * when an error occurs */ - public void setStructured(int parameterIndex, String tvpName, SQLServerDataTable tvpDataTable) throws SQLServerException; + public void setStructured(int parameterIndex, String tvpName, + SQLServerDataTable tvpDataTable) throws SQLServerException; /** - * Sets the result set to populate a table valued parameter + * Sets the result set to populate a table-valued parameter. * * @param parameterIndex * the first parameter is 1, the second is 2, ... @@ -672,7 +673,7 @@ public void setSmallDateTime(int parameterIndex, java.sql.Timestamp x, public void setStructured(int parameterIndex, String tvpName, ResultSet tvpResultSet) throws SQLServerException; /** - * Sets the server bulk record to populate a table valued parameter + * Sets the server bulk record to populate a table valued parameter. * * @param parameterIndex * the first parameter is 1, the second is 2, ... diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java index 33b1484c93..2ac7bc1b59 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSet.java @@ -77,8 +77,8 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public Geography getGeography(String columnName) throws SQLServerException; /** - * Returns the value of the designated column in the current row of this ResultSet object as a String object in - * the Java programming language. + * Returns the value of the designated column in the current row of this ResultSet object as a String object in the + * Java programming language. * * @param columnIndex * the first column is 1, the second is 2, ... @@ -89,8 +89,8 @@ public interface ISQLServerResultSet extends java.sql.ResultSet { public String getUniqueIdentifier(int columnIndex) throws SQLServerException; /** - * Returns the value of the designated column in the current row of this ResultSet object as a String object in - * the Java programming language. + * Returns the value of the designated column in the current row of this ResultSet object as a String object in the + * Java programming language. * * @param columnLabel * the name of the column @@ -355,7 +355,7 @@ public void updateObject(int index, Object obj, SQLType targetSqlType, int scale * must contain the number of bytes specified by scaleOrLength. If the second argument is a Reader then the reader * must contain the number of characters specified by scaleOrLength. If these conditions are not true the driver * will generate a SQLServerException when the statement is executed. The default implementation will throw - * SQLFeatureNotSupportedException + * SQLFeatureNotSupportedException. * * @param columnName * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then @@ -1566,7 +1566,7 @@ public void updateObject(String columnName, Object x, int precision, int scale, /** * Returns the Data Classification information for the current ResultSet For SQL Servers that do not support Data - * Classification or results that do not fetch any classified columns, this data can be null + * Classification or results that do not fetch any classified columns, this data can be null. * * @return SensitivityClassification */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java index 5eb3ec836e..32788d998d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerResultSetMetaData.java @@ -14,7 +14,7 @@ public interface ISQLServerResultSetMetaData extends ResultSetMetaData { /** - * Returns if the column is a SQLServer SparseColumnSet + * Returns if the column is a SQLServer SparseColumnSet. * * @param column * The column number diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java index 426800a12f..51797677b2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerStatement.java @@ -47,8 +47,8 @@ public interface ISQLServerStatement extends java.sql.Statement { public int getCancelQueryTimeout() throws SQLServerException; /** - * Sets the cancelQueryTimeout property on this SQLServerStatement object to cancel queryTimeout set on - * Connection or Statement level. + * Sets the cancelQueryTimeout property on this SQLServerStatement object to cancel + * queryTimeout set on Connection or Statement level. * * @param seconds * Time duration in seconds. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java index 3431e8dc01..2166154478 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/InternalSpatialDatatype.java @@ -6,9 +6,7 @@ package com.microsoft.sqlserver.jdbc; /** - * * Specifies the spatial data types values - * */ public enum InternalSpatialDatatype { POINT((byte) 1, "POINT"), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java index 119f74f148..4546885912 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbCallback.java @@ -15,6 +15,7 @@ import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; + /** * Provides implemention of the callback handler for Kerberos. */ @@ -40,7 +41,7 @@ private static String getAnyOf(Callback callback, Properties properties, } /** - * If a name was retrieved By Kerberos, return it. + * Returns if a name was retrieved By Kerberos. * * @return null if callback was not called or username was not provided */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java index 0e53e1308b..3203f07f10 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java @@ -21,8 +21,8 @@ /** - * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types - * from an ArrayList of Parameters that were provided by pstmt/cstmt. + * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java + * data types from an ArrayList of Parameters that were provided by pstmt/cstmt. */ public class SQLServerBulkBatchInsertRecord extends SQLServerBulkCommon { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java index 3d60438a8e..ac84bc58d2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java @@ -25,8 +25,8 @@ /** - * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java data types - * from a delimited file where each line represents a row of data. + * Provides a simple implementation of the ISQLServerBulkRecord interface that can be used to read in the basic Java + * data types from a delimited file where each line represents a row of data. */ public class SQLServerBulkCSVFileRecord extends SQLServerBulkCommon implements java.lang.AutoCloseable { /* @@ -57,7 +57,7 @@ public class SQLServerBulkCSVFileRecord extends SQLServerBulkCommon implements j private static final java.util.logging.Logger loggerExternal = java.util.logging.Logger.getLogger(loggerClassName); /** - * Contructs a simple reader to parse data from a delimited file with the given encoding. + * Constructs a simple reader to parse data from a delimited file with the given encoding. * * @param fileToParse * File to parse data from diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index 793635e234..e4ba97c180 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -62,12 +62,12 @@ */ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Serializable { /** - * + * Update serialVersionUID when making changes to this file */ private static final long serialVersionUID = 1989903904654306244L; - /* - * Class to represent the column mappings between the source and destination table + /** + * Represents the column mappings between the source and destination table */ private class ColumnMapping { String sourceColumnName = null; @@ -130,11 +130,11 @@ private class ColumnMapping { /** * Name of destination table on server. If destinationTable has not been set when WriteToServer is called, an - * Exception is thrown. destinationTable is a three-part name (..). You can qualify - * the table name with its database and owning schema if you choose. However, if the table name uses an underscore - * ("_") or any other special characters, you must escape the name using surrounding brackets. For more information, - * see "Identifiers" in SQL Server Books Online. You can bulk-copy data to a temporary table by using a value such - * as tempdb..#table or tempdb..#table for the destinationTable property. + * Exception is thrown. destinationTable is a three-part name {@code (..)}. You can + * qualify the table name with its database and owning schema if you choose. However, if the table name uses an + * underscore ("_") or any other special characters, you must escape the name using surrounding brackets. For more + * information, see "Identifiers" in SQL Server Books Online. You can bulk-copy data to a temporary table by using a + * value such as {@code tempdb..#table or tempdb..#table} for the destinationTable property. */ private String destinationTableName; @@ -1707,7 +1707,7 @@ private void validateStringBinaryLengths(Object colValue, int srcCol, int destCo } } - /* + /** * Returns the column metadata for the destination table (and saves it for later) */ private void getDestinationMetadata() throws SQLServerException { @@ -3016,8 +3016,7 @@ else if (null != sourceBulkRecord && (null == destCryptoMeta)) { } /** - * this method is called against jdbc41, but it require jdbc42 to work - * therefore, we will throw exception. + * this method is called against jdbc41, but it require jdbc42 to work therefore, we will throw exception. */ protected Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed, int srcJdbcType, int srcColOrdinal, DateTimeFormatter dateTimeFormatter) throws SQLServerException { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java index 081cf10b2d..67f76277bd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopyOptions.java @@ -37,7 +37,7 @@ public class SQLServerBulkCopyOptions { private int bulkCopyTimeout; /** - * Check constraints while data is being inserted. + * Checks constraints while data is being inserted. * * Default: false - constraints are not checked */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java index 6b52be79b6..b59fd90628 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java @@ -43,7 +43,7 @@ public class SQLServerClob extends SQLServerClobBase implements Clob { private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerClob"); /** - * Constructs a SQLServerClob + * Constructs a SQLServerClob. * * @param connection * the database connection this blob is implemented on @@ -160,13 +160,11 @@ abstract class SQLServerClobBase extends SQLServerLob implements Serializable { private final TypeInfo typeInfo; - // Active streams which must be closed when the Clob/NClob is closed - // - // Initial size of the array is based on an assumption that a Clob/NClob - // object is - // typically used either for input or output, and then only once. The array - // size - // grows automatically if multiple streams are used. + /** + * Active streams which must be closed when the Clob/NClob is closed. Initial size of the array is based on an + * assumption that a Clob/NClob object is typically used either for input or output, and then only once. The array + * size grows automatically if multiple streams are used. + */ private ArrayList activeStreams = new ArrayList<>(1); transient SQLServerConnection con; @@ -197,7 +195,7 @@ private String getDisplayClassName() { } /** - * Create a new CLOB from a String + * Constructs a new CLOB from a String. * * @param connection * SQLServerConnection @@ -271,7 +269,7 @@ private void checkClosed() throws SQLServerException { } /** - * Materialize the CLOB as an ASCII stream. + * Returns the CLOB as an ASCII stream. * * @throws SQLException * when an error occurs @@ -291,8 +289,7 @@ public InputStream getAsciiStream() throws SQLException { } /** - * Returns the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of - * characters). + * Returns the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of characters). * * @throws SQLException * if there is an error accessing the CLOB value @@ -330,8 +327,8 @@ public Reader getCharacterStream(long pos, long length) throws SQLException { } /** - * Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring - * begins at position pos and has up to length consecutive characters. + * Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring begins + * at position pos and has up to length consecutive characters. * * @param pos * - the first character of the substring to be extracted. The first character is at position 1. @@ -392,7 +389,7 @@ public long length() throws SQLException { } /** - * Function for the result set to maintain clobs it has created + * Provides functionality for the result set to maintain clobs it has created. * * @throws SQLException */ @@ -403,7 +400,7 @@ void fillFromStream() throws SQLException { } /** - * Converts the stream to String + * Converts the stream to String. * * @throws SQLServerException */ @@ -667,16 +664,11 @@ public int setString(long pos, String str, int offset, int len) throws SQLExcept } -// SQLServerClobWriter is a simple java.io.Writer interface implementing class -// that -// forwards all calls to SQLServerClob.setString. This class is returned to -// caller by -// SQLServerClob class when setCharacterStream is called. -// -// SQLServerClobWriter starts writing at postion streamPos and continues to -// write -// in a forward only manner. There is no reset with java.io.Writer. -// +/** + * Provides a simple java.io.Writer interface that forwards all calls to SQLServerClob.setString.\ This class is + * returned to caller by SQLServerClob class when setCharacterStream is called. SQLServerClobWriter starts writing at + * postion streamPos and continues to write in a forward only manner. There is no reset with java.io.Writer. + */ final class SQLServerClobWriter extends java.io.Writer { private SQLServerClobBase parentClob = null; private long streamPos; @@ -739,16 +731,11 @@ private void checkClosed() throws IOException { } -// SQLServerClobAsciiOutputStream is a simple java.io.OutputStream interface -// implementing class that -// forwards all calls to SQLServerClob.setString. This class is returned to -// caller by -// SQLServerClob class when setAsciiStream is called. -// -// SQLServerClobAsciiOutputStream starts writing at character postion streamPos -// and continues to write -// in a forward only manner. Reset/mark are not supported. -// +/** + * Provides a simple java.io.OutputStream interface that forwards all calls to SQLServerClob.setString. This class is + * returned to caller by SQLServerClob class when setAsciiStream is called. SQLServerClobAsciiOutputStream starts + * writing at character postion streamPos and continues to write in a forward only manner. Reset/mark are not supported. + */ final class SQLServerClobAsciiOutputStream extends java.io.OutputStream { private SQLServerClobBase parentClob = null; private long streamPos; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index 03b38f5141..5b3e25eaba 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -72,8 +72,8 @@ public String getName() { } /** - * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD and an executor service.. - * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD and + * an executor service.. This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * This constructor is present to maintain backwards compatibility with 6.0 version of the driver. Deprecated for * removal in next stable release. @@ -94,8 +94,8 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider( } /** - * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD. - * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a callback function to authenticate to AAD. This + * is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * @param authenticationCallback * - Callback function used for authenticating to AAD. @@ -117,8 +117,8 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider( } /** - * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a client id and client key to authenticate to AAD. - * This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. + * Constructs a SQLServerColumnEncryptionAzureKeyVaultProvider with a client id and client key to authenticate to + * AAD. This is used by KeyVaultClient at runtime to authenticate to Azure Key Vault. * * @param clientId * Identifier of the client requesting the token. @@ -269,7 +269,7 @@ private short convertTwoBytesToShort(byte[] input, int index) throws SQLServerEx } /** - * Encrypts CEK with RSA encryption algorithm using the asymmetric key specified by the key path + * Encrypts CEK with RSA encryption algorithm using the asymmetric key specified by the key path. * * @param masterKeyPath * - Complete path of an asymmetric key in AKV @@ -397,7 +397,7 @@ public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryption } /** - * This function validates that the encryption algorithm is RSA_OAEP and if it is not, then throws an exception + * Validates that the encryption algorithm is RSA_OAEP and if it is not, then throws an exception. * * @param encryptionAlgorithm * - Asymmetric key encryptio algorithm @@ -459,7 +459,7 @@ private void ValidateNonEmptyAKVPath(String masterKeyPath) throws SQLServerExcep } /** - * Encrypt the text using specified Azure Key Vault key. + * Encrypts the text using specified Azure Key Vault key. * * @param masterKeyPath * - Azure Key Vault key url. @@ -484,7 +484,7 @@ private byte[] AzureKeyVaultWrap(String masterKeyPath, String encryptionAlgorith } /** - * Encrypt the text using specified Azure Key Vault key. + * Encrypts the text using specified Azure Key Vault key. * * @param masterKeyPath * - Azure Key Vault key url. @@ -553,7 +553,7 @@ private boolean AzureKeyVaultVerifySignature(byte[] dataToVerify, byte[] signatu } /** - * Returns the public Key size in bytes + * Returns the public Key size in bytes. * * @param masterKeyPath * - Azure Key Vault Key path diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index 7f873e56ea..1f87ecbe08 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -25,8 +25,8 @@ /** - * Provides 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. + * Provides 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 { @@ -51,7 +51,7 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL private Path keyStoreDirectoryPath = null; /** - * Constructs a SQLServerColumnEncryptionCertificateStoreProvider + * Constructs a SQLServerColumnEncryptionCertificateStoreProvider. */ public SQLServerColumnEncryptionCertificateStoreProvider() { windowsCertificateStoreLogger.entering(SQLServerColumnEncryptionCertificateStoreProvider.class.getName(), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index bf825a7e4e..cd0a2f7552 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -33,8 +33,8 @@ /** * - * Provides 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. + * Provides 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 { @@ -264,7 +264,7 @@ public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryption } /** - * Encrypt plainText with the certificate provided + * Encrypt. plainText with the certificate provided. * * @param plainText * plain CEK to be encrypted diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java index c670139431..6fd8b845f1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionKeyStoreProvider.java @@ -7,8 +7,8 @@ /** * - * Defines the abtract class for a SQL Server Column Encryption key store provider - * Extend this class to implement a custom key store provider. + * Defines the abtract class for a SQL Server Column Encryption key store provider Extend this class to implement a + * custom key store provider. * */ public abstract class SQLServerColumnEncryptionKeyStoreProvider { @@ -22,16 +22,15 @@ public abstract class SQLServerColumnEncryptionKeyStoreProvider { public abstract void setName(String name); /** - * Retrieves the name of this key store provider. + * Returns 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. + * Decrypts 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. @@ -47,8 +46,8 @@ public abstract byte[] decryptColumnEncryptionKey(String masterKeyPath, String e 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. + * Encrypts 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 8e51c929fc..5495ab9ba4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -52,8 +52,9 @@ /** - * Provides implementation a JDBC connection to SQL Server. SQLServerConnections support JDBC connection pooling - * and may be either physical JDBC connections or logical JDBC connections. + * Provides an implementation java.sql.connection interface that assists creating 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. @@ -72,12 +73,11 @@ *

* 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. + * + * NOTE: All the public functions in this class also need to be defined in SQLServerConnectionPoolProxy Declare all new + * custom (non-static) Public APIs in ISQLServerConnection interface such that they can also be implemented by + * SQLServerConnectionPoolProxy */ - -// NOTE: All the public functions in this class also need to be defined in SQLServerConnectionPoolProxy -// Declare all new custom (non-static) Public APIs in ISQLServerConnection interface such that they can also be -// implemented by -// SQLServerConnectionPoolProxy public class SQLServerConnection implements ISQLServerConnection, java.io.Serializable { /** @@ -99,17 +99,12 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial /** * The default for if prepared statements should execute sp_executesql before following the prepare, unprepare * pattern. + * + * Used to set the initial default, can be changed later. false == use sp_executesql -> sp_prepexec -> sp_execute -> + * batched -> sp_unprepare pattern, true == skip sp_executesql part of pattern. */ - static final boolean DEFAULT_ENABLE_PREPARE_ON_FIRST_PREPARED_STATEMENT_CALL = false; // Used to set the initial - // default, can be changed - // later. - // false == use sp_executesql - // -> sp_prepexec -> - // sp_execute - // -> batched -> sp_unprepare - // pattern, true == skip - // sp_executesql part of - // pattern. + static final boolean DEFAULT_ENABLE_PREPARE_ON_FIRST_PREPARED_STATEMENT_CALL = false; + private Boolean enablePrepareOnFirstPreparedStatementCall = null; // Current limit for this particular connection. // Handle the actual queue of discarded prepared statements. @@ -174,7 +169,7 @@ public int hashCode() { } /** - * Used to keep track of an individual prepared statement handle. + * Keeps track of an individual prepared statement handle. */ class PreparedStatementHandle { private int handle = 0; @@ -229,7 +224,7 @@ boolean isDirectSql() { } /** - * Make sure handle cannot be re-used. + * Makes sure handle cannot be re-used. * * @return false: Handle could not be discarded, it is in use. true: Handle was successfully put on path for * discarding. @@ -275,12 +270,12 @@ void removeReference() { .maximumWeightedCapacity(PARSED_SQL_CACHE_SIZE).build(); } - /** Get prepared statement cache entry if exists, if not parse and create a new one */ + /** Returns prepared statement cache entry if exists, if not parse and create a new one */ static ParsedSQLCacheItem getCachedParsedSQL(CityHash128Key key) { return parsedSQLCache.get(key); } - /** Parse and create a information about parsed SQL text */ + /** Parses and create a information about parsed SQL text */ static ParsedSQLCacheItem parseAndCacheSQL(CityHash128Key key, String sql) throws SQLServerException { JDBCSyntaxTranslator translator = new JDBCSyntaxTranslator(); @@ -311,7 +306,7 @@ static ParsedSQLCacheItem parseAndCacheSQL(CityHash128Key key, String sql) throw private boolean disableStatementPooling = true; /** - * Locate statement parameters. + * Locates statement parameters. * * @param sql * SQL text to parse for positions of parameters to intialize. @@ -334,7 +329,7 @@ SqlFedAuthToken getAuthenticationResult() { } /** - * Struct encapsulating the data to be sent to the server as part of Federated Authentication Feature Extension. + * Eencapsulates the data to be sent to the server as part of Federated Authentication Feature Extension. */ class FederatedAuthenticationFeatureExtensionData { boolean fedAuthRequiredPreLoginResponse; @@ -391,7 +386,7 @@ class ActiveDirectoryAuthentication { } /** - * denotes the state of the SqlServerConnection + * Denotes the state of the SqlServerConnection. */ private enum State { Initialized, // default value on calling SQLServerConnection constructor @@ -490,12 +485,12 @@ final int getQueryTimeoutSeconds() { } /** - * timeout value for canceling the query timeout + * Timeout value for canceling the query timeout. */ private int cancelQueryTimeoutSeconds; /** - * Returns the cancelTimeout in seconds + * Returns the cancelTimeout in seconds. * * @return */ @@ -510,7 +505,7 @@ final int getSocketTimeoutMilliseconds() { } /** - * boolean value for deciding if the driver should use bulk copy API for batch inserts + * boolean value for deciding if the driver should use bulk copy API for batch inserts. */ private boolean useBulkCopyForBatchInsert; @@ -1001,9 +996,9 @@ final void setAssociatedProxy(SQLServerConnectionPoolProxy proxy) { } /* - * This function is used by the functions that return a connection object to outside world. E.g. stmt.getConnection, - * these functions should return the proxy not the actual physical connection when the physical connection is pooled - * and the user should be accessing the connection functions via the proxy object. + * Provides functionality to return a connection object to outside world. E.g. stmt.getConnection, these functions + * should return the proxy not the actual physical connection when the physical connection is pooled and the user + * should be accessing the connection functions via the proxy object. */ final Connection getConnection() { if (null != proxy) @@ -1018,7 +1013,7 @@ final void resetPooledConnection() { } /** - * Generate the next unique connection id. + * Generates the next unique connection id. * * @return the next conn id */ @@ -1035,7 +1030,7 @@ String getClassNameLogging() { } /** - * This is a helper function to provide an ID string suitable for tracing. + * Provides a helper function to return an ID string suitable for tracing. */ @Override public String toString() { @@ -1046,7 +1041,7 @@ public String toString() { } /** - * Check if the connection is closed Create a new connection if it's a fedauth connection and the access token is + * Checks if the connection is closed Create a new connection if it's a fedauth connection and the access token is * going to expire. * * @throws SQLServerException @@ -1136,13 +1131,9 @@ Connection connect(Properties propsIn, SQLServerPooledConnection pooledConnectio // We do not need to check for exceptions here, as the connection properties are already // verified during the first try. Also, we would like to do this calculation // only for the TLS 1.2 exception case. - loginTimeoutSeconds = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); // if the user - // does not - // specify a - // default - // timeout, - // default is - // 15 per spec + // if the user does not specify a default timeout, default is 15 per spec + loginTimeoutSeconds = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); + String sPropValue = propsIn.getProperty(SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString()); if (null != sPropValue && sPropValue.length() > 0) { int sPropValueInt = Integer.parseInt(sPropValue); @@ -1279,11 +1270,8 @@ Connection connectInternal(Properties propsIn, sPropValue = activeConnectionProperties.getProperty(sPropKey); ValidateMaxSQLLoginName(sPropKey, sPropValue); - int loginTimeoutSeconds = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); // if the user does - // not specify a - // default timeout, - // default is 15 per - // spec + // if the user does not specify a default timeout, default is 15 per spec + int loginTimeoutSeconds = SQLServerDriverIntProperty.LOGIN_TIMEOUT.getDefaultValue(); sPropValue = activeConnectionProperties.getProperty(SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString()); if (null != sPropValue && sPropValue.length() > 0) { try { @@ -1938,12 +1926,11 @@ else if (0 == requestedPacketSize) } - // This function is used by non failover and failover cases. Even when we make a standard connection the server can - // provide us with its - // FO partner. - // If no FO information is available a standard connection is made. - // If the server returns a failover upon connection, we shall store the FO in our cache. - // + /** + * This function is used by non failover and failover cases. Even when we make a standard connection the server can + * provide us with its FO partner. If no FO information is available a standard connection is made. If the server + * returns a failover upon connection, we shall store the FO in our cache. + */ private void login(String primary, String primaryInstanceName, int primaryPortNumber, String mirror, FailoverInfo foActual, int timeout, long timerStart) throws SQLServerException { // standardLogin would be false only for db mirroring scenarios. It would be true @@ -2409,7 +2396,7 @@ private void connectHelper(ServerPortPlaceHolder serverInfo, int timeOutsliceInM } /** - * Negotiates prelogin information with the server + * Negotiates prelogin information with the server. */ void Prelogin(String serverName, int portNumber) throws SQLServerException { // Build a TDS Pre-Login packet to send to the server. @@ -3431,15 +3418,11 @@ int writeAEFeatureRequest(boolean write, return len; } + // if false just calculates the length + int writeFedAuthFeatureRequest(boolean write, TDSWriter tdsWriter, - FederatedAuthenticationFeatureExtensionData fedAuthFeatureExtensionData) throws SQLServerException { /* - * if - * false - * just - * calculates - * the - * length - */ + FederatedAuthenticationFeatureExtensionData fedAuthFeatureExtensionData) throws SQLServerException { + assert (fedAuthFeatureExtensionData.libraryType == TDS.TDS_FEDAUTH_LIBRARY_ADAL || fedAuthFeatureExtensionData.libraryType == TDS.TDS_FEDAUTH_LIBRARY_SECURITYTOKEN); @@ -3452,10 +3435,9 @@ int writeFedAuthFeatureRequest(boolean write, TDSWriter tdsWriter, break; case TDS.TDS_FEDAUTH_LIBRARY_SECURITYTOKEN: assert null != fedAuthFeatureExtensionData.accessToken; - dataLen = 1 + 4 + fedAuthFeatureExtensionData.accessToken.length; // length of feature data = 1 byte for - // library and echo, security - // token length and sizeof(int) for - // token lengh itself + // length of feature data = 1 byte for library and echo, + // security token length and sizeof(int) for token length itself + dataLen = 1 + 4 + fedAuthFeatureExtensionData.accessToken.length; break; default: assert (false); // Unrecognized library type for fedauth feature extension request" @@ -5471,7 +5453,7 @@ protected void endRequestInternal() throws SQLException { } /** - * Replace JDBC syntax parameter markets '?' with SQL Server paramter markers @p1, @p2 etc... + * Replaces JDBC syntax parameter markets '?' with SQL Server paramter markers @p1, @p2 etc... * * @param sql * the user's SQL @@ -5515,7 +5497,7 @@ String replaceParameterMarkers(String sqlSrc, int[] paramPositions, Parameter[] } /** - * Make a SQL Server style parameter name. + * Makes a SQL Server style parameter name. * * @param nParam * the parameter number @@ -5549,11 +5531,12 @@ static int makeParamName(int nParam, char[] name, int offset) { } } - // Notify any interested parties (e.g. pooling managers) of a ConnectionEvent activity - // on the connection. Calling notifyPooledConnection with null event will place this - // connection back in the pool. Calling notifyPooledConnection with a non-null event is - // used to notify the pooling manager that the connection is bad and should be removed - // from the pool. + /** + * Notify any interested parties (e.g. pooling managers) of a ConnectionEvent activity on the connection. Calling + * notifyPooledConnection with null event will place this connection back in the pool. Calling + * notifyPooledConnection 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 notifyPooledConnection(SQLServerException e) { synchronized (this) { if (null != pooledConnectionParent) { @@ -5571,7 +5554,7 @@ void DetachFromPool() { } /** - * Determine the listening port of a named SQL Server instance. + * Determines the listening port of a named SQL Server instance. * * @param server * the server name @@ -5695,16 +5678,19 @@ int getNextSavepointId() { return nNextSavePointId; } - // Returns this connection's SQLServerConnectionSecurityManager class to caller. - // Used by SQLServerPooledConnection to verify security when passing out Connection objects. + /** + * Returns this connection's SQLServerConnectionSecurityManager class to caller. Used by SQLServerPooledConnection + * to verify security when passing out Connection objects. + */ void doSecurityCheck() { assert null != currentConnectPlaceHolder; currentConnectPlaceHolder.doSecurityCheck(); } - // ColumnEncryptionKeyCache 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. + /** + * 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. + */ private static long columnEncryptionKeyCacheTtl = TimeUnit.SECONDS.convert(2, TimeUnit.HOURS); /** @@ -5733,7 +5719,7 @@ static synchronized long getColumnEncryptionKeyCacheTtl() { } /** - * Enqueue a discarded prepared statement handle to be clean-up on the server. + * Enqueues a discarded prepared statement handle to be clean-up on the server. * * @param statementHandle * The prepared statement handle that should be scheduled for unprepare. @@ -5762,7 +5748,7 @@ public void closeUnreferencedPreparedStatementHandles() { } /** - * Remove references to outstanding un-prepare requests. Should be run when connection is closed. + * Removes references to outstanding un-prepare requests. Should be run when connection is closed. */ private final void cleanupPreparedStatementDiscardActions() { discardedPreparedStatementHandles.clear(); @@ -5800,7 +5786,7 @@ final boolean isPreparedStatementUnprepareBatchingEnabled() { } /** - * Cleans-up discarded prepared statement handles on the server using batched un-prepare actions if the batching + * Cleans up discarded prepared statement handles on the server using batched un-prepare actions if the batching * threshold has been reached. * * @param force @@ -5900,7 +5886,7 @@ public void setStatementPoolingCacheSize(int value) { } /** - * Internal method to prepare the cache handle + * Prepares the cache handle. * * @param value */ @@ -5913,7 +5899,7 @@ private void prepareCache() { .maximumWeightedCapacity(getStatementPoolingCacheSize()).build(); } - /** Get a parameter metadata cache entry if statement pooling is enabled */ + /** Returns a parameter metadata cache entry if statement pooling is enabled */ final SQLServerParameterMetaData getCachedParameterMetadata(CityHash128Key key) { if (!isStatementPoolingEnabled()) return null; @@ -5921,7 +5907,7 @@ final SQLServerParameterMetaData getCachedParameterMetadata(CityHash128Key key) return parameterMetadataCache.get(key); } - /** Register a parameter metadata cache entry if statement pooling is enabled */ + /** Registers a parameter metadata cache entry if statement pooling is enabled */ final void registerCachedParameterMetadata(CityHash128Key key, SQLServerParameterMetaData pmd) { if (!isStatementPoolingEnabled() || null == pmd) return; @@ -5929,7 +5915,7 @@ final void registerCachedParameterMetadata(CityHash128Key key, SQLServerParamete parameterMetadataCache.put(key, pmd); } - /** Get or create prepared statement handle cache entry if statement pooling is enabled */ + /** Gets or creates prepared statement handle cache entry if statement pooling is enabled */ final PreparedStatementHandle getCachedPreparedStatementHandle(CityHash128Key key) { if (!isStatementPoolingEnabled()) return null; @@ -5937,7 +5923,7 @@ final PreparedStatementHandle getCachedPreparedStatementHandle(CityHash128Key ke return preparedStatementHandleCache.get(key); } - /** Get or create prepared statement handle cache entry if statement pooling is enabled */ + /** Gets or creates prepared statement handle cache entry if statement pooling is enabled */ final PreparedStatementHandle registerCachedPreparedStatementHandle(CityHash128Key key, int handle, boolean isDirectSql) { if (!isStatementPoolingEnabled() || null == key) @@ -5948,7 +5934,7 @@ final PreparedStatementHandle registerCachedPreparedStatementHandle(CityHash128K return cacheItem; } - /** Return prepared statement handle cache entry so it can be un-prepared. */ + /** Returns prepared statement handle cache entry so it can be un-prepared. */ final void returnCachedPreparedStatementHandle(PreparedStatementHandle handle) { handle.removeReference(); @@ -5956,7 +5942,7 @@ final void returnCachedPreparedStatementHandle(PreparedStatementHandle handle) { enqueueUnprepareStatementHandle(handle); } - /** Force eviction of prepared statement handle cache entry. */ + /** Forces eviction of prepared statement handle cache entry. */ final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) { if (null == handle || null == handle.getKey()) return; @@ -5964,7 +5950,9 @@ final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) { preparedStatementHandleCache.remove(handle.getKey()); } - // Handle closing handles when removed from cache. + /* + * Handles closing handles when removed from cache. + */ final class PreparedStatementCacheEvictionListener implements EvictionListener { public void onEviction(CityHash128Key key, PreparedStatementHandle handle) { @@ -6009,6 +5997,8 @@ boolean isAzureDW() throws SQLServerException, SQLException { } /** + * Adds statement to openStatements + * * @param st * Statement to add to openStatements */ @@ -6019,6 +6009,8 @@ final synchronized void addOpenStatement(Statement st) { } /** + * Removes state from openStatements + * * @param st * Statement to remove from openStatements */ @@ -6030,7 +6022,10 @@ final synchronized void removeOpenStatement(Statement st) { } -// Helper class for security manager functions used by SQLServerConnection class. +/** + * Provides Helper class for security manager functions used by SQLServerConnection class. + * + */ final class SQLServerConnectionSecurityManager { static final String dllName = "sqljdbc_auth.dll"; String serverName; @@ -6042,8 +6037,8 @@ final class SQLServerConnectionSecurityManager { } /** - * checkConnect will throws a SecurityException if the calling thread is not allowed to open a socket connection to - * the specified serverName and portNumber. + * 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 diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java index ffdad25361..93505f5f10 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java @@ -10,14 +10,14 @@ /** - * Extends {@link SQLServerConnection43} class and implements {@link ISQLServerConnection43} with - * methods introduced in JDBC 4.3 Specifications. This class is used by the driver when initializing a class with 43 - * driver version + * Extends {@link SQLServerConnection43} and implements {@link ISQLServerConnection43} with methods introduced in JDBC + * 4.3 Specifications. This class is used by the driver when initializing a class with with JDBC 4.3 Specs supported + * JVM. */ public class SQLServerConnection43 extends SQLServerConnection implements ISQLServerConnection43 { /** - * Always refresh SerialVersionUID when prompted + * Always refresh SerialVersionUID when prompted. */ private static final long serialVersionUID = -6904163521498951547L; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java index 06f63792b3..4ac11100fd 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java @@ -14,11 +14,10 @@ /** - * Provides physical database connections for connection pool managers. - * SQLServerConnectionPoolDataSource is typically used in Java Application Server environments that support built-in - * connection pooling and require a ConnectionPoolDataSource to provide physical connections. For example, J2EE - * application servers that provide JDBC 3.0 API spec connection pooling. - * + * Provides physical database connections for connection pool managers. SQLServerConnectionPoolDataSource is typically + * used in Java Application Server environments that support built-in connection pooling and require a + * ConnectionPoolDataSource to provide physical connections. For example, J2EE application servers that provide JDBC 3.0 + * API spec connection pooling. */ public class SQLServerConnectionPoolDataSource extends SQLServerDataSource implements ConnectionPoolDataSource { // Get a new physical connection that the pool manager will issue logical connections from @@ -65,9 +64,9 @@ private void readObject(java.io.ObjectInputStream stream) throws java.io.Invalid throw new java.io.InvalidObjectException(""); } - // This is 90% duplicate from the SQLServerDataSource, the serialization proxy pattern does not lend itself to - // inheritance - // so the duplication is necessary + /** + * Implements java.io.Serializable the same way as {@link SQLServerDataSource} + */ private static class SerializationProxy implements java.io.Serializable { private final Reference ref; private static final long serialVersionUID = 654661379842314126L; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java index b389677b9c..1ee3d0128d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolProxy.java @@ -17,7 +17,7 @@ /** - * SQLServerConnectionPoolProxy is a wrapper around SQLServerConnection object. When returning a connection object from + * Provides a wrapper around SQLServerConnection object. When returning a connection object from * PooledConnection.getConnection we return this proxy per SPEC. *

* This class's public functions need to be kept identical to the SQLServerConnection's. @@ -25,7 +25,6 @@ * 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 { /** * Always refresh SerialVersionUID when prompted @@ -39,12 +38,13 @@ class SQLServerConnectionPoolProxy implements ISQLServerConnection, java.io.Seri // dispenser final private String traceID; - // Permission targets - // currently only callAbort is implemented + /** + * Permission targets currently only callAbort is implemented + */ private static final String callAbortPerm = "callAbort"; /** - * Generate the next unique connection id. + * Generates the next unique connection id. * * @return the next conn id */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index d2ff110e62..2427f9d3e0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -57,7 +57,7 @@ public class SQLServerDataSource final private String traceID; /** - * Constructs a SQLServerDataSource + * Constructs a SQLServerDataSource. */ public SQLServerDataSource() { connectionProps = new Properties(); @@ -97,8 +97,10 @@ public Connection getConnection(String username, String password) throws SQLServ 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. + /** + * Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. Note + * default value is 0. + */ @Override public void setLoginTimeout(int loginTimeout) { setIntProperty(connectionProps, SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), loginTimeout); @@ -113,9 +115,10 @@ public int getLoginTimeout() { 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. + /** + * 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; @Override @@ -125,7 +128,9 @@ public void setLogWriter(PrintWriter out) { loggerExternal.exiting(getClassNameLogging(), "setLogWriter"); } - // Returns the log writer for this DataSource. + /** + * Returns the log writer for this DataSource. + */ @Override public PrintWriter getLogWriter() { loggerExternal.entering(getClassNameLogging(), "getLogWriter"); @@ -140,9 +145,9 @@ public Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException // Core Connection property setters/getters. - // applicationName is used to identify the specific application in various - // SQL Server - // profiling and logging tools. + /** + * Sets the specific application in various SQL Server profiling and logging tools. + */ @Override public void setApplicationName(String applicationName) { setStringProperty(connectionProps, SQLServerDriverStringProperty.APPLICATION_NAME.toString(), applicationName); @@ -154,9 +159,12 @@ public String getApplicationName() { 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. + /** + * Sets the the database to connect to. + * + * @param databaseName + * if not set, returns the default value of null. + */ @Override public void setDatabaseName(String databaseName) { setStringProperty(connectionProps, SQLServerDriverStringProperty.DATABASE_NAME.toString(), databaseName); @@ -167,9 +175,12 @@ 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. + /** + * Sets the the SQL Server instance name to connect to. + * + * @param instanceName + * if not set, returns the default value of null. + */ @Override public void setInstanceName(String instanceName) { setStringProperty(connectionProps, SQLServerDriverStringProperty.INSTANCE_NAME.toString(), instanceName); @@ -224,13 +235,11 @@ 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. + /** + * Sets the Column Encryption setting. 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. + */ @Override public void setColumnEncryptionSetting(String columnEncryptionSetting) { setStringProperty(connectionProps, SQLServerDriverStringProperty.COLUMN_ENCRYPTION.toString(), @@ -360,14 +369,14 @@ public String getHostNameInCertificate() { 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. + /** + * Sets the lock timeout value. + * + * @param lockTimeout + * 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. + */ @Override public void setLockTimeout(int lockTimeout) { setIntProperty(connectionProps, SQLServerDriverIntProperty.LOCK_TIMEOUT.toString(), lockTimeout); @@ -379,12 +388,13 @@ public int getLockTimeout() { 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. + /** + * Sets the password that will be used when connecting to SQL Server. + * + * @param password + * Note getPassword is deliberately declared non-public for security reasons. If the password is not set, + * getPassword returns the default value of null. + */ @Override public void setPassword(String password) { setStringProperty(connectionProps, SQLServerDriverStringProperty.PASSWORD.toString(), password); @@ -394,13 +404,14 @@ 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. + /** + * Sets the TCP-IP port number used when opening a socket connection to SQL Server. + * + * @param portNumber + * if 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. + */ @Override public void setPortNumber(int portNumber) { setIntProperty(connectionProps, SQLServerDriverIntProperty.PORT_NUMBER.toString(), portNumber); @@ -412,14 +423,16 @@ public int getPortNumber() { 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". + /** + * Sets the default cursor type used for the result set. + * + * @param selectMethod + * This(non-Javadoc) @see com.microsoft.sqlserver.jdbc.ISQLServerDataSource#setSelectMethod(java.lang.String) + * property is useful when you are dealing with large result sets and do not 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". + */ @Override public void setSelectMethod(String selectMethod) { setStringProperty(connectionProps, SQLServerDriverStringProperty.SELECT_METHOD.toString(), selectMethod); @@ -466,14 +479,14 @@ public boolean getSendTimeAsDatetime() { 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. + /** + * Sets whether string parameters are sent to the server in UNICODE format. + * + * @param sendStringParametersAsUnicode + * if true (default), string parameters are sent to the server in UNICODE format. if false, string parameters + * are sent to the server in the native TDS collation format of the database, not in UNICODE. if set, returns + * the default of true. + */ @Override public void setSendStringParametersAsUnicode(boolean sendStringParametersAsUnicode) { setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.toString(), @@ -499,9 +512,12 @@ public boolean getServerNameAsACE() { 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. + /** + * Sets the host name of the target SQL Server. + * + * @param serverName + * if not set, returns the default value of null is returned. + */ @Override public void setServerName(String serverName) { setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_NAME.toString(), serverName); @@ -512,8 +528,12 @@ 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 + /** + * Sets the Service Principal Name (SPN) of the target SQL Server. + * https://msdn.microsoft.com/en-us/library/cc280459.aspx + * + * @param serverSpn + */ @Override public void setServerSpn(String serverSpn) { setStringProperty(connectionProps, SQLServerDriverStringProperty.SERVER_SPN.toString(), serverSpn); @@ -524,9 +544,12 @@ 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. + /** + * Sets the fail over partner of the target SQL Server. + * + * @param serverName + * if not set, returns the default value of null. + */ @Override public void setFailoverPartner(String serverName) { setStringProperty(connectionProps, SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(), serverName); @@ -549,9 +572,12 @@ public boolean getMultiSubnetFailover() { 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. + /** + * Sets the user name that will be used when connecting to SQL Server. + * + * @param user + * if not set, returns the default value of null. + */ @Override public void setUser(String user) { setStringProperty(connectionProps, SQLServerDriverStringProperty.USER.toString(), user); @@ -562,12 +588,14 @@ 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(). + /** + * Sets the name of the client machine (or client workstation). + * + * @param workstationID + * host name of the client. if not set, the default value is constructed by calling + * InetAddress.getLocalHost().getHostName() or if getHostName() returns blank then + * getHostAddress().toString(). + */ @Override public void setWorkstationID(String workstationID) { setStringProperty(connectionProps, SQLServerDriverStringProperty.WORKSTATION_ID.toString(), workstationID); @@ -587,13 +615,13 @@ public String getWorkstationID() { 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. + /** + * Sets whether the driver will convert SQL states to XOPEN compliant states. + * + * @param xopenStates + * if 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 not set, getXopenStates returns the default value of false. + */ @Override public void setXopenStates(boolean xopenStates) { setBooleanProperty(connectionProps, SQLServerDriverBooleanProperty.XOPEN_STATES.toString(), xopenStates); @@ -652,26 +680,19 @@ public String getTrustManagerConstructorArg() { SQLServerDriverStringProperty.TRUST_MANAGER_CONSTRUCTOR_ARG.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://". + /** + * Sets the datasource URL. + * + * @param url + * 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://". + */ @Override public void setURL(String url) { loggerExternal.entering(getClassNameLogging(), "setURL", url); @@ -691,9 +712,10 @@ public String getURL() { 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". + /** + * Sets the DataSource description. Per JDBC specification 16.1.1 "...the only property that all DataSource + * implementations are required to support is the description property". + */ @Override public void setDescription(String description) { loggerExternal.entering(getClassNameLogging(), "setDescription", description); @@ -701,6 +723,9 @@ public void setDescription(String description) { loggerExternal.exiting(getClassNameLogging(), "setDescription"); } + /** + * Returns the DataSource description + */ @Override public String getDescription() { loggerExternal.entering(getClassNameLogging(), "getDescription"); @@ -708,10 +733,14 @@ public String getDescription() { 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. + /** + * Sets the packet size. + * + * @param packetSize + * 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. + */ @Override public void setPacketSize(int packetSize) { setIntProperty(connectionProps, SQLServerDriverIntProperty.PACKET_SIZE.toString(), packetSize); @@ -836,31 +865,15 @@ public String getJASSConfigurationName() { SQLServerDriverStringProperty.JAAS_CONFIG_NAME.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. + /** + * Sets a property string value. + * + * @param props + * @param propKey + * @param propValue + * 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")) { @@ -872,9 +885,15 @@ private void setStringProperty(Properties props, String propKey, String propValu 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. + /** + * Returns a property value in String format. + * + * @param props + * @param propKey + * @param defaultValue + * @return 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); @@ -887,8 +906,14 @@ private String getStringProperty(Properties props, String propKey, String defaul return propValue; } - // Set an integer property value. - // Caller will always supply a non-null props and propKey. + /** + * Sets an integer property value. + * + * @param props + * @param propKey + * @param propValue + * 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, propValue); @@ -896,9 +921,10 @@ private void setIntProperty(Properties props, String propKey, int propValue) { 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. + /** + * Returns 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); @@ -918,8 +944,9 @@ private int getIntProperty(Properties props, String propKey, int defaultValue) { return value; } - // Set a boolean property value. - // Caller will always supply a non-null props and propKey. + /** + * 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, propValue); @@ -927,9 +954,10 @@ private void setBooleanProperty(Properties props, String propKey, boolean propVa 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. + /** + * Returns 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); @@ -966,17 +994,12 @@ private Object getObjectProperty(Properties props, String propKey, Object defaul return propValue; } - // 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. + /** + * 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; @@ -1087,10 +1110,12 @@ Reference getReferenceInternal(String dataSourceClassString) { return ref; } - // Initialize this datasource from properties found inside the reference - // ref. - // Called by SQLServerDataSourceObjectFactory to initialize new DataSource - // instance. + /** + * Initializes the datasource from properties found inside the reference + * + * @param 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java index 3b49cc8720..59fc884b14 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java @@ -22,15 +22,14 @@ public final class SQLServerDataSourceObjectFactory implements ObjectFactory { // class with public constructor. /** - * Constructs a SQLServerDataSourceObjectFactory + * Constructs a SQLServerDataSourceObjectFactory. */ public SQLServerDataSourceObjectFactory() {} /** - * Returns an reference to the SQLServerDataSource instance - * getObjectInstance is a factory for rehydrating references to SQLServerDataSource and its child classes. - * Caller gets the reference by calling SQLServerDataSource.getReference. - * References are used by JNDI to persist and rehydrate objects. + * Returns an reference to the SQLServerDataSource instance getObjectInstance is a factory for rehydrating + * references to SQLServerDataSource and its child classes. Caller gets the reference by calling + * SQLServerDataSource.getReference. References are used by JNDI to persist and rehydrate objects. */ public Object getObjectInstance(Object ref, Name name, Context c, Hashtable h) throws SQLServerException { // Create a new instance of a DataSource class from the given reference. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java index 269f0d3d0a..e648271876 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java @@ -69,7 +69,7 @@ public synchronized Iterator> getIterator() { } /** - * Adds meta data for the specified column + * Adds meta data for the specified column. * * @param columnName * the name of the column @@ -85,7 +85,7 @@ public synchronized void addColumnMetadata(String columnName, int sqlType) throw } /** - * Adds meta data for the specified column + * Adds meta data for the specified column. * * @param column * the name of the column @@ -298,7 +298,7 @@ else if (val instanceof OffsetTime) /** * Returns the java.util.Map object type of columnMetaData for all columns where column indexes are - * mapped with their respective {@link SQLServerDataColumn} Java object + * mapped with their respective {@link SQLServerDataColumn} Java object. * * @return Map */ @@ -307,7 +307,7 @@ public synchronized Map getColumnMetadata() { } /** - * Returns name of TVP type set by {@link #setTvpName(String)} + * Returns name of TVP type set by {@link #setTvpName(String)}. * * @return tvpName */ @@ -316,7 +316,7 @@ public String getTvpName() { } /** - * Sets the TVP Name + * Sets the TVP Name. * * @param tvpName * the name of TVP diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index f4606fe91a..aca757bc9f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -101,7 +101,7 @@ private static int nextInstanceID() { } /** - * This is a helper function to provide an ID string suitable for tracing. + * Provides a helper function to provide an ID string suitable for tracing. * * @return traceID string */ @@ -110,7 +110,7 @@ final public String toString() { } /** - * Create new database meta data + * Constructs a SQLServerDatabaseMetaData database meta data * * @param con * the connection @@ -233,8 +233,7 @@ private void checkClosed() throws SQLServerException { private static final String IS_AUTOINCREMENT = "IS_AUTOINCREMENT"; /** - * Make a simple query execute and return the result from it. This is to be used only for internal queries without - * any user input. + * Returns the result from a simple query. This is to be used only for internal queries without any user input. * * @param catalog * catalog the query to be made in @@ -259,8 +258,8 @@ private SQLServerResultSet getResultSetFromInternalQueries(String catalog, return rs; } - /* - * Note we pool the handles per object. + /** + * Returns the CallableStatement handle. Note we pool the handles per object. */ private CallableStatement getCallableStatementHandle(CallableHandles request, String catalog) throws SQLServerException { @@ -278,7 +277,7 @@ private CallableStatement getCallableStatementHandle(CallableHandles request, } /** - * Make the stored procedure call and return the result from it. + * Returns the result from the stored procedure call. * * @param catalog * catalog the query to be made in @@ -325,7 +324,7 @@ private SQLServerResultSet getResultSetWithProvidedColumnNames(String catalog, C } /** - * Switch database catalogs. + * Switches the database catalogs. * * @param catalog * the new catalog @@ -513,7 +512,7 @@ public java.sql.ResultSet getTables(String catalog, String schema, String table, /** * Accepts a SQL identifier (such as a column name or table name) and escapes the identifier so sql 92 wild card * characters can be escaped properly to be passed to functions like sp_columns or sp_tables. Assumes that the - * incoming identifier is unescaped. + * incoming identifier is un-escaped. * * @inID input identifier to escape. * @return the escaped value. @@ -2316,8 +2315,10 @@ public boolean locatorsUpdateCopy() throws SQLException { } -// Filter to convert DATA_TYPE column values from the ODBC types -// returned by SQL Server to their equivalent JDBC types. +/** + * Provides filter to convert DATA_TYPE column values from the ODBC types returned by SQL Server to their equivalent + * JDBC types. + */ final class DataTypeFilter extends IntColumnFilter { private static final int ODBC_SQL_GUID = -11; private static final int ODBC_SQL_WCHAR = -8; @@ -2365,9 +2366,9 @@ int oneValueToAnother(int precl) { } -// abstract class converts one value to another solely based on the column -// integer value -// apply to integer columns only +/** + * Converts one value to another solely based on the column integer value. Apply to integer columns only + */ abstract class IntColumnFilter extends ColumnFilter { abstract int oneValueToAnother(int value); @@ -2401,9 +2402,10 @@ final Object apply(Object value, JDBCType asJDBCType) throws SQLServerException } -// Filter to convert int identity column values from 0,1 to YES, NO -// There is a mismatch between what the stored proc returns and what the -// JDBC spec expects. +/** + * Provides filter to convert int identity column values from 0,1 to YES, NO There is a mismatch between what the stored + * proc returns and what the JDBC spec expects. + */ class IntColumnIdentityFilter extends ColumnFilter { private static String zeroOneToYesNo(int i) { return 0 == i ? "NO" : "YES"; @@ -2444,5 +2446,4 @@ final Object apply(Object value, JDBCType asJDBCType) throws SQLServerException return value; } } - } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index 4655b4c488..2af70a0cdf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -21,10 +21,9 @@ /** - * SQLServerDriver implements the java.sql.Driver for SQLServerConnect. + * Implements the java.sql.Driver for SQLServerConnect. * */ - final class SQLServerDriverPropertyInfo { private final String name; @@ -195,12 +194,16 @@ enum ApplicationIntent { // the value of the enum private final String value; - // constructor that sets the string value of the enum + /** + * Constructs a ApplicationIntent that sets the string value of the enum. + */ private ApplicationIntent(String value) { this.value = value; } - // returns the string value of enum + /** + * Returns the string value of enum. + */ public String toString() { return value; } @@ -236,7 +239,7 @@ private SQLServerDriverObjectProperty(String name, String defaultValue) { } /** - * returning string due to structure of DRIVER_PROPERTIES_PROPERTY_ONLY + * Returns string due to structure of DRIVER_PROPERTIES_PROPERTY_ONLY. * * @return */ @@ -359,10 +362,9 @@ public String toString() { } } + /** - * * Provides methods to connect to a SQL Server database and to obtain information about the JDBC driver. - * */ public final class SQLServerDriver implements java.sql.Driver { static final String PRODUCT_NAME = "Microsoft JDBC Driver " + SQLJdbcVersion.major + "." + SQLJdbcVersion.minor @@ -504,8 +506,9 @@ public final class SQLServerDriver implements java.sql.Driver { Boolean.toString(SQLServerDriverBooleanProperty.USE_BULK_COPY_FOR_BATCH_INSERT.getDefaultValue()), false, TRUE_FALSE),}; - // Properties that can only be set by using Properties. - // Cannot set in connection string + /** + * Properties that can only be set by using Properties. Cannot set in connection string + */ private static final SQLServerDriverPropertyInfo[] DRIVER_PROPERTIES_PROPERTY_ONLY = { // default required available choices // property name value property (if appropriate) @@ -562,8 +565,10 @@ public SQLServerDriver() { loggingClassName = "com.microsoft.sqlserver.jdbc." + "SQLServerDriver:" + instanceID; } - // Helper function used to fixup the case sensitivity, synonyms and remove unknown tokens from the - // properties + /** + * Provides Helper function used to fix the case sensitivity, synonyms and remove unknown tokens from the + * properties. + */ static Properties fixupProperties(Properties props) throws SQLServerException { // assert props !=null Properties fixedup = new Properties(); @@ -594,9 +599,11 @@ static Properties fixupProperties(Properties props) throws SQLServerException { return fixedup; } - // Helper function used to merge together the property set extracted from the url and the - // user supplied property set passed in by the caller. This function is used by both SQLServerDriver.connect - // and SQLServerDataSource.getConnectionInternal to centralize this property merging code. + /** + * Provides Helper function used to merge together the property set extracted from the url and the user supplied + * property set passed in by the caller. This function is used by both SQLServerDriver.connect and + * SQLServerDataSource.getConnectionInternal to centralize this property merging code. + */ static Properties mergeURLAndSuppliedProperties(Properties urlProps, Properties suppliedProperties) throws SQLServerException { if (null == suppliedProperties) @@ -628,7 +635,7 @@ static Properties mergeURLAndSuppliedProperties(Properties urlProps, } /** - * Returns the normalized the property names + * Returns the normalized the property names. * * @param name * name to normalize @@ -656,7 +663,7 @@ static String getNormalizedPropertyName(String name, Logger logger) { } /** - * Returns the property-only names that do not work with connection string + * Returns the property-only names that do not work with connection string. * * @param name * to normalize diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java index 60feb165c4..6724596e05 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java @@ -89,7 +89,7 @@ final void setDriverErrorCode(int value) { } /** - * Logs an exception to the driver log file + * Logs an exception to the driver log file. * * @param o * the io buffer that generated the exception @@ -131,7 +131,7 @@ static String getErrString(String errCode) { } /** - * Make a new SQLException + * Construct a SQLServerException. * * @param errText * the exception message @@ -168,7 +168,7 @@ public SQLServerException(Object obj, String errText, String errState, int errNu } /** - * Constructs a new SQLServerException + * Constructs a new SQLServerException. * * @param obj * the object @@ -181,8 +181,7 @@ public SQLServerException(Object obj, String errText, String errState, int errNu * @param bStack * true to generate the stack trace */ - public SQLServerException(Object obj, String errText, String errState, StreamError streamError, - boolean bStack) { + public SQLServerException(Object obj, String errText, String errState, StreamError streamError, boolean bStack) { super(errText, errState, streamError.getErrorNumber()); // Log SQL error with info from StreamError. @@ -192,7 +191,7 @@ public SQLServerException(Object obj, String errText, String errState, StreamErr } /** - * Builds a new SQL Exception from an error detected by the driver. + * Constructs a SQLServerException from an error detected by the driver. * * @param con * the connection @@ -243,8 +242,8 @@ static void makeFromDriverError(SQLServerConnection con, Object obj, String errT * true to generate the stack trace * @throws SQLServerException */ - static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText, - StreamError streamError, boolean bStack) throws SQLServerException { + static void makeFromDatabaseError(SQLServerConnection con, Object obj, String errText, StreamError streamError, + boolean bStack) throws SQLServerException { String state = generateStateCode(con, streamError.getErrorNumber(), streamError.getErrorState()); SQLServerException theException = new SQLServerException(obj, @@ -306,7 +305,7 @@ static String mapFromXopen(String state) { } /** - * Generates the JDBC state code based on the error number returned from the database + * Generates the JDBC state code based on the error number returned from the database. * * @param con * the connection @@ -359,7 +358,7 @@ static String generateStateCode(SQLServerConnection con, int errNum, int databas } /** - * Appends ClientConnectionId to an error message if applicable + * Appends ClientConnectionId to an error message if applicable. * * @param errMsg * - the orginal error message. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java index d7a0cf59ce..0fdee293db 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java @@ -10,7 +10,7 @@ abstract class SQLServerLob { /** - * Function for the result set to maintain blobs it has created + * Provides functionality for the result set to maintain blobs it has created. * * @throws SQLException */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java index 8f2316b700..da9db54b7e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java @@ -10,8 +10,8 @@ /** * - * Represents metadata for a column. It is used in the ISQLServerDataRecord interface to pass column metadata - * to the table-valued parameter. + * Represents metadata for a column. It is used in the ISQLServerDataRecord interface to pass column metadata to the + * table-valued parameter. * */ public class SQLServerMetaData { @@ -29,7 +29,7 @@ public class SQLServerMetaData { static final int defaultSortOrdinal = -1; /** - * Constructs a SQLServerMetaData with the column name and SQL type + * Constructs a SQLServerMetaData with the column name and SQL type. * * @param columnName * the name of the column @@ -42,7 +42,7 @@ public SQLServerMetaData(String columnName, int sqlType) { } /** - * Constructs a SQLServerMetaData with the column name, SQL type, precision, and scale + * Constructs a SQLServerMetaData with the column name, SQL type, precision, and scale. * * @param columnName * the name of the column @@ -61,7 +61,7 @@ public SQLServerMetaData(String columnName, int sqlType, int precision, int scal } /** - * Constructs a SQLServerMetaData + * Constructs a SQLServerMetaData. * * @param columnName * the name of the column @@ -114,6 +114,7 @@ public SQLServerMetaData(SQLServerMetaData sqlServerMetaData) { /** * Returns the column name. + * * @return column name */ public String getColumName() { @@ -122,6 +123,7 @@ public String getColumName() { /** * Returns the java sql type. + * * @return java sql type */ public int getSqlType() { @@ -130,6 +132,7 @@ public int getSqlType() { /** * Returns the precision of the type passed to the column. + * * @return precision */ public int getPrecision() { @@ -138,6 +141,7 @@ public int getPrecision() { /** * Returns the scale of the type passed to the column. + * * @return scale */ public int getScale() { @@ -146,6 +150,7 @@ public int getScale() { /** * Returns whether the column uses the default server value. + * * @return whether the column uses the default server value. */ public boolean useServerDefault() { @@ -154,6 +159,7 @@ public boolean useServerDefault() { /** * Returns whether the column is unique. + * * @return whether the column is unique. */ public boolean isUniqueKey() { @@ -162,6 +168,7 @@ public boolean isUniqueKey() { /** * Returns the sort order. + * * @return sort order */ public SQLServerSortOrder getSortOrder() { @@ -170,6 +177,7 @@ public SQLServerSortOrder getSortOrder() { /** * Returns the sort ordinal. + * * @return sort ordinal */ public int getSortOrdinal() { @@ -177,7 +185,8 @@ public int getSortOrdinal() { } /** - * Returns collation. + * Returns the collation. + * * @return SQL collation */ SQLCollation getCollation() { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index f7e785a63c..9e2603f759 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -325,7 +325,7 @@ private void parseQueryMetaFor2008(ResultSet rsQueryMeta) throws SQLServerExcept } /** - * Parses escaped strings properly e.g.[Table Name, ] using tokenizer + * Parses escaped strings properly e.g.[Table Name, ] using tokenizer/ * * @param st * string tokenizer @@ -894,7 +894,7 @@ public int isNullable(int param) throws SQLServerException { } /** - * Verify a supplied parameter index is valid + * Returns if a supplied parameter index is valid. * * @param param * the param index diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java index dd7952b689..9d178bc914 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.java @@ -18,9 +18,8 @@ /** - * 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. + * 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 { @@ -121,11 +120,11 @@ public Connection getConnection() throws SQLException { } } - // 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. + /** + * Notifies 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()); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 4aef3148be..e96b550e7d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -34,8 +34,8 @@ /** - * Provides JDBC prepared statement functionality. SQLServerPreparedStatement provides - * methods for the user to supply parameters as any native Java type and many Java object types. + * Provides an implementation of java.sql.PreparedStatement interface that assists in preparing Statements for SQL + * Server. *

* 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) @@ -187,7 +187,7 @@ String getClassNameInternal() { } /** - * Constructs a SQLServerPreparedStatement + * Constructs a SQLServerPreparedStatement. * * @param conn * the connection @@ -595,8 +595,8 @@ final void doExecutePreparedStatement(PrepStmtExecCmd command) throws SQLServerE } /** - * Returns if the execution should be retried because the re-used cached handle could not be re-used due to server side state - * changes + * Returns if the execution should be retried because the re-used cached handle could not be re-used due to server + * side state changes. */ private boolean retryBasedOnFailedReuseOfCachedHandle(SQLException e, int attempt, boolean needsPrepare, boolean isBatch) { @@ -659,7 +659,7 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException { } /** - * Sends the statement parameters by RPC + * Sends the statement parameters by RPC. */ void sendParamsByRPC(TDSWriter tdsWriter, Parameter[] params) throws SQLServerException { char cParamName[]; @@ -964,7 +964,9 @@ private void getParameterEncryptionMetadata(Parameter[] params) throws SQLServer connection.resetCurrentCommand(); } - /** Manage re-using cached handles */ + /** + * Manages re-using cached handles. + */ private boolean reuseCachedHandle(boolean hasNewTypeDefinitions, boolean discardCurrentCacheItem) { // No re-use of caching for cursorable statements (statements that WILL use sp_cursor*) if (isCursorable(executeMethod)) @@ -2976,7 +2978,6 @@ public final void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLExce loggerExternal.exiting(getClassNameLogging(), "setSQLXML"); } - /* make sure we throw here */ @Override public final int executeUpdate(String sql) throws SQLServerException { loggerExternal.entering(getClassNameLogging(), "executeUpdate", sql); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 5309dd1ad5..89502cd2af 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -33,7 +33,7 @@ /** - * Indicates the type of the row received from the server + * Indicates the type of the row received from the server. */ enum RowType { ROW, @@ -228,7 +228,7 @@ public SensitivityClassification getSensitivityClassification() { } /** - * Constructs a SQLServerResultSet + * Constructs a SQLServerResultSet. * * @param stmtIn * the generating statement @@ -505,7 +505,7 @@ private void verifyResultSetIsUpdatable() throws SQLServerException { } /** - * Returns if whether the result set has a current row. + * Returns whether the result set has a current row. * * @return true if there is a current row * @return false if the result set is positioned before the first row or after the last row. @@ -592,7 +592,7 @@ private void throwUnsupportedCursorOp() throws SQLServerException { } /** - * Close the result set. + * Closes the result set. * * Note that the public close() method performs all of the cleanup work through this internal method which cannot * throw any exceptions. This is done deliberately to ensure that ALL of the object's client-side and server-side @@ -631,7 +631,7 @@ public void close() throws SQLServerException { } /** - * Find a column index given a column name + * Finds a column index given a column name. * * @param columnName * the name of the column @@ -714,7 +714,7 @@ final Column getColumn(int columnIndex) throws SQLServerException { } /** - * This function initializes null compressed columns only when the row type is NBCROW and if the + * Initializes null compressed columns only when the row type is NBCROW and if the * areNullCompressedColumnsInitialized is false. In all other cases this will be a no-op. * * @throws SQLServerException @@ -763,7 +763,7 @@ private Column loadColumn(int index) throws SQLServerException { } /** - * Clears result set warnings + * Clears result set warnings. * * @throws SQLServerException * when an error occurs @@ -950,7 +950,7 @@ private void moveBackward(int rowsToMove) throws SQLServerException { } /** - * Update the current row's position if known. + * Updates the current row's position if known. * * If known, the current row is assumed to be at a valid position somewhere in the ResultSet. That is, the current * row is not before the first row or after the last row. @@ -964,7 +964,7 @@ private void updateCurrentRow(int rowsToMove) { } /** - * Moves the cursor to the first row of this ResultSet object initially, then subsequent calls moves the cursor to + * Moves the cursor to the first row of this ResultSet object initially, then subsequent calls move the cursor to * the second row, the third row, and so on. * * @return false when there are no more rows to read @@ -1072,6 +1072,8 @@ public boolean wasNull() throws SQLServerException { } /** + * Returns if the cursor is before the first row in this result set. + * * @return true if the cursor is before the first row in this result set, returns false otherwise or if the result * set contains no rows. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java index a9d52ee683..5f36d2d75f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java @@ -10,9 +10,8 @@ /** - * Provides an implementation of the result set metadata to the SQL Server. - * A ResultSetMetaData object can be used to obtain the meta data (types and type properties) of the columns in a - * ResultSet. + * Provides an implementation of the result set metadata to the SQL Server. A ResultSetMetaData object can be used to + * obtain the meta data (types and type properties) of the columns in a ResultSet. * * 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. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java index 26ceb7b106..b58a715c31 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSQLXML.java @@ -50,9 +50,8 @@ /** - * SQLServerSQLXML represents an XML object and implements a java.sql.SQLXML. + * Represents an XML object and implements a java.sql.SQLXML. */ - final class SQLServerSQLXML implements java.sql.SQLXML { // Connection that created this SQLXML only set when created for setting data private final SQLServerConnection con; @@ -82,7 +81,11 @@ final public String toString() { return traceID; } - // Returns unique id for each instance. + /** + * Returns unique id for each instance. + * + * @return + */ private static int nextInstanceID() { return baseID.incrementAndGet(); } @@ -203,7 +206,7 @@ void checkWriteXML() throws SQLException { } /** - * Return an input stream to read data from this SQLXML + * Returns an input stream to read data from this SQLXML. * * @throws SQLException * when an error occurs @@ -218,8 +221,8 @@ public InputStream getBinaryStream() throws SQLException { } /** - * Sets 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. + * Sets 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. * * @throws SQLException * when an error occurs @@ -488,8 +491,9 @@ private DOMResult getDOMResult() throws SQLException { } -// We use this class to convert the byte information we have in the string to -// an inputstream which is used when sending to the info to the server +/** + * Converts the byte information in the string to an inputstream which is used when sending to the info to the server. + */ final class ByteArrayOutputStreamToInputStream extends ByteArrayOutputStream { ByteArrayInputStream getInputStream() throws SQLServerException { ByteArrayInputStream is = new ByteArrayInputStream(buf, 0, count); @@ -498,7 +502,10 @@ ByteArrayInputStream getInputStream() throws SQLServerException { } -// Resolves External entities in an XML with inline DTDs to empty string +/** + * Resolves External entities in an XML with inline DTDs to empty string. + * + */ final class SQLServerEntityResolver implements EntityResolver { public InputSource resolveEntity(String publicId, String systemId) { return new InputSource(new StringReader("")); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java index 2a921f8dbd..94679be972 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java @@ -9,8 +9,8 @@ /** - * Provides an implementation of the JDBC 3.0 savepoints. A savepoint is checkpoint to which a transaction can be rolled - * back. Savepoints are defined relative to a connection. + * Provides an implementation of JDBC Interface java.sql.Savepoint. 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. @@ -22,7 +22,7 @@ public final class SQLServerSavepoint implements ISQLServerSavepoint { private final SQLServerConnection con; /** - * Constructs a SQLServerSavepoint + * Constructs a SQLServerSavepoint. * * @param con * the connection diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java index 38d722c3ed..d8f01ef78c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java @@ -94,14 +94,14 @@ abstract class SQLServerSpatialDatatype { protected abstract void serializeToWkb(boolean noZM); /** - * Deserialize the buffer (that contains WKB representation of Geometry/Geography data), and stores it into multiple - * corresponding data structures. + * Deserializes the buffer (that contains WKB representation of Geometry/Geography data), and stores it into + * multiple corresponding data structures. * */ protected abstract void parseWkb(); /** - * Create the WKT representation of Geometry/Geography from the deserialized data. + * Constructs the WKT representation of Geometry/Geography from the deserialized data. * * @param sd * the Geometry/Geography instance. @@ -875,7 +875,7 @@ && checkEmptyKeyword(parentShapeIndex, InternalSpatialDatatype.valueOf(nextToken } /** - * Reads a CurvePolygon WKT + * Reads a CurvePolygon WKT. * * @throws SQLServerException * if an exception occurs @@ -915,7 +915,7 @@ protected void readCurvePolygon() throws SQLServerException { } /** - * Reads a MultiPolygon WKT + * Reads a MultiPolygon WKT. * * @param thisShapeIndex * shape index of current shape @@ -947,7 +947,7 @@ protected void readMultiPolygonWkt(int thisShapeIndex, String nextToken) throws } /** - * Reads a Segment WKT + * Reads a Segment WKT. * * @param segmentType * segment type @@ -987,7 +987,7 @@ protected void readSegmentWkt(int segmentType, boolean isFirstIteration) throws } /** - * Reads a CompoundCurve WKT + * Reads a CompoundCurve WKT. * * @param isFirstIteration * flag that indicates if this is the first iteration from the loop outside @@ -1043,7 +1043,7 @@ protected String getNextStringToken() { } /** - * Populates the various data structures contained within the Geometry/Geography instace. + * Populates the various data structures contained within the Geometry/Geography instance. */ protected void populateStructures() { if (pointList.size() > 0) { @@ -1650,7 +1650,7 @@ private void skipWhiteSpaces() { /** - * Class to hold and represent the internal makings of a Figure. + * Represents the internal makings of a Figure. * */ class Figure { @@ -1677,7 +1677,7 @@ public void setFiguresAttribute(byte fa) { /** - * Class to hold and represent the internal makings of a Shape. + * Represents the internal makings of a Shape. * */ class Shape { @@ -1711,7 +1711,7 @@ public void setFigureOffset(int fo) { /** - * Class to hold and represent the internal makings of a Segment. + * Represents the internal makings of a Segment. * */ class Segment { @@ -1728,7 +1728,7 @@ public byte getSegmentType() { /** - * Class to hold and represent the internal makings of a Point. + * Represents the internal makings of a Point. * */ class Point { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java index 00996951ed..ec37e6ffe3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java @@ -29,9 +29,10 @@ /** - * Provides the basic implementation of JDBC statement functionality. It also provides a number of - * base class implementation methods for the JDBC prepared statement and callable Statements. SQLServerStatement's basic - * role is to execute SQL statements and return update counts and resultset rows to the user application. + * Provides an implementation of java.sql.Statement JDBC Interface to assist in creating Statements against SQL Server. + * It also provides a number of base class implementation methods for the JDBC prepared statement and callable + * Statements. SQLServerStatement's basic role is to execute SQL statements and return update counts and resultset rows + * to the user application. * * 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 @@ -48,7 +49,6 @@ * 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 SQLServerStatement implements ISQLServerStatement { final static char LEFT_CURLY_BRACKET = 123; final static char RIGHT_CURLY_BRACKET = 125; @@ -162,7 +162,7 @@ protected SQLServerStatementColumnEncryptionSetting getStmtColumnEncriptionSetti } /** - * ExecuteProperties encapsulates a subset of statement property values as they were set at execution time. + * Encapsulates a subset of statement property values as they were set at execution time. */ final class ExecuteProperties { final private boolean wasResponseBufferingSet; @@ -267,7 +267,7 @@ synchronized void incrResultSetCount() { } /** - * decrement opened result set counter + * Decrement opened result set counter. */ synchronized void decrResultSetCount() { resultSetCount--; @@ -969,7 +969,7 @@ final boolean isSelect(String sql) throws SQLServerException { * The statment SQL. * @return True if the statement is an insert. */ - final boolean isInsert(String sql) throws SQLServerException { + final boolean isInsert(String sql) throws SQLServerException { checkClosed(); // Used to check just the first letter which would cause // "Set" commands to return true... @@ -1314,7 +1314,7 @@ final void processResults() throws SQLServerException { } /** - * Returns more results in the TDS stream + * Returns more results in the TDS stream. * * @return true if the next result is a ResultSet object; false if it is an integer (indicating that it is an update * count or there are no more results). @@ -1902,7 +1902,7 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio } // executeLargeBatch /** - * Returns the statement's connection + * Returns the statement's connection. * * @throws SQLServerException * when an error occurs @@ -2331,7 +2331,7 @@ public final String getResponseBuffering() throws SQLServerException { /** - * Helper class that does some basic parsing work for SQL statements that are stored procedure calls. + * Provides a help class that does some basic parsing work for SQL statements that are stored procedure calls. * * - Determines whether the SQL uses JDBC call syntax ("{[? =] call procedure_name...}") or T-SQL EXECUTE syntax ("EXEC * [@p0 =] procedure_name..."). If JDBC call syntax is present, it gets rewritten as T-SQL EXECUTE syntax. @@ -2435,9 +2435,9 @@ enum State { .compile("\\{\\s*[lL][iI][mM][iI][tT]\\s+(((\\(|\\s)*)(\\d*|\\?)((\\)|\\s)*))\\s*\\}"); /** - * This function translates the LIMIT escape syntax, {LIMIT [OFFSET ]} SQL Server does not support - * LIMIT syntax, the LIMIT escape syntax is thus translated to use "TOP" syntax The OFFSET clause is not supported, - * and will throw an exception if used. + * Translates the LIMIT escape syntax, {LIMIT [OFFSET ]} SQL Server does not support LIMIT syntax, the + * LIMIT escape syntax is thus translated to use "TOP" syntax The OFFSET clause is not supported, and will throw an + * exception if used. * * @param sql * the SQL query @@ -2453,7 +2453,6 @@ enum State { * @return the number of characters that have been translated * */ - int translateLimit(StringBuffer sql, int indx, char endChar) throws SQLServerException { Matcher selectMatcher = selectPattern.matcher(sql); Matcher openQueryMatcher = openQueryPattern.matcher(sql); @@ -2496,18 +2495,17 @@ int translateLimit(StringBuffer sql, int indx, char endChar) throws SQLServerExc break; case OFFSET: // throw exception as OFFSET is not supported - throw new SQLServerException(SQLServerException.getErrString("R_limitOffsetNotSupported"), null, // SQLState - // is - // null - // as - // this - // error - // is - // generated - // in - // the - // driver - 0, // Use 0 instead of DriverError.NOT_SET to use the correct constructor + // SQLState is null as this error is generated in the driver + throw new SQLServerException(SQLServerException.getErrString("R_limitOffsetNotSupported"), null, 0, // Use + // 0 + // instead + // of + // DriverError.NOT_SET + // to + // use + // the + // correct + // constructor null); case LIMIT: // Check if the number of opening/closing parentheses surrounding the digits or "?" in LIMIT match @@ -2524,17 +2522,8 @@ int translateLimit(StringBuffer sql, int indx, char endChar) throws SQLServerExc closingParentheses++; } if (openingParentheses != closingParentheses) { - throw new SQLServerException(SQLServerException.getErrString("R_limitEscapeSyntaxError"), null, // SQLState - // is - // null - // as - // this - // error - // is - // generated - // in - // the - // driver + // SQLState is null as this error is generated in the driver + throw new SQLServerException(SQLServerException.getErrString("R_limitEscapeSyntaxError"), null, 0, // Use 0 instead of DriverError.NOT_SET to use the correct constructor null); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java index 40c41fbc7e..6ba0504b7a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXADataSource.java @@ -15,8 +15,8 @@ /** - * Provides database connections for use in distributed (XA) transactions. SQLServerXADataSource - * also supports connection pooling of physical connections. + * Provides database connections for use in distributed (XA) transactions. SQLServerXADataSource also supports + * connection pooling of physical connections. * * The XADataSource and XAConnection interfaces, which are defined in the package javax.sql, are implemented by * sqlserver. An XAConnection object is a pooled connection that can participate in a distributed transaction. More @@ -114,9 +114,9 @@ private void readObject(java.io.ObjectInputStream stream) throws java.io.Invalid throw new java.io.InvalidObjectException(""); } - // This is 90% duplicate from the SQLServerDataSource, the serialization proxy pattern does not lend itself to - // inheritance - // so the duplication is necessary + /** + * Implements java.io.Serializable the same way as {@link SQLServerDataSource} + */ private static class SerializationProxy implements java.io.Serializable { private final Reference ref; private static final long serialVersionUID = 454661379842314126L; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java index e248212f26..224996a90f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerXAResource.java @@ -24,7 +24,7 @@ /** - * Transaction id implementation used to recover transactions. + * Impelments Transaction id used to recover transactions. */ final class XidImpl implements Xid { private final int formatId; @@ -41,7 +41,7 @@ final class XidImpl implements Xid { */ /** - * Constructs a XidImpl + * Constructs a XidImpl. * * @param formatId * format id @@ -70,7 +70,7 @@ public int getFormatId() { } /** - * Returns trace id used for tracing + * Returns trace id used for tracing. * * @return traceID string */ @@ -102,9 +102,9 @@ final class XAReturnValue { /** - * This class provides an XAResource for XA distributed transaction management. XA transactions are implemented - * over SQL Server using Microsoft Distributed Transaction Manager (DTC). SQLServerXAResource makes calls to a SQL - * Server extended dll called SQLServer_XA.dll which interfaces with DTC. + * Provides an XAResource for XA distributed transaction management. XA transactions are implemented over SQL Server + * using Microsoft Distributed Transaction Manager (DTC). SQLServerXAResource makes calls to a SQL Server extended dll + * called SQLServer_XA.dll which interfaces with DTC. * * XA calls received by SQLServerXAResource (XA_START, XA_END, XA_PREPARE etc) are mapped to the corresponding calls to * DTC functions. @@ -112,7 +112,6 @@ final class XAReturnValue { * SQLServerXAResource may also be configured not to use DTC. In this case distributed transactions are simply * implemented as local transactions. */ - public final class SQLServerXAResource implements javax.transaction.xa.XAResource { /* * In the Java transaction API doc a 'resource manager' appears to be (for JDBC) a 'particular DBMS server that diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java b/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java index 4bab44e13c..281398d2da 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java @@ -81,14 +81,14 @@ public class SqlVariant { private JDBCType baseJDBCType; /** - * Constructs a SqlVariant + * Constructs a SqlVariant. */ SqlVariant(int baseType) { this.baseType = baseType; } /** - * Returns if the basetype for variant is of time value + * Returns if the basetype for variant is of time value. * * @return */ @@ -101,7 +101,7 @@ void setIsBaseTypeTimeValue(boolean isBaseTypeTime) { } /** - * Sets the base type for sql-variant + * Sets the base type for sql-variant. * * @param baseType */ @@ -110,7 +110,7 @@ void setBaseType(int baseType) { } /** - * Returns the base type for sql-variant + * Returns the base type for sql-variant. * * @return */ @@ -119,7 +119,7 @@ int getBaseType() { } /** - * Store the basetype as jdbc type + * Stores the basetype as JDBC type. * * @param baseJDBCType */ @@ -128,7 +128,7 @@ void setBaseJDBCType(JDBCType baseJDBCType) { } /** - * Returns the base type as jdbc type + * Returns the base type as JDBC type. * * @return */ @@ -137,7 +137,7 @@ JDBCType getBaseJDBCType() { } /** - * Sets the scale if applicable + * Sets the scale if applicable. * * @param scale */ @@ -146,7 +146,7 @@ void setScale(int scale) { } /** - * Returns the scale + * Returns the scale. * * @return */ @@ -155,7 +155,7 @@ int getScale() { } /** - * Sets the precision if applicable + * Sets the precision if applicable. * * @param precision */ @@ -164,7 +164,7 @@ void setPrecision(int precision) { } /** - * Returns the precision + * Returns the precision. * * @return */ @@ -173,7 +173,7 @@ int getPrecision() { } /** - * Sets the collation if applicable + * Sets the collation if applicable. * * @param collation */ @@ -182,7 +182,7 @@ void setCollation(SQLCollation collation) { } /** - * Returns the collation + * Returns the collation. * * @return */ @@ -191,7 +191,7 @@ SQLCollation getCollation() { } /** - * Sets the maximum length + * Sets the maximum length. * * @param maxLength */ @@ -200,7 +200,7 @@ void setMaxLength(int maxLength) { } /** - * Returns the maximum length + * Returns the maximum length. * * @return */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java index 5e9e1c8792..7acffa5148 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/dataclassification/SensitivityClassification.java @@ -10,7 +10,8 @@ /** - * Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active resultSet + * Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active + * resultSet */ public class SensitivityClassification { private List