package com.pearson.cbl; import com.couchbase.lite.Manager; public class Main { public static void main(String[] args) { // Enable logging Logger log = Logger.getLogger("app"); log.setLevel(Level.ALL); JavaContext context = new JavaContext(); // Create a manager Manager manager = null; try { manager = new Manager(context, Manager.DEFAULT_OPTIONS); } catch (IOException e) { e.printStackTrace(); } // Create or open the database named app Database database = null; try { database = manager.getDatabase("app"); } catch (CouchbaseLiteException e) { e.printStackTrace(); } // The properties that will be saved on the document Map properties = new HashMap(); properties.put("title", "Couchbase Mobile"); properties.put("sdk", "Java"); // Create a new document Document document = database.createDocument(); // Save the document to the database try { document.putProperties(properties); } catch (CouchbaseLiteException e) { e.printStackTrace(); } // Log the document ID (generated by the database) // and properties log.info(String.format("Document ID :: %s", document.getId())); log.info(String.format("Learning %s with %s", (String) document.getProperty("title"), (String) document.getProperty("sdk"))); } }