Skip to content

Commit

Permalink
Read password from file for Beeline (apache#582)
Browse files Browse the repository at this point in the history
* Read password from file for Beeline

Activate option -w password file for beeline for kylin.

Example:
https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients
% beeline -u jdbc:hive2://localhost:10000/default -n scott -w password_file
  • Loading branch information
dekarlab authored and nichunen committed May 5, 2019
1 parent 962629a commit aab2b90
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

package org.apache.kylin.source.hive;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
Expand Down Expand Up @@ -60,6 +65,17 @@ public BeelineHiveClient(String beelineParams) {
if ("-p".equals(splits[i])) {
password = stripQuotes(splits[i + 1]);
}
if ("-w".equals(splits[i])) {
File file = new File(splits[i + 1]);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
password = br.readLine();
br.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Properties jdbcProperties = SourceConfigurationUtil.loadHiveJDBCProperties();
jdbcProperties.put(HIVE_AUTH_PASSWD, password);
Expand Down

0 comments on commit aab2b90

Please sign in to comment.