Am writing jdbc program to connect hive database. I want the username and password to give it in the connection url.
I don't know how to get the username and password using hive QL. Can anybody help me out??
Exception in thread "main" java.sql.SQLNonTransientConnectionException: [DataDirect][Hive JDBC Driver]A value was not specified for a required property: PASSWORD
at com.ddtek.jdbc.hivebase.ddcp.b(Unknown Source)
at com.ddtek.jdbc.hivebase.ddcp.a(Unknown Source)
at com.ddtek.jdbc.hivebase.ddco.b(Unknown Source)
at com.ddtek.jdbc.hivebase.ddco.a(Unknown Source)
at com.ddtek.jdbc.hive.HiveImplConnection.b(Unknown Source)
at com.ddtek.jdbc.hivebase.BaseConnection.b(Unknown Source)
at com.ddtek.jdbc.hivebase.BaseConnection.k(Unknown Source)
at com.ddtek.jdbc.hivebase.BaseConnection.b(Unknown Source)
at com.ddtek.jdbc.hivebase.BaseConnection.a(Unknown Source)
at com.ddtek.jdbc.hivebase.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at hivejdbcconnection.HiveJdbcConnection.main(HiveJdbcConnection.java:33)
Java Result: 1
To get hive username and password, go to
hive-site.xml
and search forjavax.jdo.option.ConnectionUserName
andjavax.jdo.option.ConnectionPassword
. The values of these properties are your hive username and password respectively.(Default values are
APP
andmine
for username and password which can be found inhive-default.xml
)In case, if you don't have such property in hive-site.xml. Then add these lines in
hive-site.xml
:Note: I have a database named hadoop in mysql for hive. Thats why the value for
javax.jdo.option.ConnectionURL
isjdbc:mysql://localhost:3306/hadoop
.After setting or finding your username and password, use it as follows:
Use your
hive database name
instead ofdefault
. Hope it helps!!!!hive default user name is hive
use the below connection string for hiveserver2
for hiveserver1 default is empty,hiveserver2 also works with empty username and password.
Driver name:
org.apache.hadoop.hive.jdbc.HiveDriver
Username and password are empty
read the link Connecting to Hive using Beeline