Review Board 1.7.22


HIVE-4406 - Missing "/" or "/<dbname>" in hs2 jdbc uri switches mode to embedded mode

Review Request #10859 - Created April 30, 2013 and updated

Anandha L Ranganahan
Reviewers
hive
hive
https://issues.apache.org/jira/browse/HIVE-4406 

Attaching patch for review

 

Diff revision 2 (Latest)

1 2
1 2

  1. /trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java: Loading...
  2. /trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java: Loading...
/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java
Revision 1469709 New Change
[20] 187 lines
[+20] [+] public static JdbcConnectionParams parseURL(String uri) throws IllegalArgumentException {
188
    // Don't parse URL with no other configuration.
188
    // Don't parse URL with no other configuration.
189
    if (uri.equalsIgnoreCase(URL_PREFIX)) {
189
    if (uri.equalsIgnoreCase(URL_PREFIX)) {
190
      connParams.setEmbeddedMode(true);
190
      connParams.setEmbeddedMode(true);
191
      return connParams;
191
      return connParams;
192
    }
192
    }

    
   
193

   
193
    URI jdbcURI = URI.create(uri.substring(URI_JDBC_PREFIX.length()));
194
    URI jdbcURI = URI.create(uri.substring(URI_JDBC_PREFIX.length()));
194

    
   
195

   

    
   
196
    // If the url format contains like this, then condition will get execute.

    
   
197
    // jdbc:hive2://localhost:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM

    
   
198
    if((jdbcURI.getPath().equals("")) && (jdbcURI.getHost()==null)){

    
   
199
       throw new IllegalArgumentException("Bad URL format and it should be in the format of jdbc:hive2://<hostame>:<port>/<DB_name>");

    
   
200
    }

    
   
201

   
195
    connParams.setHost(jdbcURI.getHost());
202
    connParams.setHost(jdbcURI.getHost());
196
    if (connParams.getHost() == null) {
203
    if (connParams.getHost() == null) {
197
      connParams.setEmbeddedMode(true);
204
      connParams.setEmbeddedMode(true);
198
    } else {
205
    } else {
199
      int port = jdbcURI.getPort();
206
      int port = jdbcURI.getPort();
[+20] [20] 55 lines
/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
Revision 1469709 New Change
 
  1. /trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java: Loading...
  2. /trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java: Loading...