Easiest Way to connect with Couchbase using Scala


In this blog, we have explained how easily we can connect with Couchbase, store and fetch data  using scala through an example.

Tools and technologies used :

SBT 0.13.8
Scala 2.11.6
Couchbase Server 4.0 Beta
Eclipse
JDK 1.7

Please follow below instructions to use this example:-

1) Install and configure Couchbase

a) Download the couchbase server from here.

b)  If you are using ubuntu, then Install the package using the dpkg command as a privileged user under sudo. For example:

sudo dpkg -i couchbase-server-enterprise_4.0.0-beta-ubuntu14.04_amd64.deb

c) Get Couchbase Server up and running quickly.

d) You can configure your server using the instructions given here.

2) Set up build.sbt

Selection_032
3) Couchbase Connection

Connect with Couchbase using CouchbaseCluster

Selection_0334) Create Person case-class

Selection_035
5) Write store and fetch method to get data from Couchbase

Selection_034
6) Go to http://localhost:8091/ and create a bucket “person”

7) Now run

sbt test

8) Now go back to http://localhost:8091/, you will able to see person data in JSON format.
Selection_036
You can find complete source code here https://github.com/knoldus/scala-couchbase

About Ayush Mishra

Ayush is the Sr. Software Consultant @ Knoldus Software LLP. In his 5 years of experience he has become developer with proven experience in architecting and developing web applications. Ayush has a Masters in Computer Application from U.P. Technical University, Ayush is a strong-willed and self-motivated professional who takes deep care in adhering to quality norms within projects. He is capable of managing challenging projects with remarkable deadline sensitivity without compromising code quality. .
This entry was posted in couchbase, NoSql, Scala and tagged , . Bookmark the permalink.

5 Responses to Easiest Way to connect with Couchbase using Scala

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s