com.github.panhongan.util.hive.HiveUtil Maven / Gradle / Ivy
package com.github.panhongan.util.hive;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.panhongan.util.conf.Config;
import com.github.panhongan.util.sql.SqlUtil;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class HiveUtil {
private static final Logger logger = LoggerFactory.getLogger(HiveUtil.class);
private static final String HIVE_DRIVER = "org.apache.hadoop.hive.jdbc.HiveDriver";
private static final String SOURCE_TYPE = "hive";
public static HiveSession createHiveSession(String hive_conf_file) throws SQLException {
Config conf = new Config();
conf.parse(hive_conf_file);
return new HiveSession(SqlUtil.createConnection(conf));
}
public static HiveSession createHiveSession(Config conf) throws SQLException {
return new HiveSession(SqlUtil.createConnection(conf));
}
public static void closeHiveSession(HiveSession session) {
if (session != null) {
session.close();
}
}
}