org.apache.hive.jdbc

## Class Utils

- java.lang.Object
- - org.apache.hive.jdbc.Utils

    public class Utils
    extends Object

### Nested Class Summary

Nested Classes
`static class` `Utils.JdbcConnectionParams`

### Field Summary

Fields
`static String` `URL_PREFIX` The required prefix for the connection URL.

### Constructor Summary

Constructors
Constructor and Description
`Utils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static Utils.JdbcConnectionParams` `extractURLComponents(String uri, Properties info)` This method handles the base parsing of the given jdbc uri.
`static String` `getCanonicalHostName(String hostName)` Method to get canonical-ized hostname, given a hostname (possibly a CNAME).
`static String` `getPassword(Map<String,String> confMap, String key)` Method to get the password from the configuration map if available.
`static String` `parsePropertyFromUrl(String url, String key)`
`static Utils.JdbcConnectionParams` `parseURL(String uri)`
`static Utils.JdbcConnectionParams` `parseURL(String uri, Properties info)` Parse JDBC connection URL The new format of the URL is: jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list where the optional sess, conf and var lists are semicolon separated <key>=<val> pairs.

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

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

### Field Detail

#### URL_PREFIX

    public static final String URL_PREFIX

The required prefix for the connection URL.

See Also:
  Constant Field Values

### Constructor Detail

#### Utils

    public Utils()

### Method Detail

#### parseURL

    public static Utils.JdbcConnectionParams parseURL(String uri)
                                               throws JdbcUriParseException,
                                                      SQLException,
                                                      ZooKeeperHiveClientException

Throws:
  `JdbcUriParseException`
  `SQLException`
  `ZooKeeperHiveClientException`

#### parseURL

    public static Utils.JdbcConnectionParams parseURL(String uri,
                                                      Properties info)
                                               throws JdbcUriParseException,
                                                      SQLException,
                                                      ZooKeeperHiveClientException

Parse JDBC connection URL The new format of the URL is: jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list where the optional sess, conf and var lists are semicolon separated <key>=<val> pairs. For utilizing dynamic service discovery with HiveServer2 multiple comma separated host:port pairs can be specified as shown above. The JDBC driver resolves the list of uris and picks a specific server instance to connect to. Currently, dynamic service discovery using ZooKeeper is supported, in which case the host:port pairs represent a ZooKeeper ensemble. As before, if the host/port is not specified, it the driver runs an embedded hive. examples - jdbc:hive2://ubuntu:11000/db2?hive.cli.conf.printheader=true;hive.exec.mode.local.auto.inputbytes.max=9999#stab=salesTable;icol=customerID jdbc:hive2://?hive.cli.conf.printheader=true;hive.exec.mode.local.auto.inputbytes.max=9999#stab=salesTable;icol=customerID jdbc:hive2://ubuntu:11000/db2;user=foo;password=bar Connect to http://server:10001/hs2, with specified basicAuth credentials and initial database: jdbc:hive2://server:10001/db;user=foo;password=bar?hive.server2.transport.mode=http;hive.server2.thrift.http.path=hs2

Parameters:
  `uri` -
Returns:
Throws:
  `SQLException`
  `JdbcUriParseException`
  `ZooKeeperHiveClientException`

#### extractURLComponents

    public static Utils.JdbcConnectionParams extractURLComponents(String uri,
                                                                  Properties info)
                                                           throws JdbcUriParseException

This method handles the base parsing of the given jdbc uri. Some of JdbcConnectionParams returned from this method are updated if ZooKeeper is used for service discovery

Parameters:
  `uri` -
  `info` -
Returns:
Throws:
  `JdbcUriParseException`

#### parsePropertyFromUrl

    public static String parsePropertyFromUrl(String url,
                                              String key)

#### getCanonicalHostName

    public static String getCanonicalHostName(String hostName)

Method to get canonical-ized hostname, given a hostname (possibly a CNAME). This should allow for service-principals to use simplified CNAMEs.

Parameters:
  `hostName` - The hostname to be canonical-ized.
Returns:
  Given a CNAME, the canonical-ized hostname is returned. If not found, the original hostname is returned.

#### getPassword

    public static String getPassword(Map<String,String> confMap,
                                     String key)

Method to get the password from the configuration map if available. Otherwise, get it from the credential provider

Parameters:
  `confMap` - configuration map
  `key` - param
Returns:
  password