Struct oracle::Connector [] [src]

pub struct Connector { /* fields omitted */ }

Connection Builder

A connection is created by two methods. One is Connection::new. The other is connect method. Use the former to connect to a database with username, password and connect_string. Use the latter when additional parameters such as SYSDBA are required. See examples below.

Methods

impl Connector
[src]

[src]

Creates a connection builder.

[src]

Establishes a connection.

[src]

Sets a system privilege such as SYSDBA.

// same with `sqlplus system/manager as sysdba` on command line.
let mut connector = oracle::Connector::new("system", "manager", "");
connector.auth_mode(oracle::AuthMode::SYSDBA);
let conn = connector.connect().unwrap();

[src]

Sets prelim_auth mode. This is required to connect to an idle instance.

This is required only when starting up a database.

[src]

[src]

[src]

Sets new password during establishing a connection.

When a password is expired, you cannot connect to the user. A new password must be set by other user or set during establishing a connection.

Examples

Connect to user scott with password tiger. If the password is expired, set a new password jaguar.

let conn = match oracle::Connection::new("scott", "tiger", "") {
    Ok(conn) => conn,
    Err(oracle::Error::OciError(ref dberr)) if dberr.code() == 28001 => {
        // ORA-28001: the password has expired
        let mut connector = oracle::Connector::new("scott", "tiger", "");
        connector.new_password("jaguar");
        connector.connect().unwrap()
    },
    Err(err) => panic!(err.to_string()),
};

[src]

Sets an application context. See Oracle manual

This is same with DBMS_SESSION.SET_CONTEXT but this can set application contexts before a connection is established.

Examples:

let mut connector = oracle::Connector::new("scott", "tiger", "");
connector.app_context("CLIENTCONTEXT", "foo", "bar");
connector.app_context("CLIENTCONTEXT", "baz", "qux");
let conn = connector.connect().unwrap();
let mut stmt = conn.execute("select sys_context('CLIENTCONTEXT', 'baz') from dual", &[]).unwrap();
let row = stmt.fetch().unwrap();
let val: String = row.get(0).unwrap();
assert_eq!(val, "qux");

[src]

Sets the driver name displayed in V$SESSION_CONNECT_INFO.CLIENT_DRIVER.

The default value is "rust-oracle : version number". Only the first 8 chracters "rust-ora" are displayed when the Oracle server version is lower than 12.0.1.2.