Import data from Influxdb_V2 to Spring Boot application - spring

I am trying to fetch data from influxdb(version 2) bucket into my Spring Boot application. I have not found any references on google to implement this feature.
Can anyone help me in this my providing any references or documentation so I can implement this feature.

String token = "tokenDetails";
String bucket = "test123";
String org = "test";
InfluxDBClient client = InfluxDBClientFactory.create("https:localhost:8086/",
token.toCharArray());
String query = String.format("from(bucket: \"%s\") |> range(start: -15m)", bucket);
List<FluxTable> tables = client.getQueryApi().query(query, org);
Iterate on tables and records to operate on data.

Related

i want to use simba.spark.jdbc driver in sprint boot to connect to databricks with token

want to use simba spark jdbc driver in spring boot to connect to data bricks with token
so that i can leverage the code over the "JDBC" boiler plate code and using row mapper and can fetch data from data bricks database , what will be user and password in case of connecting to data bricks
database using token as there is no user and password .and reference or code is welcome
You just not need to set username & password explicitly - just provide URL. Here is a simple working example that uses Databricks SQL endpoint (full example is here):
String host = "adb-123.11.azuredatabricks.net";
String httpPath = "/sql/1.0/endpoints/...";
String token = "your_token";
String query = "select count(1) from default.table";
String jdbcUrl = "jdbc:spark://" + host +
":443/default;transportMode=http;ssl=1;httpPath=" +
httpPath + ";AuthMech=3;UID=token;PWD=" + token;
SimpleDriverDataSource ds = new SimpleDriverDataSource();
ds.setDriver(new Driver());
ds.setUrl(jdbcUrl);
JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
int numRows = jdbcTemplate.queryForObject(query, Integer.class);

Read Full Query parameter String in Spring Boot

Is there a way for me to read the entire query string in the GET API? Since there can be a variable number of parameters I am already looking at using this
public void createUser(#RequestParam(required=false) Map<String,String> qparams) {
}
But I want to read the entire query string as well.
The reason being one of the parameters here is an HMAC which is calculated on the entire string. and we are using that HMAC for cross verification.
We have deep integration with third-party software. The issue here is that the third-party software can make a change to their API at any point in time.
Here's how you can do it.
#GetMapping("/test1")
void endpoint1(HttpServletRequest req) {
var qs = req.getQueryString() //returns the entire string
qs.split("&") //split to get the individual parameters
}

How to retrieve xstring value from ABAP using RfcQuery?

I am wondering how a xstring should be retrieved from ABAP backend using RfcQuery.
final RfcQuery query = new RfcQuery(<myRFC>)...
Byte[] pdf = query.execute(erpEndpoint).get("EX_BLOB").getAs ??
Any ideas?
As of now retrieving XSTRING values from an remote-enabled function module is not supported.
I'll edit this question if there is an update.

scan and scroll in spring data elasticsearch 3

I am trying to migrate my es 2.2.1 with spring data elastic 2 to ES 5.6.1 with spring Data elastic 3 but when i am trying to use scan scroll method for large dataaset i am not able to access them, its look like ElasticsearchTemaplate class do not have these function any more in the newer version Can you please let me know what is the substitute of scan and scroll in SDA 3.x:-
ElasticsearchTemplate rep=null;
String scrollId = rep.scan(searchQuery, (long)25000, false);
//List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
boolean hasRecords = true;
You now can use startScroll method instead of scan() and scroll().
It's not presented in current docs.
Here are example ElasticsearchTemplate retrieve big data sets

Issue Retrieving a Screenshot from a database

I've got a bunch of screenshots and some screenshot meta data I'm trying to display in an ASP.NET MVC 3 web application, I'm trying to retrieve the data from my databse but I get this error:
LINQ to Entities does not recognize the method 'System.Drawing.Image
ByteArrayToImage(Byte[])' method, and this method cannot be translated
into a store expression.
Here's my code:
var screenshotData = (from screenshots in db.screenshots
where screenshots.projects_ID == projectID
select new ImageInformation
{
ID = screenshots.id,
Language = screenshots.language,
Screenshot = Utility.ByteArrayToImage(screenshots.screen_shot),
ProjectID = screenshots.projects_ID
});
foreach (ImageInformation info in screenshotData)
{
this.Add(info);
}
ImageInformation is just a simple class that contains the defintion the information stored (ID, Language, Screenshot, ProjectID).
Here's my ByteArrayToImage function:
public static Image ByteArrayToImage(byte[] byteArrayIn)
{
using (MemoryStream ms = new MemoryStream(byteArrayIn))
{
Image returnImage = Image.FromStream(ms);
return returnImage;
}
}
Can anybody tell me why I receive this error when this code runs?
Thanks.
I think it's because, with LINQ-to-Entities, the code is turned into server-side query and it can't do that in this case. I don't think you can mix client-side code like this directly with L2E.
I would suspect you will have to do the conversion from byte->image after you've retrieved the data from the database as a distinct step.
You can't do the function in a LINQ to Entities query... one option:
1) have a byte[] property on the object you are instantiating (ImageInformation) and copy the data in there along with another propery to read the image from this ImageInformation object.

Resources