Index: jdbc/src/test/org/apache/hive/jdbc/TestUtils.java =================================================================== --- jdbc/src/test/org/apache/hive/jdbc/TestUtils.java (revision 0) +++ jdbc/src/test/org/apache/hive/jdbc/TestUtils.java (revision 0) @@ -0,0 +1,54 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hive.jdbc; + +import java.sql.SQLException; + +import org.apache.hive.service.cli.thrift.TStatus; +import org.apache.hive.service.cli.thrift.TStatusCode; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class TestUtils extends TestCase { + + public void testVerifySuccess() { + TStatus status = new TStatus(); + + // Test successful cases + status.setStatusCode(TStatusCode.SUCCESS_STATUS); + try { + Utils.verifySuccess(status); + status.setStatusCode(TStatusCode.SUCCESS_WITH_INFO_STATUS); + Utils.verifySuccess(status); + } catch (SQLException e) { + fail("SQL exception should not be thrown for successful status"); + } + + // Test failure cases + status.setStatusCode(TStatusCode.ERROR_STATUS); + status.setErrorMessage("Test message for exception"); + try { + Utils.verifySuccess(status); + fail("Exception will be thrown for a failed status code"); + } catch (SQLException e) { + Assert.assertEquals("Test message for exception", e.getMessage()); + } + } +} Index: jdbc/src/java/org/apache/hive/jdbc/Utils.java =================================================================== --- jdbc/src/java/org/apache/hive/jdbc/Utils.java (revision 1478471) +++ jdbc/src/java/org/apache/hive/jdbc/Utils.java (working copy) @@ -145,22 +145,12 @@ } // Verify success or success_with_info status, else throw SQLException - public static void verifySuccessWithInfo(TStatus status) throws SQLException { - verifySuccess(status, true); - } - - // Verify success status, else throw SQLException public static void verifySuccess(TStatus status) throws SQLException { - verifySuccess(status, false); - } - - // Verify success and optionally with_info status, else throw SQLException - public static void verifySuccess(TStatus status, boolean withInfo) throws SQLException { - if ((status.getStatusCode() != TStatusCode.SUCCESS_STATUS) && - (withInfo && (status.getStatusCode() != TStatusCode.SUCCESS_WITH_INFO_STATUS))) { + if (status.getStatusCode() != TStatusCode.SUCCESS_STATUS && + status.getStatusCode() != TStatusCode.SUCCESS_WITH_INFO_STATUS) { throw new SQLException(status.getErrorMessage(), - status.getSqlState(), status.getErrorCode()); - } + status.getSqlState(), status.getErrorCode()); + } } /** Index: jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java =================================================================== --- jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java (revision 1478471) +++ jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java (working copy) @@ -184,7 +184,7 @@ TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql); execReq.setConfOverlay(sessConf); TExecuteStatementResp execResp = client.ExecuteStatement(execReq); - Utils.verifySuccessWithInfo(execResp.getStatus()); + Utils.verifySuccess(execResp.getStatus()); stmtHandle = execResp.getOperationHandle(); } catch (SQLException es) { throw es; Index: jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java =================================================================== --- jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java (revision 1478471) +++ jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java (working copy) @@ -104,7 +104,7 @@ cancelReq.setOperationHandle(stmtHandle); try { TCancelOperationResp cancelResp = client.CancelOperation(cancelReq); - Utils.verifySuccessWithInfo(cancelResp.getStatus()); + Utils.verifySuccess(cancelResp.getStatus()); } catch (SQLException e) { throw e; } catch (Exception e) { @@ -138,7 +138,7 @@ TCloseOperationReq closeReq = new TCloseOperationReq(); closeReq.setOperationHandle(stmtHandle); TCloseOperationResp closeResp = client.CloseOperation(closeReq); - Utils.verifySuccessWithInfo(closeResp.getStatus()); + Utils.verifySuccess(closeResp.getStatus()); } } catch (SQLException e) { throw e; @@ -179,7 +179,7 @@ TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql); execReq.setConfOverlay(sessConf); TExecuteStatementResp execResp = client.ExecuteStatement(execReq); - Utils.verifySuccessWithInfo(execResp.getStatus()); + Utils.verifySuccess(execResp.getStatus()); stmtHandle = execResp.getOperationHandle(); } catch (SQLException eS) { throw eS; Index: jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java =================================================================== --- jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java (revision 1478471) +++ jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java (working copy) @@ -223,7 +223,7 @@ TFetchResultsReq fetchReq = new TFetchResultsReq(stmtHandle, TFetchOrientation.FETCH_NEXT, fetchSize); TFetchResultsResp fetchResp = client.FetchResults(fetchReq); - Utils.verifySuccessWithInfo(fetchResp.getStatus()); + Utils.verifySuccess(fetchResp.getStatus()); fetchedRows = fetchResp.getResults().getRows(); fetchedRowsItr = fetchedRows.iterator(); }