Accessing REQL¶
r¶
The top-level ReQL namespace.
Example: Set up your top-level namespace.
private RethinkDB r = RethinkDB.r;
connect¶
Create a new connection to the database server. The keyword arguments are:
- host: host of the RethinkDB instance. The default value is localhost.
- port: the driver port, by default 28015.
- db: the database used if not explicitly specified in a query, by default test.
- auth_key: the authentification key, by default the empty string.
If the connection cannot be established, a RqlDriverError exception will be thrown.
Example: Opens a new connection to the database.
RethinkDBConnection connection = r.connect();
Signatures:
public RethinkDBConnection connect();
public RethinkDBConnection connect(String hostname);
public RethinkDBConnection connect(String hostname, int port);
public RethinkDBConnection connect(String hostname, int port, String authKey);
public RethinkDBConnection connect(String hostname, int port, String authKey, int timeout);
use¶
Change the default database on this connection.
Example: Change the default database so that we don’t need to specify the database when referencing a table.
conn.use("marvel");
r.table("heroes").run(conn); // same as r.db("marvel").table("heroes")
run¶
Run a query on a connection, returning a list of of objects
Example:
List<Map<String,Object>> results = r.table("mystuff").run(connection);