Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

use set command through Impala JDBC Driver

use set command through Impala JDBC Driver

Explorer

Dea all

 

I use java to access Impala through jdbc driver. According the following information

http://www.cloudera.com/documentation/archive/impala/2-x/2-0-x/topics/impala_query_options.html

 

In Impala 2.0 and later, you can set query options directly through the JDBC and ODBC interfaces by using the SET statement. Formerly, SET was only available as command within the impala-shell interpreter.

If I want to set REQUEST_POOL = root.default through JDBC in Java, how do I configure it ?

My Sample code as below

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

public class ClouderaImpalaJdbcExample
{

    // here is an example query based on one of the Hue Beeswax sample tables
    private static final String SQL_STATEMENT = "SELECT * FROM testload";
    
    private static final String CONNECTION_URL = "jdbc:impala://192.168.1.123:21050;AuthMech=3;UID=aaa;PWD=bbb";
    private static final String JDBC_DRIVER_NAME = "com.cloudera.impala.jdbc4.Driver";
    
    public static void main( String[] args )
    {

        System.out.println( "\n=============================================" );
        System.out.println( "Cloudera Impala JDBC Example" );
        System.out.println( "Using Connection URL: " + CONNECTION_URL );
        System.out.println( "Running Query: " + SQL_STATEMENT );
        
        Connection con = null;

        try
        {

            Class.forName( JDBC_DRIVER_NAME );

            con = DriverManager.getConnection( CONNECTION_URL);
            
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery( SQL_STATEMENT );

            System.out.println( "\n== Begin Query Results ======================" );

            // print the results to the console
            while ( rs.next() )
            {
                // the example query returns one String column
                System.out.print( rs.getString( "exg" ) + ":" );
//                System.out.println( rs.getString( "value" ) );
            }

            System.out.println( "== End Query Results =======================\n\n" );

        }
        catch ( SQLException e )
        {
            e.printStackTrace();
        }
        catch ( Exception e )
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                con.close();
            }
            catch ( Exception e )
            {
               
            }
        }
    }

}

 

1 REPLY 1

Re: use set command through Impala JDBC Driver

Explorer

Dear all 

 

I find it in the newest version of Impala JDBC Driver.

jdbc:impala://localhost:18000[/default2];AuthMech=3;
UID=cloudera;PWD=cloudera;MEM_LIMIT=1000000000;REQUEST_POOL=myPool
Don't have an account?
Coming from Hortonworks? Activate your account here