|
||||||||||
| 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
| Nested Class Summary | |
|---|---|
static class |
DB.WriteConcern
|
| Field Summary | |
|---|---|
protected boolean |
_readOnly
|
| Constructor Summary | |
|---|---|
DB(java.lang.String name)
|
|
| Method Summary | |
|---|---|
void |
addUser(java.lang.String username,
char[] passwd)
|
boolean |
authenticate(java.lang.String username,
char[] passwd)
Authenticates connection/db with given name and password |
DBObject |
command(DBObject cmd)
Execute a database command directly. |
DBCollection |
createCollection(java.lang.String name,
DBObject o)
Creates a collection with a given name and options. |
DBObject |
doEval(java.lang.String code,
java.lang.Object... args)
|
protected abstract DBCollection |
doGetCollection(java.lang.String name)
|
void |
dropDatabase()
Drops this database. |
java.lang.Object |
eval(java.lang.String code,
java.lang.Object... args)
|
void |
forceError()
For testing purposes only - this method forces an error to help test error handling |
DBCollection |
getCollection(java.lang.String name)
Gets a collection with a given name. |
abstract DBCollection |
getCollectionFromFull(java.lang.String fullNameSpace)
Returns the collection represented by the string <dbName>.<collectionName>. |
DBCollection |
getCollectionFromString(java.lang.String s)
Returns a collection matching a given string. |
java.util.Set<java.lang.String> |
getCollectionNames()
Returns a set of the names of collections in this database. |
DBObject |
getLastError()
Gets the the error (if there is one) from the previous operation. |
java.lang.String |
getName()
Returns the name of this database. |
DBObject |
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(java.lang.String dbName)
|
DB.WriteConcern |
getWriteConcern()
|
void |
requestDone()
|
void |
requestEnsureConnection()
|
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(java.lang.Boolean b)
Makes this database read-only |
void |
setWriteConcern(DB.WriteConcern concern)
|
java.lang.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(java.lang.String name)
| Method Detail |
|---|
public void requestStart()
public void requestDone()
public void requestEnsureConnection()
public abstract DBCollection getCollectionFromFull(java.lang.String fullNameSpace)
fullNameSpace - the string
protected abstract DBCollection doGetCollection(java.lang.String name)
public abstract DB getSisterDB(java.lang.String dbName)
public final DBCollection getCollection(java.lang.String name)
name - the name of the collection to return
public final DBCollection createCollection(java.lang.String name,
DBObject o)
name - the name of the collection to returno - options
public DBCollection getCollectionFromString(java.lang.String s)
s - the name of the collection
public DBObject command(DBObject cmd)
throws MongoException
MongoException
public DBObject doEval(java.lang.String code,
java.lang.Object... args)
throws MongoException
MongoException
public java.lang.Object eval(java.lang.String code,
java.lang.Object... args)
throws MongoException
MongoExceptionpublic java.lang.String getName()
public void setReadOnly(java.lang.Boolean b)
b - if the database should be read-only
public java.util.Set<java.lang.String> getCollectionNames()
throws MongoException
MongoExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic void resetIndexCache()
public DBObject 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.
MongoExceptionpublic void setWriteConcern(DB.WriteConcern concern)
public DB.WriteConcern getWriteConcern()
public void dropDatabase()
throws MongoException
MongoException
public boolean authenticate(java.lang.String username,
char[] passwd)
throws MongoException
username - name of user for this databasepasswd - password of user for this database
MongoException
public void addUser(java.lang.String username,
char[] passwd)
public DBObject 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 | |||||||||