How to connect two difference versions couchbase server

Hi team
I have two versions of the couchbase server, them are 4.5.0 and 7.2.2.
How to connect them in one application at the same time ?
As far as I know, both of their java client pom are

<dependency>
        <groupId>com.couchbase.client</groupId>
        <artifactId>java-client</artifactId>
</dependency>

The version of pom of 4.5.0 java-client is 2.3.1 and the version of pom of 7.2.2 java-client is 3.5.2.

Hi @superman , I would strongly recommend upgrading both your 4.5.0 server and your 2.3.1 Java SDK as they were both now long EOL and unsupported.

But to answer your question - you would create two cluster connections from your application, e.g. two instances of the SDK.

1 Like

Thank you for your reply.
For some reasons, the upgrading is not allowed.
How to create two cluster connections ? How to use two versions SDK ?

Follow the instructions for creating one cluster connection, using the connection information from the first cluster.

Then follow the instructions again to create a second connection, using the connection information for the second cluster.

If you are writing a new application it’s advisable to use the latest SDK version (3.5.2).

I tried to connect couchbase server 4.5.0 by SDK version (3.5.2), it didn’t work.

Please show the error.
Please add a call to WaitUntilReady as it gives more detailed diagnostics.
Please use SDK Doctor to help diagnose the issue.

Hi @superman,

How to use two versions SDK ?

Sorry, it is not possible to use both the standard Couchbase Java client version 2.x and version 3.x in the same application. As you noted, they share the same Maven group and artifact name. They also have conflicting class names inside the JARs.

There is a path forward, but it would require that you create a custom version of SDK 2.x using the Maven Shade plugin, and relocate all the SDK 2.x classes under a different package. Then you’d use your custom version of SDK 2 instead of the standard version. This would require modifying your existing code to use the repackaged version of SDK 2.x instead of the standard version. I don’t know how much we could help with this – you’d probably be largely on your own, since even the standard SDK 2.x is so old that it’s no longer supported.

Thanks,
David

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.