use of java.sql.SQLFeatureNotSupportedException in project hive by apache.
the class HiveQueryResultSet method next.
/**
* Moves the cursor down one row from its current position.
*
* @see java.sql.ResultSet#next()
* @throws SQLException
* if a database access error occurs.
*/
public boolean next() throws SQLException {
if (isClosed) {
throw new SQLException("Resultset is closed");
}
if (emptyResultSet || (maxRows > 0 && rowsFetched >= maxRows)) {
return false;
}
/**
* Poll on the operation status, till the operation is complete.
* We need to wait only for HiveStatement to complete.
* HiveDatabaseMetaData which also uses this ResultSet returns only after the RPC is complete.
*/
if ((statement != null) && (statement instanceof HiveStatement)) {
((HiveStatement) statement).waitForOperationToComplete();
}
try {
TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT;
if (fetchFirst) {
// If we are asked to start from begining, clear the current fetched resultset
orientation = TFetchOrientation.FETCH_FIRST;
fetchedRows = null;
fetchedRowsItr = null;
fetchFirst = false;
}
if (fetchedRows == null || !fetchedRowsItr.hasNext()) {
TFetchResultsReq fetchReq = new TFetchResultsReq(stmtHandle, orientation, fetchSize);
TFetchResultsResp fetchResp;
fetchResp = client.FetchResults(fetchReq);
Utils.verifySuccessWithInfo(fetchResp.getStatus());
TRowSet results = fetchResp.getResults();
fetchedRows = RowSetFactory.create(results, protocol);
fetchedRowsItr = fetchedRows.iterator();
}
if (fetchedRowsItr.hasNext()) {
row = fetchedRowsItr.next();
} else {
return false;
}
rowsFetched++;
} catch (SQLException eS) {
throw eS;
} catch (Exception ex) {
ex.printStackTrace();
throw new SQLException("Error retrieving next row", ex);
}
// NOTE: fetchOne doesn't throw new SQLFeatureNotSupportedException("Method not supported").
return true;
}
use of java.sql.SQLFeatureNotSupportedException in project cobar by alibaba.
the class ServerRouter method validateAST.
private static void validateAST(SQLStatement ast, TableConfig tc, RuleConfig rule, PartitionKeyVisitor visitor) throws SQLNonTransientException {
if (ast instanceof DMLUpdateStatement) {
List<Identifier> columns = null;
List<String> ruleCols = rule.getColumns();
DMLUpdateStatement update = (DMLUpdateStatement) ast;
for (Pair<Identifier, Expression> pair : update.getValues()) {
for (String ruleCol : ruleCols) {
if (equals(pair.getKey().getIdTextUpUnescape(), ruleCol)) {
if (columns == null) {
columns = new ArrayList<Identifier>(ruleCols.size());
}
columns.add(pair.getKey());
}
}
}
if (columns == null) {
return;
}
Map<String, String> alias = visitor.getTableAlias();
for (Identifier column : columns) {
String table = column.getLevelUnescapeUpName(2);
table = alias.get(table);
if (table != null && table.equals(tc.getName())) {
throw new SQLFeatureNotSupportedException("partition key cannot be changed");
}
}
}
}
use of java.sql.SQLFeatureNotSupportedException in project druid by alibaba.
the class DruidPooledCallableStatementTest method test_getObject_1.
public void test_getObject_1() throws Exception {
Connection conn = dataSource.getConnection();
DruidPooledCallableStatement stmt = (DruidPooledCallableStatement) conn.prepareCall("select 1");
stmt.execute();
Assert.assertEquals(0, dataSource.getErrorCount());
Exception error = null;
try {
stmt.getObject("1", String.class);
} catch (SQLFeatureNotSupportedException e) {
error = e;
}
Assert.assertNotNull(error);
Assert.assertEquals(0, dataSource.getErrorCount());
stmt.close();
conn.close();
Assert.assertEquals(1, dataSource.getPoolingCount());
}
use of java.sql.SQLFeatureNotSupportedException in project druid by alibaba.
the class DruidPooledResultSetTest method test_notSupport_1.
public void test_notSupport_1() throws Exception {
String sql = "select ?";
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, "xxx");
DruidPooledResultSet rs = (DruidPooledResultSet) stmt.executeQuery();
Exception error = null;
try {
rs.getObject("1", String.class);
} catch (SQLFeatureNotSupportedException e) {
error = e;
}
Assert.assertNotNull(error);
rs.close();
conn.close();
}
use of java.sql.SQLFeatureNotSupportedException in project druid by alibaba.
the class DruidPooledResultSetTest method test_notSupport.
public void test_notSupport() throws Exception {
String sql = "select ?";
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, "xxx");
DruidPooledResultSet rs = (DruidPooledResultSet) stmt.executeQuery();
Exception error = null;
try {
rs.getObject(1, String.class);
} catch (SQLFeatureNotSupportedException e) {
error = e;
}
Assert.assertNotNull(error);
rs.close();
conn.close();
}
Aggregations