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.

Impala Prepared Statement Exception when statement executed second time

Solved Go to solution

Impala Prepared Statement Exception when statement executed second time

New Contributor

Using the Impala JDBC driver, I'm getting an exception when trying to use a prepared statement more than once. The first execute works, and the second doesn't. Here's my code snippet:

 

PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement("select * from hbase_vm_customer where cas_id=?");
} catch (SQLException e) {
e.printStackTrace();
}

try {
stmt.setString( 1, "155304611");
ResultSet rs = stmt.executeQuery();
if( !rs.next() ) {
System.out.println( "missing row" );
}
else {
System.out.println( rs.getString(1) );
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}

try {
stmt.setString( 1, "155304612");
ResultSet rs = stmt.executeQuery();
if( !rs.next() ) {
System.out.println( "missing row for " );
}
else {
System.out.println( rs.getString(1) );
}
} catch (SQLException e) {
e.printStackTrace();
}

 

Here's the stack trace:

 

155304611
java.sql.SQLException: [JDBC Driver]Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.cloudera.impala.jdbc.common.SPreparedStatement.getInputParameterValues(SPreparedStatement.java:3313)
at com.cloudera.impala.jdbc.common.SPreparedStatement.getInputParameterValues(SPreparedStatement.java:3268)
at com.cloudera.impala.jdbc.common.SPreparedStatement.executeQuery(SPreparedStatement.java:1070)
at imptest.ImpExample.main(ImpExample.java:50)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
... 6 more

 

 

This is a query against an Hbase table, and

I'm using Cloudera_ImpalaJDBC4_2.5.5.1007 jdbc driver.

Any suggestions would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Impala Prepared Statement Exception when statement executed second time

New Contributor

I was able to switch to the Impala JDBC4 2.5.32 version of the driver and the prepared statement behavior is what I expect with that one.

1 REPLY 1
Highlighted

Re: Impala Prepared Statement Exception when statement executed second time

New Contributor

I was able to switch to the Impala JDBC4 2.5.32 version of the driver and the prepared statement behavior is what I expect with that one.