You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

JDBC Add Batch로 멀티 쿼리를 실행하려고 그랬으나 지원하지 않는다는 것을 확인함. → 쿼리문을 만들어서 Impala Shell에서 처리를 하는 것이 가장 적합한 것으로 보임.

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SpringJdbcTest {

    public static void main(String[] args) throws SQLException {
        com.cloudera.impala.jdbc.DataSource ds = new com.cloudera.impala.jdbc.DataSource();
        ds.setURL("jdbc:impala://10.0.1.71:21050/default");
        ds.setUserID("impala");
        ds.setPassword("impala");
        ds.setCustomProperty("AuthMech", "0");

        Connection conn = ds.getConnection();
        Statement stmt = conn.createStatement();

        stmt.addBatch("SET SYNC_DDL=1");
        stmt.addBatch("CREATE TABLE STUDENT(STUDENT_ID STRING) PARTITION BY HASH (STUDENT_ID) PARTITIONS 10 STORED AS KUDU");
        stmt.addBatch("REFRESH STUDENT");
        stmt.addBatch("INSERT INTO STUDENT (STUDENT_ID) VALUES('S101')");
        stmt.addBatch("INSERT INTO STUDENT (STUDENT_ID) VALUES('S102')");
        stmt.addBatch("INSERT INTO STUDENT (STUDENT_ID) VALUES('S103')");
        stmt.addBatch("INSERT INTO STUDENT (STUDENT_ID) VALUES('S104')");

        stmt.executeBatch();

        ResultSet rs = stmt.executeQuery("SELECT * FROM STUDENT");
        while (rs.next()) {
            System.out.println(rs.getString(0));
        }

        stmt.close();
        conn.close();
    }

}

상기 코드를 실행하면 다음과 같이 에러 메시지가 출력됨

Exception in thread "main" java.sql.SQLException: Error message not found: NOT_IMPLEMENTED. Can't find resource for bundle java.util.PropertyResourceBundle, key NOT_IMPLEMENTED
	at com.cloudera.impala.hivecommon.dataengine.HiveJDBCDataEngine.prepareBatch(Unknown Source)
	at com.cloudera.impala.jdbc.common.SStatement.executeAnyBatch(Unknown Source)
	at com.cloudera.impala.jdbc.common.BaseStatement.executeBatch(Unknown Source)
Caused by: com.cloudera.impala.support.exceptions.GeneralException: Error message not found: NOT_IMPLEMENTED. Can't find resource for bundle java.util.PropertyResourceBundle, key NOT_IMPLEMENTED
	... 3 more


  • No labels