Creating a database in InfluxDB v1.8 using the new Java client

Hi,

I am using InfluxDB v1.8.5 and I have recently migrated my Java Client from GitHub - influxdata/influxdb-java: Java client for InfluxDB to GitHub - influxdata/influxdb-client-java: InfluxDB 2 JVM Based Clients.

My use case requires to create the Database from the Java application. I initially thought I had something working by using the createV1 method from the new client then using the bucket API to create databases. But I realised a 404 is returned and my database was actually created by telegraf itself (I believe…).

In the past, I used to create a Query from java that was doing CREATE DATABASE database_name
But doing something similar returns a 403 error.

I have not thoroughly investigated yet, but I just wanted to make sure such thing was possible using the new client.

Thanks in advance.

Hello @0liver,
In 2.x databases are called buckets. Buckets = database + retention policy.
InfluxDBClient influxDBClient = InfluxDBClientFactory.create(“http://localhost:8086”, token);

    //
    // Create bucket "iot_bucket" with data retention set to 3,600 seconds
    //
    BucketRetentionRules retention = new BucketRetentionRules();
    retention.setEverySeconds(3600);

    Bucket bucket = influxDBClient.getBucketsApi().createBucket("iot-bucket", retention, "12bdc4164c2e8141");

Are you using the InfluxDB 2.x client library with InfluxDB 1.x? Or are you using 2.x client library with InfluxDB 2?

Hi @Anaisdg ,

Thank you for your reply. You are correct, I am using the InfluxDB 2.x client library with InfluxDB 1.8 as I thought they would work together (as suggested by: GitHub - influxdata/influxdb-client-java: InfluxDB 2 JVM Based Clients)

But if I understood correctly, the support for version 1.8 is only partial, correct ?

Thanks in advance.

Here are the compatibility docs:

So yes I don’t think you can use the client to create a bucket. :confused:

Hi @Anaisdg,

That’s fair enough.

However, I am a bit confused by the documentation you have sent as I believe this is the V1 endpoints for InfluxDB v2, am I correct ?

In my case, I would like to use the new Java Client used for V2 with V1 (as it seems v1 has some compatibility with V2 API). But I believe your statement is still correct.

I have implemented a workaround for my use case. It is not ideal because I would prefer using the Client itself.

I will try to get in touch with the maintainers of the Java Client to understand a bit more what is allowed / not allowed in my case.

Thanks !

Hello @0liver,
That’s correct. You’re using the v2 client which uses the v2 API which has compatibility with the /query and /write endpoints for 1.x. I believe you’re right and I shared the forward with you whoops. This always confuses me. You’re looking for backward compatibility.
Here are the docs for backward:

Here are the docs for forward.

@0liver InfluxDB 1.8.5 includes v2 compatible endpoints, but only for writes and queries. You can’t actually create a database in 1.x using a v2 client.

Thank you for replies @Anaisdg and @scott .

If I may ask 1 last question: Is this support never to be included ? Or is it something that is considered and may come in future versions of the v2 client ?

For now, migrating to v2 would be too much of a hassle for us. So, the idea was to plan for a smoother migration by migrating the client first. Then, wait to see if v2 can become an option or wait for IOx to be released.

But from my understanding, there is no certainty that this client GitHub - influxdata/influxdb-client-java: InfluxDB 2 JVM Based Clients will be the one for IOx, am I correct ?

Thanks in advance.

This discussion is also very useful for me, :blush: thanks for sharing!

1 Like

Hi @Anaisdg , Hi @scott ,

One question that’s important to me regarding using the new Java library is whether this new Java client used for v2 will also be the one used for further versions (InfluxDB IOx for example) ?

Or, is it just the one for v2 but IOx or further InfluxDB versions will have their own client.

Thanks in advance,

@0liver
IOx implements the same write endpoint as 2.x so the 2.x clients will work to write data in. However, there will be separate IOx specific client libraries for working with the management API. For query, if using the Flux or InfluxQL connector, then 2.x clients will work. IOx also supports Arrow Flight + SQL for query, which would use an Apache Arrow library in your language of choice.
Ultimately, IOx will have its own client libraries as well.
So yes and no depending on what you want to do.

@Anaisdg ,

Thank you so much for your reply again. IOx sounds really promising. And the improvements around the tag cardinality definitely make it a good candidate for our use.

So, from my understanding, IOx will use the same write endpoints than 2.x. So, the v2 client will be the one that will actually work. As, I guess the v1 client will not work because IOx won’t have the v1 endpoints, correct ?

Also, I see the v1 client seems to be community supported. Can I assume the support of this library will eventually come to an end. Where the support of v2 will continue ?

Thanks in advance.

1 Like

@0liver,
I can’t say for certain, but that sounds likely. Yes I believe the support of v2 will continue. @tim.hall might be able to confirm or deny for me.

1 Like

like all technology things will advance…and evolve. But, if/when they do, we’ll make sure there is plenty of compatibility/overlap for quite some time. So, working with the v2 API is the latest and most stable to work with. Introduction of IOx will be via InfluxDB Cloud and the v2 read/write APIs will be leveraged.

1 Like

Thanks @Anaisdg and @tim.hall for your replies !