Class CouchDbClient
java.lang.Object
org.lightcouch.CouchDbClientBase
org.lightcouch.CouchDbClient
- All Implemented Interfaces:
Closeable, AutoCloseable
Presents a client to CouchDB database server.
This class is the main object to use to gain access to the APIs.
Usage Example:
Create a new client instance:
CouchDbClient dbClient = new CouchDbClient();
Start using the API by the client:
Documents CRUD APIs is accessed by the client directly, eg.: dbClient.find(Foo.class, "doc-id")
View APIs dbClient.view()
Change Notifications dbClient.changes()
Replication dbClient.replication() and dbClient.replicator()
DB server dbClient.context()
Design documents dbClient.design()
At the end of a client usage; it's useful to call: shutdown() to ensure proper release of resources.
- Since:
- 0.0.2
- Author:
- Ahmed Yehia
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of this class, expects a configuration file namedcouchdb.propertiesto be available in your application default classpath.CouchDbClient(String configFileName) Constructs a new instance of this class.CouchDbClient(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) Constructs a new instance of this class.CouchDbClient(CouchDbProperties properties) Constructs a new instance of this class. -
Method Summary
Methods inherited from class CouchDbClientBase
batch, bulk, changes, contains, context, design, executeRequest, find, find, find, find, find, findAny, findDocs, getBaseUri, getDBUri, getGson, invokeUpdateHandler, post, remove, remove, replication, replicator, save, saveAttachment, saveAttachment, setGsonBuilder, syncDesignDocsWithDb, update, view
-
Constructor Details
-
CouchDbClient
public CouchDbClient()Constructs a new instance of this class, expects a configuration file namedcouchdb.propertiesto be available in your application default classpath. -
CouchDbClient
Constructs a new instance of this class.- Parameters:
configFileName- The configuration file name.
-
CouchDbClient
public CouchDbClient(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) Constructs a new instance of this class.- Parameters:
dbName- The database name.createDbIfNotExist- To create a new database if it does not already exist.protocol- The protocol to use (i.e http or https)host- The database host addressport- The database listening portusername- The Username credentialpassword- The Password credential
-
CouchDbClient
Constructs a new instance of this class.- Parameters:
properties- An object containing configuration properties.- See Also:
-
-
Method Details
-
shutdown
public void shutdown() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-