Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Who agreed with this solution

avatar
Super Collaborator

Hi,

 

Maybe you could share the java source code doing the connection ?

Here is a really small working sample :

 

 

public class ManageHive {

private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static Logger logger = Logger.getLogger(ManageHive.class);

public static Connection getConnection(LoadProperties prop, String user) throws ClassNotFoundException, SQLException {

String hiveJdbc = prop.getPropertyByName("hive_jdbc");

try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw e;
}
Connection conn2 = DriverManager.getConnection(hiveJdbc+"/extraction", user, "");
return conn2;
}

public static void execSql(LoadProperties prop, String user, String sql) throws SQLException, ClassNotFoundException {

Connection maConn = getConnection(prop,user);
Statement stmt = maConn.createStatement();

int result = stmt.executeUpdate(sql);
if ( result == Statement.EXECUTE_FAILED ) {
throw new SQLException("Erreur d'execution.");
}
}
}

 

 

 

View solution in original post

Who agreed with this solution