public class JDBCUtils {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static String url = "jdbc:hive2://192.168.0.109:10000/house";
private static String user = "";
private static String password = "";
static HiveStatement hiveStatement = null;
private JDBCUtils(){
}
static {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void SetName(String name){
try {
hiveStatement.setCursorName(name);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException{
return DriverManager.getConnection(url, user, password);
}
public static void free(ResultSet rs,Statement stmt, Connection conn){
try {
if(rs != null){
rs.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try{
if(stmt != null){
stmt.close();
}
} catch (SQLException e){
e.printStackTrace();
} finally {
try{
if(conn != null){
conn.close();
}
} catch (SQLException e){
e.printStackTrace();
}
}
}
}
public static void free(ResultSet rs,Statement stmt){
try{
if(rs != null){
rs.close();
}
}catch(SQLException e){
e.printStackTrace();
} finally {
try{
if(stmt != null){
stmt.close();
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
}
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static String url = "jdbc:hive2://192.168.0.109:10000/house";
private static String user = "";
private static String password = "";
static HiveStatement hiveStatement = null;
private JDBCUtils(){
}
static {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void SetName(String name){
try {
hiveStatement.setCursorName(name);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException{
return DriverManager.getConnection(url, user, password);
}
public static void free(ResultSet rs,Statement stmt, Connection conn){
try {
if(rs != null){
rs.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try{
if(stmt != null){
stmt.close();
}
} catch (SQLException e){
e.printStackTrace();
} finally {
try{
if(conn != null){
conn.close();
}
} catch (SQLException e){
e.printStackTrace();
}
}
}
}
public static void free(ResultSet rs,Statement stmt){
try{
if(rs != null){
rs.close();
}
}catch(SQLException e){
e.printStackTrace();
} finally {
try{
if(stmt != null){
stmt.close();
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
}