1. Log onto CirrusGrid.
2. Create environment with CouchDB database:
3. Check your email box for getting credentials to access CouchDB node:
4. Then create a file mydb.cfg in Config Manager (folder HOME). This file contains information on connecting to CouchDB. This info will be read by your application:
5. In this step you have to prepare part of java code that creates connection to your DB:
import com.fourspaces.couchdb.*; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; public class CouchdbConnector { public boolean createDatabase(String name) { try { //Read file mydb.cfg Properties prop = new Properties(); prop.load(new FileInputStream(System.getProperty("user.home") + "/mydb.cfg")); //Getting info we need: host, port, username, password String host = prop.getProperty("host").toString(); int port = Integer.parseInt(prop.getProperty("port").toString()); String username = prop.getProperty("username").toString(); String password = prop.getProperty("password").toString(); Session dbSession = new Session(host, port, username, password); dbSession.createDatabase(name); try { dbSession.getDatabase(name); } catch (Exception e) { return false; } } catch (IOException ex) { Logger.getLogger(CouchdbConnector.class.getName()).log(Level.SEVERE, null, ex); } return true; } }
NOTE: you have to upload all libraries that CouchDB connection needs!
6. Deploy application: couchdb.war
7. Run deployed application and input database name you want to create:
Input database name:
8. Check CouchDB server if it contains “new” database:
run CouchDB instance in browser:
input credentials that you got on e-mail;
check database presence.
Powered by BetterDocs
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.