Created 09-07-2018 06:39 AM
Hello,
I have 4 node HDPcluster .in that second node I installed Hiveserver2 and apache lamp server.
What are all the configurations should I give for thrift PHP and Hive. I want to know the prerequisites for thrift with hive and steps to connect hive and php
Created 09-07-2018 10:36 AM
@Hariprasanth Madhavan You can connect via ODBC to Query HiveServer2.
ODBC Driver can be downloaded from: https://hortonworks.com/downloads/ -> HDP Addons
Created 09-07-2018 10:36 AM
@Hariprasanth Madhavan You can connect via ODBC to Query HiveServer2.
ODBC Driver can be downloaded from: https://hortonworks.com/downloads/ -> HDP Addons
Created 09-10-2018 12:05 PM
Thank you,
Can you refer me a configuration and package details for ODBC Connectivity? give me an Example Code for the hive and PHP ODBC connectivity.
I referred this link also https://cwiki.apache.org/confluence/display/Hive/HiveODBC but, I can't able to connect with Hive Properly.
Created on 09-17-2018 09:26 PM - edited 08-18-2019 01:21 AM
Here is the sample code which may help you.
<html> <body> <?php $conn=odbc_connect('TestODBC','hive',''); if (!$conn){ exit("Connection to the database Failed: " . $conn); } $sql="show databases"; $resultSet=odbc_exec($conn, $sql); if (!$resultSet){ exit("Error!");} echo "<table><tr>"; echo "<th>Database Name</th>"; while (odbc_fetch_row($resultSet)) { $dbName=odbc_result($resultSet,"database_name"); echo "<tr><td>$dbName</td></tr>"; } odbc_close($conn); echo "</table>"; ?> </body> </html>
Note: I do not have any authentication metod set for Hive, so I have used AuthMEth=2 in my odbc.ini file as below.
[TestODBC] Description=Hortonworks Hive Driver=/usr/lib/hive/lib/native/Linux-amd64-64/libhortonworkshiveodbc64.so Host=HiveServer2Hotname PORT=10000 schema=default HiveServerType=2 AuthMech=2 ThriftTransport=0
Below is Sample Output
Created 09-18-2018 05:28 AM
Please mark the answer, if you see it correct 🙂