Skip to content

Commit

Permalink
javadocs (#2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgreenbird authored Nov 7, 2024
1 parent ffa5e1f commit 362d3a4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
@FunctionalInterface
public interface ReconnectListener {

/**
* called before reconnect
*/
void beforeReconnect();

}
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,9 @@ public void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision) {
this.calcBigDecimalPrecision = calcBigDecimalPrecision;
}

/**
* Retry exec
*/
private String retryExec = SQLServerDriverStringProperty.RETRY_EXEC.getDefaultValue();

/**
Expand Down Expand Up @@ -1783,10 +1786,22 @@ SQLServerPooledConnection getPooledConnectionParent() {
*/
private List<ReconnectListener> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> bcOperationColumnList = null;

/**
* Bulkcopy operation value list
*/
private ArrayList<String> bcOperationValueList = null;

/** Returns the prepared statement SQL */
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
*
*/
public enum SQLServerSortOrder {
/** ascending order */
ASCENDING(0),
/** descending order */
DESCENDING(1),
/** unspecified order */
UNSPECIFIED(-1);

final int value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 362d3a4

Please sign in to comment.