Struct oci_rs::connection::Connection[][src]

pub struct Connection { /* fields omitted */ }

Represents a connection to a database.

Internally it holds the various handles that are needed to maintain a connection to the database. Once it goes out of scope it will free these handles using the relevant OCI calls via a Drop implementation.

Methods

impl Connection
[src]

Creates a new Connection.

Errors

Any errors encounter when trying to allocate handles in OCI library will bubble up here. The OciError will return the relevant Oracle error codes and text when available.

Examples

use oci_rs::connection::Connection;

let connection = Connection::new("localhost:1521/xe",
                                 "user",
                                 "password")
                                 .unwrap();

Creates a new Statement.

A Statement can only live as long as the Connection that created it. The SQL statement that needs to be executed is supplied. A connection can have multiple statements active.

Errors

Any OCI failures will be reported and the relevant Oracle error codes available.

Examples

use oci_rs::connection::Connection;

let connection = Connection::new("localhost:1521/xe",
                                 "user",
                                 "password")
                                 .unwrap();

let sql_select = "SELECT * FROM SomeTable";
let select_stmt = match connection.create_prepared_statement(sql_select) {
    Ok(stmt) => stmt,
    Err(err) => panic!("Oracle error: {}", err),
};

Trait Implementations

impl Debug for Connection
[src]

Formats the value using the given formatter. Read more

impl Drop for Connection
[src]

Ends the current user session, disconnects from the database and frees the handles allocated by the OCI library.

This should ensure there are no remaining processes or memory allocated.

Panics

Panics if the resources can't be freed. This would be a failure of the underlying OCI resource freeing function.

Auto Trait Implementations

impl !Send for Connection

impl !Sync for Connection