User Tools

Site Tools


Sidebar

HPL/SQL is included to Apache Hive since version 2.0

connections

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== Connections - HPL/SQL Reference ====== HPL/SQL allows you to [[multiple-databases|work with multiple databases]] in a single HPL/SQL script. ===== Configuring Connections ===== Connection information is stored in [[configuration|plhql-site.xml]] configuration file. The default connection profile is defined by [[configuration#plhqlconndefault|plhql.conn.default]] option: <HTML> <property> <name>plhql.conn.default</name> <value>hiveconn</value> </property> </HTML> ===== Predefined Connections ===== [[configuration|plhql-site.xml]] contains predefined connections for some databases: * **hiveconn** - Embedded Hive JDBC Connection (not requiring a HiveServer) <HTML> <property> <name>plhql.conn.hiveconn</name> <value>org.apache.hadoop.hive.jdbc.HiveDriver;jdbc:hive://</value> </property> </HTML> * **hive2conn** - HiveServer2 JDBC Connection <HTML> <property> <name>plhql.conn.hive2conn</name> <value>org.apache.hive.jdbc.HiveDriver;jdbc:hive2://localhost:10000</value> </property> </HTML> * **db2conn** - IBM DB2 JDBC Connection <HTML> <property> <name>plhql.conn.db2conn</name> <value>com.ibm.db2.jcc.DB2Driver;jdbc:db2://localhost:50001/dbname;user;pwd</value> <description>IBM DB2 connection</description> </property> </HTML> When using DB2 JDBC driver make sure //db2jcc4.jar// is specified in CLASSPATH. * **tdconn** - Teradata JDBC Connection <HTML> <property> <name>plhql.conn.tdconn</name> <value> com.teradata.jdbc.TeraDriver;jdbc:teradata://host/database=name,logmech=ldap;usr;pwd </value> </property> </HTML> When using Teradata JDBC driver make sure //teradata-jdbc4-xx.xx.xx.jar//and //tdgssconfig.jar// (both .jars required) are specified in CLASSPATH. * **mysqlconn** - MySQL JDBC Connection <HTML> <property> <name>plhql.conn.mysqlconn</name> <value>com.mysql.jdbc.Driver;jdbc:mysql://localhost/test;user;password</value> </property> </HTML> When using MySQL JDBC driver make sure //mysql-connector-java-x.x.xx-bin.jar// is specified in CLASSPATH. You can modify these connection profiles and specify appropriate connection details. Set the default connection profile using the [[configuration#plhqlconndefault|plhql.conn.default]] option. ===== Defining a New Connection ===== PL/HQL allows you to define any connection profile. Just create a new parameter named //plhql.conn.<your_connection_name>// and specify the connection details: <HTML> <value>JDBC Driver;JDBC Connection String;User;Password</value> </HTML> For example, to create a new connection //sales// that points to the //sales_db// database in MySQL add the following section to your [[configuration|plhql-site.xml]] file: <HTML> <property> <name>plhql.conn.sales</name> <value>com.mysql.jdbc.Driver;jdbc:mysql://localhost/sales_db;paul;pwd</value> </property> </HTML> Read your JDBC driver documentation how to properly specify the connection string and available options. Once you configured the connections, read how to [[multiple-databases|use them in PL/HQL scripts]]. ~~NOTOC~~