Package com.databricks.jdbc.common.util

## Class ValidationUtil

- java.lang.Object
- - com.databricks.jdbc.common.util.ValidationUtil

    public class ValidationUtil
    extends Object

### Constructor Summary

Constructors
`ValidationUtil()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `checkHTTPError​(org.apache.http.HttpResponse response)`
`static String` `checkHTTPErrorWithoutThrowingError​(org.apache.http.HttpResponse response)`
`static <T extends Number> void` `checkIfNonNegative​(T number, String fieldName)`
`static <T extends Number> void` `checkIfPositive​(T number, String fieldName)` Validates that a number is positive (greater than 0).
`static boolean` `isValidJdbcUrl​(String url)` Validates the JDBC URL.
`static void` `throwErrorIfNull​(String field, Object value)`
`static void` `throwErrorIfNull​(Map<String,​String> fields, String context)`
`static int` `validateAndParsePositiveInteger​(String value, String fieldName)` Parses a string to an integer and validates that it is positive (greater than 0).
`static void` `validateInputProperties​(Map<String,​String> parameters)` Validates all input properties for JDBC connection parameters.
`static void` `validateUidParameter​(Map<String,​String> parameters)` Validates the UID parameter in JDBC connection properties.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ValidationUtil

    public ValidationUtil()

### Method Detail

#### checkIfNonNegative

    public static <T extends Number> void checkIfNonNegative​(T number,
                                                             String fieldName)
                                                      throws DatabricksValidationException

Throws:
  `DatabricksValidationException`

#### checkIfPositive

    public static <T extends Number> void checkIfPositive​(T number,
                                                          String fieldName)
                                                   throws DatabricksValidationException

Validates that a number is positive (greater than 0).

Parameters:
  `number` - the number to validate
  `fieldName` - the name of the field being validated
Throws:
  `DatabricksValidationException` - if the number is not positive

#### validateAndParsePositiveInteger

    public static int validateAndParsePositiveInteger​(String value,
                                                      String fieldName)
                                               throws DatabricksValidationException

Parses a string to an integer and validates that it is positive (greater than 0).

Parameters:
  `value` - the string value to parse
  `fieldName` - the name of the field being validated
Returns:
  the parsed positive integer
Throws:
  `DatabricksValidationException` - if the value cannot be parsed or is not positive

#### throwErrorIfNull

    public static void throwErrorIfNull​(Map<String,​String> fields,
                                        String context)
                                 throws DatabricksValidationException

Throws:
  `DatabricksValidationException`

#### throwErrorIfNull

    public static void throwErrorIfNull​(String field,
                                        Object value)
                                 throws DatabricksValidationException

Throws:
  `DatabricksValidationException`

#### checkHTTPErrorWithoutThrowingError

    public static String checkHTTPErrorWithoutThrowingError​(org.apache.http.HttpResponse response)

#### checkHTTPError

    public static void checkHTTPError​(org.apache.http.HttpResponse response)
                               throws DatabricksHttpException,
                                      IOException

Throws:
  `DatabricksHttpException`
  `IOException`

#### isValidJdbcUrl

    public static boolean isValidJdbcUrl​(String url)

Validates the JDBC URL.

Parameters:
  `url` - JDBC URL
Returns:
  true if the URL is valid, false otherwise

#### validateInputProperties

    public static void validateInputProperties​(Map<String,​String> parameters)
                                        throws DatabricksValidationException

Validates all input properties for JDBC connection parameters. This method serves as a central validation entry point, consolidating all property validations in one place for better maintainability and extensibility.

Parameters:
  `parameters` - Map of JDBC connection parameters to validate
Throws:
  `DatabricksValidationException` - if any validation fails

#### validateUidParameter

    public static void validateUidParameter​(Map<String,​String> parameters)
                                     throws DatabricksValidationException

Validates the UID parameter in JDBC connection properties. UID must either be omitted or set to "token".

Parameters:
  `parameters` - Map of JDBC connection parameters
Throws:
  `DatabricksValidationException` - if UID validation fails