Module oci_rs::connection [] [src]

Connections to a database.

The current implementation only supports a simple connection to the database. There is one user session, but multiple statements can be created. Multiple connections can be created safely because it defaults to setting the OCI environment mode as multi-threaded and therefore the OCI library takes care of concurrency. The cost of this is that a purely single threaded client application might run slower.

More advanced connection options such as connection and statement pooling are not yet available.

Examples

Connection and statement creation with error handling:

use oci_rs::connection::Connection;

let connection = match Connection::new("localhost:1521/xe",
                                       "oci_rs",
                                       "test") {
    Ok(conn) => conn,
    Err(err) => panic!("Failed to create a connection: {}", err),
};

let sql_create = "CREATE TABLE Cats (CatId INTEGER,
                                     Name VARCHAR(20))";

let create = match connection.create_prepared_statement(sql_create) {
    Ok(stmt) => stmt,
    Err(err) => panic!("Failed to create a statement: {}", err),
};

Structs

Connection

Represents a connection to a database.