use of org.ballerinalang.nativeimpl.actions.data.sql.SQLDatasource in project ballerina by ballerina-lang.
the class Select method execute.
@Override
public void execute(Context context) {
try {
BStruct bConnector = (BStruct) context.getRefArgument(0);
String query = context.getStringArgument(0);
BRefValueArray parameters = (BRefValueArray) context.getNullableRefArgument(1);
BStructType structType = getStructType(context);
SQLDatasource datasource = (SQLDatasource) bConnector.getNativeData(Constants.CLIENT_CONNECTOR);
Map<String, String> tags = new HashMap<>();
tags.put(TAG_KEY_DB_STATEMENT, query);
tags.put(TAG_KEY_DB_TYPE, TAG_DB_TYPE_SQL);
TraceUtil.getTracer(context.getParentWorkerExecutionContext()).addTags(tags);
executeQuery(context, datasource, query, parameters, structType);
} catch (Throwable e) {
context.setReturnValues(SQLDatasourceUtils.getSQLConnectorError(context, e));
SQLDatasourceUtils.handleErrorOnTransaction(context);
}
}
use of org.ballerinalang.nativeimpl.actions.data.sql.SQLDatasource in project ballerina by ballerina-lang.
the class UpdateWithGeneratedKeys method execute.
@Override
public void execute(Context context) {
try {
BStruct bConnector = (BStruct) context.getRefArgument(0);
String query = context.getStringArgument(0);
BRefValueArray parameters = (BRefValueArray) context.getNullableRefArgument(1);
BStringArray keyColumns = (BStringArray) context.getNullableRefArgument(2);
SQLDatasource datasource = (SQLDatasource) bConnector.getNativeData(Constants.CLIENT_CONNECTOR);
Map<String, String> tags = new HashMap<>();
tags.put(TAG_KEY_DB_STATEMENT, query);
tags.put(TAG_KEY_DB_TYPE, TAG_DB_TYPE_SQL);
TraceUtil.getTracer(context.getParentWorkerExecutionContext()).addTags(tags);
executeUpdateWithKeys(context, datasource, query, keyColumns, parameters);
} catch (Throwable e) {
context.setReturnValues(SQLDatasourceUtils.getSQLConnectorError(context, e));
SQLDatasourceUtils.handleErrorOnTransaction(context);
}
}
Aggregations