|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.DB
public abstract class DB
a logical database on a server
Nested Class Summary | |
---|---|
static class |
DB.WriteConcern
Settings for strictness of error checking on writes (inserts, updates, and removes). |
Field Summary | |
---|---|
protected boolean |
_readOnly
|
Constructor Summary | |
---|---|
DB(String name)
|
Method Summary | |
---|---|
void |
addUser(String username,
char[] passwd)
|
boolean |
authenticate(String username,
char[] passwd)
Authenticates connection/db with given name and password |
boolean |
collectionExists(String collectionName)
Checks to see if a collection by name %lt;name> exists. |
CommandResult |
command(DBObject cmd)
Execute a database command directly. |
CommandResult |
command(String cmd)
|
DBCollection |
createCollection(String name,
DBObject o)
Creates a collection with a given name and options. |
CommandResult |
doEval(String code,
Object... args)
|
protected abstract DBCollection |
doGetCollection(String name)
|
void |
dropDatabase()
Drops this database. |
Object |
eval(String code,
Object... args)
|
void |
forceError()
For testing purposes only - this method forces an error to help test error handling |
DBCollection |
getCollection(String name)
Gets a collection with a given name. |
abstract DBCollection |
getCollectionFromFull(String fullNameSpace)
Returns the collection represented by the string <dbName>.<collectionName>. |
DBCollection |
getCollectionFromString(String s)
Returns a collection matching a given string. |
Set<String> |
getCollectionNames()
Returns a set of the names of collections in this database. |
CommandResult |
getLastError()
Gets the the error (if there is one) from the previous operation. |
String |
getName()
Returns the name of this database. |
CommandResult |
getPreviousError()
Returns the last error that occurred since start of database or a call to resetError()
The return object will look like |
abstract DB |
getSisterDB(String dbName)
|
DB.WriteConcern |
getWriteConcern()
Get the write concern for this database. |
abstract void |
requestDone()
|
abstract void |
requestEnsureConnection()
|
abstract void |
requestStart()
|
void |
resetError()
Resets the error memory for this database. |
void |
resetIndexCache()
Clears any indices that have not yet been applied to the collections in this database. |
void |
setReadOnly(Boolean b)
Makes this database read-only |
void |
setWriteConcern(DB.WriteConcern concern)
Set the write concern for this database. |
String |
toString()
Returns the name of this database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean _readOnly
Constructor Detail |
---|
public DB(String name)
Method Detail |
---|
public abstract void requestStart()
public abstract void requestDone()
public abstract void requestEnsureConnection()
public abstract DBCollection getCollectionFromFull(String fullNameSpace)
fullNameSpace
- the string
protected abstract DBCollection doGetCollection(String name)
public abstract DB getSisterDB(String dbName)
public final DBCollection getCollection(String name)
name
- the name of the collection to return
public final DBCollection createCollection(String name, DBObject o)
name
- the name of the collection to returno
- options
public DBCollection getCollectionFromString(String s)
s
- the name of the collection
public CommandResult command(DBObject cmd) throws MongoException
MongoException
public CommandResult command(String cmd) throws MongoException
MongoException
public CommandResult doEval(String code, Object... args) throws MongoException
MongoException
public Object eval(String code, Object... args) throws MongoException
MongoException
public String getName()
public void setReadOnly(Boolean b)
b
- if the database should be read-onlypublic Set<String> getCollectionNames() throws MongoException
MongoException
public boolean collectionExists(String collectionName)
collectionName
- The collection to test for existence
public String toString()
toString
in class Object
public void resetIndexCache()
public CommandResult getLastError() throws MongoException
{ "err" : errorMessage , "ok" : 1.0 , "_ns" : "$cmd"}The value for errorMessage will be null if no error occurred, or a description otherwise. Care must be taken to ensure that calls to getLastError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.
MongoException
public void setWriteConcern(DB.WriteConcern concern)
DB.WriteConcern
for more information.
concern
- write concern to usepublic DB.WriteConcern getWriteConcern()
public void dropDatabase() throws MongoException
MongoException
public boolean authenticate(String username, char[] passwd) throws MongoException
username
- name of user for this databasepasswd
- password of user for this database
MongoException
public void addUser(String username, char[] passwd)
public CommandResult getPreviousError() throws MongoException
resetError()
The return object will look like
{ err : errorMessage, nPrev : countOpsBack, ok : 1 }The value for errormMessage will be null of no error has ocurred, or the message. The value of countOpsBack will be the number of operations since the error occurred. Care must be taken to ensure that calls to getPreviousError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.
MongoException
public void resetError() throws MongoException
MongoException
public void forceError() throws MongoException
MongoException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |