Connect to Aiven for Valkey™ with Java
Establish a connection to your Aiven for Valkey™ service using Java and the jedis library.
Variables
Replace placeholders in the code sample with values from your service overview page:
| Variable | Description |
|---|---|
SERVICE_URI | URI for the Aiven for Valkey service connection |
Prerequisites
-
Alternatively, if you choose not to install Maven, manually download the dependencies from the Maven Central Repository and place them in the
libfolder. -
If you have Maven installed, run the following commands in the
libfolder to downloadjedisand its dependencies:mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=redis.clients:jedis:4.1.1:jar -Ddest=lib/jedis-4.1.1.jar \
&& mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.apache.commons:commons-pool2:2.11.1:jar -Ddest=lib/commons-pool2-2.11.1.jar \
&& mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.slf4j:slf4j-api:1.7.35:jar -Ddest=lib/slf4j-api-1.7.35.jar \
&& mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=com.google.code.gson:gson:2.8.9:jar -Ddest=lib/gson-2.8.9.jar