use of org.apache.drill.exec.proto.UserProtos.CreatePreparedStatementResp in project drill by axbaretto.
the class DrillJdbc41Factory method newServerPreparedStatement.
private DrillJdbc41PreparedStatement newServerPreparedStatement(DrillConnectionImpl connection, StatementHandle h, Meta.Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
String sql = signature.sql;
try {
DrillRpcFuture<CreatePreparedStatementResp> respFuture = connection.getClient().createPreparedStatement(signature.sql);
CreatePreparedStatementResp resp;
try {
resp = respFuture.get();
} catch (InterruptedException e) {
// Preserve evidence that the interruption occurred so that code higher up
// on the call stack can learn of the interruption and respond to it if it
// wants to.
Thread.currentThread().interrupt();
throw new SQLException("Interrupted", e);
}
final RequestStatus status = resp.getStatus();
if (status != RequestStatus.OK) {
final String errMsgFromServer = resp.getError() != null ? resp.getError().getMessage() : "";
if (status == RequestStatus.TIMEOUT) {
logger.error("Request timed out to create prepare statement: {}", errMsgFromServer);
throw new SQLTimeoutException("Failed to create prepared statement: " + errMsgFromServer);
}
if (status == RequestStatus.FAILED) {
logger.error("Failed to create prepared statement: {}", errMsgFromServer);
throw new SQLException("Failed to create prepared statement: " + errMsgFromServer);
}
logger.error("Failed to create prepared statement. Unknown status: {}, Error: {}", status, errMsgFromServer);
throw new SQLException(String.format("Failed to create prepared statement. Unknown status: %s, Error: %s", status, errMsgFromServer));
}
return new DrillJdbc41PreparedStatement(connection, h, signature, resp.getPreparedStatement(), resultSetType, resultSetConcurrency, resultSetHoldability);
} catch (SQLException e) {
throw e;
} catch (RuntimeException e) {
throw Helper.INSTANCE.createException("Error while preparing statement [" + sql + "]", e);
} catch (Exception e) {
throw Helper.INSTANCE.createException("Error while preparing statement [" + sql + "]", e);
}
}
use of org.apache.drill.exec.proto.UserProtos.CreatePreparedStatementResp in project drill by apache.
the class DrillJdbc41Factory method newServerPreparedStatement.
private DrillJdbc41PreparedStatement newServerPreparedStatement(DrillConnectionImpl connection, StatementHandle h, Meta.Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
String sql = signature.sql;
try {
DrillRpcFuture<CreatePreparedStatementResp> respFuture = connection.getClient().createPreparedStatement(signature.sql);
CreatePreparedStatementResp resp;
try {
resp = respFuture.get();
} catch (InterruptedException e) {
// Preserve evidence that the interruption occurred so that code higher up
// on the call stack can learn of the interruption and respond to it if it
// wants to.
Thread.currentThread().interrupt();
throw new SQLException("Interrupted", e);
}
final RequestStatus status = resp.getStatus();
if (status != RequestStatus.OK) {
final String errMsgFromServer = resp.getError() != null ? resp.getError().getMessage() : "";
if (status == RequestStatus.TIMEOUT) {
logger.error("Request timed out to create prepare statement: {}", errMsgFromServer);
throw new SQLTimeoutException("Failed to create prepared statement: " + errMsgFromServer);
}
if (status == RequestStatus.FAILED) {
logger.error("Failed to create prepared statement: {}", errMsgFromServer);
throw new SQLException("Failed to create prepared statement: " + errMsgFromServer);
}
logger.error("Failed to create prepared statement. Unknown status: {}, Error: {}", status, errMsgFromServer);
throw new SQLException(String.format("Failed to create prepared statement. Unknown status: %s, Error: %s", status, errMsgFromServer));
}
return new DrillJdbc41PreparedStatement(connection, h, signature, resp.getPreparedStatement(), resultSetType, resultSetConcurrency, resultSetHoldability);
} catch (SQLException e) {
throw e;
} catch (Exception e) {
throw Helper.INSTANCE.createException("Error while preparing statement [" + sql + "]", e);
}
}
Aggregations