====== Connections ======
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|hplsql-site.xml]] configuration file. The default connection profile is defined by [[configuration#hplsqlconndefault|hplsql.conn.default]] option:
hplsql.conn.default
hiveconn
===== Predefined Connections =====
[[configuration|hplsql-site.xml]] contains predefined connections for some databases:
* **hiveconn** - Embedded Hive JDBC Connection (not requiring a HiveServer)
hplsql.conn.hiveconn
org.apache.hadoop.hive.jdbc.HiveDriver;jdbc:hive://
* **hive2conn** - HiveServer2 JDBC Connection
hplsql.conn.hive2conn
org.apache.hive.jdbc.HiveDriver;jdbc:hive2://localhost:10000
* **db2conn** - IBM DB2 JDBC Connection
hplsql.conn.db2conn
com.ibm.db2.jcc.DB2Driver;jdbc:db2://localhost:50001/dbname;user;pwd
IBM DB2 connection
When using DB2 JDBC driver make sure //db2jcc4.jar// is specified in CLASSPATH.
* **tdconn** - Teradata JDBC Connection
hplsql.conn.tdconn
com.teradata.jdbc.TeraDriver;jdbc:teradata://host/database=name,logmech=ldap;usr;pwd
When using Teradata JDBC driver make sure //teradata-jdbc4-xx.xx.xx.jar//and //tdgssconfig.jar// (both .jars are required) are specified in CLASSPATH.
* **mysqlconn** - MySQL JDBC Connection
hplsql.conn.mysqlconn
com.mysql.jdbc.Driver;jdbc:mysql://localhost/test;user;password
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#hplsqlconndefault|hplsql.conn.default]] option.
===== Defining a New Connection =====
HPL/SQL allows you to define any connection profile. Just create a new parameter named //hplsql.conn.// and specify the connection details:
JDBC Driver;JDBC Connection String;User;Password
For example, to create a new connection //sales// that points to the //sales_db// database in MySQL add the following section to your [[configuration|hplsql-site.xml]] file:
hplsql.conn.sales
com.mysql.jdbc.Driver;jdbc:mysql://localhost/sales_db;paul;pwd
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 HPL/SQL scripts]].
~~NOTOC~~