From 362d3a43c52a30284247222719459f09a9f3f285 Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Thu, 7 Nov 2024 11:42:05 -0800 Subject: [PATCH] javadocs (#2521) --- .../sqlserver/jdbc/KerbAuthentication.java | 4 +-- .../PersistentTokenCacheAccessAspect.java | 7 ++++++ .../sqlserver/jdbc/ReconnectListener.java | 3 +++ .../sqlserver/jdbc/SQLServerConnection.java | 15 +++++++++++ .../sqlserver/jdbc/SQLServerException.java | 6 +++++ .../jdbc/SQLServerPreparedStatement.java | 25 ++++++++++++++----- .../sqlserver/jdbc/SQLServerSortOrder.java | 3 +++ .../sqlserver/jdbc/SQLServerWarning.java | 5 +++- 8 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java index 3c21e7711..6f8f30a29 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/KerbAuthentication.java @@ -5,8 +5,6 @@ package com.microsoft.sqlserver.jdbc; -import java.security.AccessControlContext; -import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.text.MessageFormat; @@ -96,7 +94,7 @@ private void initAuthInit() throws SQLServerException { Subject currentSubject; KerbCallback callback = new KerbCallback(con); try { - AccessControlContext context = AccessController.getContext(); + java.security.AccessControlContext context = java.security.AccessController.getContext(); currentSubject = Subject.getSubject(context); if (null == currentSubject) { if (useDefaultJaas) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java b/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java index 24458a7f3..5dca14899 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java @@ -28,6 +28,13 @@ public class PersistentTokenCacheAccessAspect implements ITokenCacheAccessAspect static final long TIME_TO_LIVE = 86400000L; // Token cache time to live (24 hrs). private long expiryTime; + /** + * default constructor + */ + public PersistentTokenCacheAccessAspect() { + // default constructor + } + static PersistentTokenCacheAccessAspect getInstance() { if (instance == null) { instance = new PersistentTokenCacheAccessAspect(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ReconnectListener.java b/src/main/java/com/microsoft/sqlserver/jdbc/ReconnectListener.java index c56045dfd..5fc1dfff8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ReconnectListener.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ReconnectListener.java @@ -10,6 +10,9 @@ @FunctionalInterface public interface ReconnectListener { + /** + * called before reconnect + */ void beforeReconnect(); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 903adc0b0..601271755 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -1064,6 +1064,9 @@ public void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision) { this.calcBigDecimalPrecision = calcBigDecimalPrecision; } + /** + * Retry exec + */ private String retryExec = SQLServerDriverStringProperty.RETRY_EXEC.getDefaultValue(); /** @@ -1783,10 +1786,22 @@ SQLServerPooledConnection getPooledConnectionParent() { */ private List reconnectListeners = new ArrayList<>(); + /** + * Register before reconnect listener + * + * @param reconnectListener + * reconnect listener + */ public void registerBeforeReconnectListener(ReconnectListener reconnectListener) { reconnectListeners.add(reconnectListener); } + /** + * Remove before reconnect listener + * + * @param reconnectListener + * reconnect listener + */ public void removeBeforeReconnectListener(ReconnectListener reconnectListener) { reconnectListeners.remove(reconnectListener); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java index 57387bb03..ba35b84a2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java @@ -179,6 +179,12 @@ static String getErrString(String errCode) { logException(obj, errText, bStack); } + /** + * Constructs a new SQLServerException from SQL Server error + * + * @param sqlServerError + * SQL Server error + */ public SQLServerException(SQLServerError sqlServerError) { super(sqlServerError.getErrorMessage(), generateStateCode(null, sqlServerError.getErrorNumber(), sqlServerError.getErrorState()), diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 2c2bbcb9a..2128f9cef 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -132,8 +132,20 @@ private void setPreparedStatementHandle(int handle) { * For caching data related to batch insert with bulkcopy */ private SQLServerBulkCopy bcOperation = null; + + /** + * Bulkcopy operation table name + */ private String bcOperationTableName = null; + + /** + * Bulkcopy operation column list + */ private ArrayList bcOperationColumnList = null; + + /** + * Bulkcopy operation value list + */ private ArrayList bcOperationValueList = null; /** Returns the prepared statement SQL */ @@ -450,13 +462,13 @@ private String buildParamTypeDefinitions(Parameter[] params, boolean renewDefini return ""; // Output looks like @P0 timestamp, @P1 varchar - int stringLen = nCols * 2; // @P - stringLen += nCols; // spaces - stringLen += nCols -1; // commas + int stringLen = nCols * 2; // @P + stringLen += nCols; // spaces + stringLen += nCols - 1; // commas if (nCols > 10) - stringLen += 10 + ((nCols - 10) * 2); // @P{0-99} Numbers after p + stringLen += 10 + ((nCols - 10) * 2); // @P{0-99} Numbers after p else - stringLen += nCols; // @P{0-9} Numbers after p less than 10 + stringLen += nCols; // @P{0-9} Numbers after p less than 10 // Computing the type definitions up front, so we can get exact string lengths needed for the string builder. String[] typeDefinitions = new String[nCols]; @@ -2358,7 +2370,8 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio if (rs.getColumnCount() != bcOperationValueList.size()) { MessageFormat form = new MessageFormat( SQLServerException.getErrString("R_colNotMatchTable")); - Object[] msgArgs = {bcOperationColumnList!= null ? bcOperationColumnList.size() : 0, bcOperationValueList.size()}; + Object[] msgArgs = {bcOperationColumnList != null ? bcOperationColumnList.size() : 0, + bcOperationValueList.size()}; throw new IllegalArgumentException(form.format(msgArgs)); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java index 16ea49043..756515674 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSortOrder.java @@ -11,8 +11,11 @@ * */ public enum SQLServerSortOrder { + /** ascending order */ ASCENDING(0), + /** descending order */ DESCENDING(1), + /** unspecified order */ UNSPECIFIED(-1); final int value; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerWarning.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerWarning.java index de6df2a42..dffefdcb8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerWarning.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerWarning.java @@ -22,8 +22,11 @@ public class SQLServerWarning extends SQLWarning { /** SQL server error */ private SQLServerError sqlServerError; - /* + /** * Create a SQLWarning from an SQLServerError object + * + * @param sqlServerError + * SQL Server error */ public SQLServerWarning(SQLServerError sqlServerError) { super(sqlServerError.getErrorMessage(), SQLServerException.generateStateCode(null,