1. Description
Hadoop is a popular distributed computing solution, and Hive is a Hadoop-based data analysis tool. In general, the operation of Hive is done through the CLI, that is, the Linux console, but in essence, each connection is stored in a meta-data, the difference between the different, such a pattern used to do some testing is appropriate, not suitable for product development and application.
Therefore, the way that hive's JDBC connection is generated. This article describes the Hadoop, hive database connection method in the report development tool Finereport.
2. Steps
Hive provides the JDBC driver so that we can connect to hive and make SQL statement queries for some kind of relational database, first we need to copy these drivers to the report project, then establish the connection, and finally the data query through the connection.
2.1 Copy jar package to FR project
copy Hadoop-common.jar from Hadoop to report engineering Appname/web-inf/lib under;
Hive-exec.jar in Hive, Hive-jdbc.jar, Hive-metastore.jar, Hive-service.jar, Libfb303.jar, Log4j.jar, Slf4j-api.jar, Slf4j-log4j12.jar Copy to the report project appname/web-inf/lib .
2.2 Configuring Data Connections
start the designer, open server > Define Data Connections , create a new JDBC connection.
Prior to Hive 0.11.0, only the Hiveserver service is available, and the Hiveserver service must be opened on a hive-installed server before the program can operate hive. Hiveserver itself has a lot of problems (such as security, concurrency, etc.); For these issues, the Hive0.11.0 version provides a whole new service: HiveServer2, a good solution to the security, concurrency, and other problems hiveserver exist, So let's describe the way Hiveserver and HiveServer2 configure data connections separately.
· Hiveserver
Database driver: Org.apache.hadoop.hive.jdbc.HiveDriver
URL: Jdbc:hive://localhost:10000/default
Note: The Hive service has a default port of 10000, modifies the port according to the actual situation, and currently supports only the default database name, which is supported by all hive.
Test the connection to indicate that the connection was successful.
650) this.width=650; "src=" http://img.blog.csdn.net/20151217092837142 "style=" border:none; "/>
· HiveServer2
Database driver: Org.apache.hive.jdbc.HiveDriver
URL: Jdbc:hive2://localhost:10000/default
Note: This connection mode only supports Hive0.11.0 and later versions.
650) this.width=650; "src=" http://img.blog.csdn.net/20151217092849645 "style=" border:none; "/>
Hadoop,hive Database Connectivity solution in Finereport