Connecting Couchbase to java application

CouchDB connection

1. Login to your Cloudjiffy account
2. Create an environment with Couchbase database
 
 
3. Check the email box to get credentials to access the Couchbase database
                            
                                       

4.
To establish the connection between your Couchbase cluster and Java application, you need to provide the appropriate dedicated Couchbase Java Client JAR libraries within the /lib directory on your application server container. Herewith, this can be accomplished in two different ways - through uploading the required files manually (for the already deployed application) or rebuilding it from the sources with the appropriate client being set as a dependency - we’ll consider both these approaches.

So, for manual upload - click Config next to the application server with your deployed project and Upload extracted files from the above-linked package to its webapps/{app_context}/WEB-INF/lib directory.

 
 
 

Finally, Restart the server with the corresponding icon next to it for the newly added JARs to be automatically detected and run. Once it’s up again, modify your application source code to establish the connection to the Couchbase cluster.

If compiling your Java application from sources by means of Maven build node, you can simply designate the Couchbase Java Client as a required dependency within the project pom.xml file like in the code snippet below.


   
       com.couchbase.client
       java-client
       2.0.3
   

After rebuilding with such parameters, you’ll get a new application version with out-of-box ability to interact with clustered Couchbase DB so you just need to define the appropriate connection parameters within its code.  


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 15201