Skip to content

Commit

Permalink
javadoc fixes (#2363)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgreenbird authored Mar 25, 2024
1 parent c74a51e commit 9a13e5d
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,22 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,

/**
* Get Currently installed message handler on the connection
* @see {@link ISQLServerMessageHandler#messageHandler(ISQLServerMessage)}
* @return
*
* @see ISQLServerMessageHandler#messageHandler(ISQLServerMessage)
* @return ISQLServerMessageHandler
*/
ISQLServerMessageHandler getServerMessageHandler();

/**
* Set message handler on the connection
* @see {@link ISQLServerMessageHandler#messageHandler(ISQLServerMessage)}
*
* @param messageHandler
* message handler
*
* @see ISQLServerMessageHandler#messageHandler(ISQLServerMessage)
*/
ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler);

/**
* Returns the current flag for calcBigDecimalPrecision.
*
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

import java.sql.SQLException;

public interface ISQLServerMessage
{

/**
* Provides an interface SQLServerMessage
*/
public interface ISQLServerMessage {
/**
* Returns SQLServerError containing detailed info about SQL Server Message as received from SQL Server.
*
Expand Down Expand Up @@ -67,16 +70,18 @@ public interface ISQLServerMessage

/**
* Creates a SQLServerException or SQLServerWarning from this SQLServerMessage<br>
*
* @return
* <ul>
* <li>SQLServerException if it's a SQLServerError object</li>
* <li>SQLServerWarning if it's a SQLServerInfoMessage object</li>
* </ul>
* <ul>
* <li>SQLServerException if it's a SQLServerError object</li>
* <li>SQLServerWarning if it's a SQLServerInfoMessage object</li>
* </ul>
*/
public SQLException toSqlExceptionOrSqlWarning();

/**
* Check if this is a isErrorMessage
*
* @return true if it's an instance of SQLServerError
*/
public default boolean isErrorMessage() {
Expand All @@ -85,6 +90,7 @@ public default boolean isErrorMessage() {

/**
* Check if this is a SQLServerInfoMessage
*
* @return true if it's an instance of SQLServerInfoMessage
*/
public default boolean isInfoMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,99 +5,99 @@
package com.microsoft.sqlserver.jdbc;

/**
* You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server.
* You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server.
* Implementing ISQLServerMessageHandler in your own class for handling error messages can provide the following benefits:
* <ul>
* <li><b>"message feedback"</b><br>
* Display Server messages from a long running SQL Statement<br>
* Like <code>RAISERROR ('Progress message...', 0, 1) WITH NOWAIT</code><br>
* Or Status messages from a running backup...<br>
* </li>
* <li><b>"Universal" error logging</b><br>
* Your error-message handler can contain the logic for handling all error logging.
* </li>
* <li><b>"Universal" error handling</b><br>
* Error-handling logic can be placed in your error-message handler, instead of being repeated throughout your application.
* </li>
* <li><b>Remapping of error-message severity</b>, based on application requirements<br>
* Your error-message handler can contain logic for recognizing specific error messages, and downgrading or upgrading
* their severity based on application considerations rather than the severity rating of the server.
* For example, during a cleanup operation that deletes old rows, you might want to downgrade the severity of a
* message that a row does not exist. However, you may want to upgrade the severity in other circumstances.
* </li>
* <li><b>"message feedback"</b><br>
* Display Server messages from a long running SQL Statement<br>
* Like <code>RAISERROR ('Progress message...', 0, 1) WITH NOWAIT</code><br>
* Or Status messages from a running backup...<br>
* </li>
* <li><b>"Universal" error logging</b><br>
* Your error-message handler can contain the logic for handling all error logging.
* </li>
* <li><b>"Universal" error handling</b><br>
* Error-handling logic can be placed in your error-message handler, instead of being repeated throughout your application.
* </li>
* <li><b>Remapping of error-message severity</b>, based on application requirements<br>
* Your error-message handler can contain logic for recognizing specific error messages, and downgrading or upgrading
* their severity based on application considerations rather than the severity rating of the server.
* For example, during a cleanup operation that deletes old rows, you might want to downgrade the severity of a
* message that a row does not exist. However, you may want to upgrade the severity in other circumstances.
* </li>
* </ul>
* <p>
* For example code, see {@link #messageHandler(ISQLServerMessage)}
*/
public interface ISQLServerMessageHandler
{
public interface ISQLServerMessageHandler {
/**
* You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server.
* You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server.
* Implementing ISQLServerMessageHandler in your own class for handling error messages can provide the following benefits:
* <ul>
* <li><b>"message feedback"</b><br>
* Display Server messages from a long running SQL Statement<br>
* Like <code>RAISERROR ('Progress message...', 0, 1) WITH NOWAIT</code><br>
* Or Status messages from a running backup...<br>
* </li>
* <li><b>"Universal" error logging</b><br>
* Your error-message handler can contain the logic for handling all error logging.
* </li>
* <li><b>"Universal" error handling</b><br>
* Error-handling logic can be placed in your error-message handler, instead of being repeated throughout your application.
* </li>
* <li><b>Remapping of error-message severity</b>, based on application requirements<br>
* Your error-message handler can contain logic for recognizing specific error messages, and downgrading or upgrading
* their severity based on application considerations rather than the severity rating of the server.
* For example, during a cleanup operation that deletes old rows, you might want to downgrade the severity of a
* message that a row does not exist. However, you may want to upgrade the severity in other circumstances.
* </li>
* <li><b>"message feedback"</b><br>
* Display Server messages from a long running SQL Statement<br>
* Like <code>RAISERROR ('Progress message...', 0, 1) WITH NOWAIT</code><br>
* Or Status messages from a running backup...<br>
* </li>
* <li><b>"Universal" error logging</b><br>
* Your error-message handler can contain the logic for handling all error logging.
* </li>
* <li><b>"Universal" error handling</b><br>
* Error-handling logic can be placed in your error-message handler, instead of being repeated throughout your application.
* </li>
* <li><b>Remapping of error-message severity</b>, based on application requirements<br>
* Your error-message handler can contain logic for recognizing specific error messages, and downgrading or upgrading
* their severity based on application considerations rather than the severity rating of the server.
* For example, during a cleanup operation that deletes old rows, you might want to downgrade the severity of a
* message that a row does not exist. However, you may want to upgrade the severity in other circumstances.
* </li>
* </ul>
*
* Example code:
*
* <pre>
* public ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning)
* {
* ISQLServerMessage retObj = serverErrorOrWarning;
* public ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning) {
* ISQLServerMessage retObj = serverErrorOrWarning;
*
* if (serverErrorOrWarning.isErrorMessage()) {
* if (serverErrorOrWarning.isErrorMessage()) {
*
* // Downgrade: 2601 -- Cannot insert duplicate key row...
* if (2601 == serverErrorOrWarning.getErrorNumber()) {
* retObj = serverErrorOrWarning.getSQLServerMessage().toSQLServerInfoMessage();
* }
* // Downgrade: 2601 -- Cannot insert duplicate key row...
* if (2601 == serverErrorOrWarning.getErrorNumber()) {
* retObj = serverErrorOrWarning.getSQLServerMessage().toSQLServerInfoMessage();
* }
*
* // Discard: 3701 -- Cannot drop the table ...
* if (3701 == serverErrorOrWarning.getErrorNumber()) {
* retObj = null;
* }
* }
* // Discard: 3701 -- Cannot drop the table ...
* if (3701 == serverErrorOrWarning.getErrorNumber()) {
* retObj = null;
* }
* }
*
* return retObj;
* }
* return retObj;
* }
*
* </pre>
*
* @param serverErrorOrWarning
* @return
* <ul>
* <li><b>unchanged</b> same object as passed in.<br>
* The JDBC driver will works as if no message hander was installed<br>
* Possibly used for logging functionality<br>
* </li>
* <li><b>null</b><br>
* The JDBC driver will <i>discard</i> this message. No SQLException will be thrown
* </li>
* <li><b>SQLServerInfoMessage</b> object<br>
* Create a "SQL warning" from a input database error, and return it.
* This results in the warning being added to the warning-message chain.
* </li>
* <li><b>SQLServerError</b> object<br>
* If the originating message is a SQL warning (SQLServerInfoMessage object), messageHandler can evaluate
* the SQL warning as urgent and create and return a SQL exception (SQLServerError object)
* to be thrown once control is returned to the JDBC Driver.
* </li>
* </ul>
* server error or warning
* @return
* <ul>
* <li><b>unchanged</b> same object as passed in.<br>
* The JDBC driver will work as if no message hander was installed<br>
* Possibly used for logging functionality<br>
* </li>
* <li><b>null</b><br>
* The JDBC driver will <i>discard</i> this message. No SQLException will be thrown
* </li>
* <li><b>SQLServerInfoMessage</b> object<br>
* Create a "SQL warning" from a input database error, and return it.
* This results in the warning being added to the warning-message chain.
* </li>
* <li><b>SQLServerError</b> object<br>
* If the originating message is a SQL warning (SQLServerInfoMessage object), messageHandler can evaluate
* the SQL warning as urgent and create and return a SQL exception (SQLServerError object)
* to be thrown once control is returned to the JDBC Driver.
* </li>
* </ul>
*/
ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,21 @@ public void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)

}

/**
* Get expiry time
*
* @return expiry time
*/
public long getExpiryTime() {
return this.expiryTime;
}

/**
* Set expiry time
*
* @param expiryTime
* expiry time
*/
public void setExpiryTime(long expiryTime) {
this.expiryTime = expiryTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,22 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow
return isValid;
}

/**
* Sign column master key metadata
*
* @param masterKeyPath
* master key path
*
* @param allowEnclaveComputations
* flag whether to allow enclave computations
*
* @return
* column master key metadata
*
* @throws SQLServerException
* when an error occurs
*
*/
public byte[] signColumnMasterKeyMetadata(String masterKeyPath,
boolean allowEnclaveComputations) throws SQLServerException {
if (!allowEnclaveComputations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow
return isValid;
}

/**
* Sign column master key metadata
*
* @param masterKeyPath
* master key path
*
* @param allowEnclaveComputations
* flag whether to allow enclave computations
*
* @return
* column master key metadata
*
* @throws SQLServerException
* when an error occurs
*
*/
public byte[] signColumnMasterKeyMetadata(String masterKeyPath,
boolean allowEnclaveComputations) throws SQLServerException {
if (!allowEnclaveComputations)
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,9 @@ public void setIgnoreOffsetOnDateTimeOffsetConversion(boolean ignoreOffsetOnDate
this.ignoreOffsetOnDateTimeOffsetConversion = ignoreOffsetOnDateTimeOffsetConversion;
}

/**
* Flag to indicate whether the driver should calculate precision for BigDecimal inputs, as opposed to using the maximum allowed valued for precision (38).
*/
private boolean calcBigDecimalPrecision = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION
.getDefaultValue();

Expand Down Expand Up @@ -8521,31 +8524,28 @@ public String getIPAddressPreference() {
return activeConnectionProperties.getProperty(SQLServerDriverStringProperty.IPADDRESS_PREFERENCE.toString());
}



/** Message handler */
private transient ISQLServerMessageHandler serverMessageHandler;

/**
* Set current message handler
*
* @param messageHandler
* message handler
* @return The previously installed message handler (null if none)
*/
@Override
public ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler)
{
ISQLServerMessageHandler installedMessageHandler = this.serverMessageHandler;
this.serverMessageHandler = messageHandler;
public ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler) {
ISQLServerMessageHandler installedMessageHandler = this.serverMessageHandler;
this.serverMessageHandler = messageHandler;
return installedMessageHandler;
}
}

/**
* @return Get Currently installed message handler on the connection
*/
@Override
public ISQLServerMessageHandler getServerMessageHandler()
{
public ISQLServerMessageHandler getServerMessageHandler() {
return this.serverMessageHandler;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ private void checkClosed() throws SQLServerException {
// Use LinkedHashMap to force retrieve elements in order they were inserted
/** getColumns columns */
private LinkedHashMap<Integer, String> getColumnsDWColumns = null;

/** getTypes columns */
private LinkedHashMap<Integer, String> getTypesDWColumns = null;

/** getImportedKeys columns */
private volatile LinkedHashMap<Integer, String> getImportedKeysDWColumns;
private static final Lock LOCK = new ReentrantLock();
Expand Down
Loading

0 comments on commit 9a13e5d

Please sign in to comment.