Struct oracle::Connector

source ·
pub struct Connector { /* private fields */ }
Expand description

Builder data type to create Connection.

When a connection can be established only with username, password and connect string, use Connection::connect instead.

Implementations§

source§

impl Connector

source

pub fn new<U, P, C>(username: U, password: P, connect_string: C) -> Connector
where U: Into<String>, P: Into<String>, C: Into<String>,

Create a connector

source

pub fn privilege(&mut self, privilege: Privilege) -> &mut Connector

Set administrative privilege.

§Examples
// connect system/manager as sysdba
let conn = Connector::new("system", "manager", "")
    .privilege(Privilege::Sysdba)
    .connect()?;
source

pub fn external_auth(&mut self, b: bool) -> &mut Connector

Uses external authentication such as OS authentication.

§Examples
let conn = Connector::new("", "", "")
    .external_auth(true)
    .connect()?;
source

pub fn prelim_auth(&mut self, b: bool) -> &mut Connector

Sets prelim auth mode to connect to an idle instance.

See starting up a database.

source

pub fn new_password<P>(&mut self, password: P) -> &mut Connector
where P: Into<String>,

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 Connection::connect("scott", "tiger", "") {
    Ok(conn) => conn,
    Err(Error::OciError(dberr)) if dberr.code() == 28001 => {
        // ORA-28001: the password has expired
        Connector::new("scott", "tiger", "")
            .new_password("jaguar")
            .connect()?
    }
    Err(err) => return Err(err),
};
source

pub fn purity(&mut self, purity: Purity) -> &mut Connector

Sets session purity specifying whether an application can reuse a pooled session (Purity::Self_) or must use a new session (Purity::New) from DRCP pooled sessions.

source

pub fn connection_class<S>(&mut self, connection_class: S) -> &mut Connector
where S: Into<String>,

Sets a connection class to restrict sharing DRCP pooled sessions.

See here for more detail.

source

pub fn app_context<T1, T2, T3>( &mut self, namespace: T1, name: T2, value: T3 ) -> &mut Connector
where T1: Into<String>, T2: Into<String>, T3: Into<String>,

Appends 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 conn = Connector::new(username, password, connect_string)
              .app_context("CLIENTCONTEXT", "foo", "bar")
              .app_context("CLIENTCONTEXT", "baz", "qux")
              .connect()?;
let val = conn.query_row_as::<String>("select sys_context('CLIENTCONTEXT', 'foo') from dual", &[])?;
assert_eq!(val, "bar");
let val = conn.query_row_as::<String>("select sys_context('CLIENTCONTEXT', 'baz') from dual", &[])?;
assert_eq!(val, "qux");
source

pub fn events(&mut self, b: bool) -> &mut Connector

Reserved for when advanced queuing (AQ) or continuous query notification (CQN) is supported.

source

pub fn edition<S>(&mut self, edition: S) -> &mut Connector
where S: Into<String>,

Specifies edition of Edition-Based Redefinition.

source

pub fn driver_name<S>(&mut self, driver_name: S) -> &mut Connector
where S: Into<String>,

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.

source

pub fn stmt_cache_size(&mut self, size: u32) -> &mut Connector

Specifies the number of statements to retain in the statement cache. Use a value of 0 to disable the statement cache completely.

The default value is 20.

See also Connection::stmt_cache_size and Connection::set_stmt_cache_size

source

pub fn connect(&self) -> Result<Connection>

Connect an Oracle server using specified parameters

Trait Implementations§

source§

impl Clone for Connector

source§

fn clone(&self) -> Connector

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Connector

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Connector

source§

fn eq(&self, other: &Connector) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Connector

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.