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
impl Connector
Sourcepub fn new<U, P, C>(username: U, password: P, connect_string: C) -> Connector
pub fn new<U, P, C>(username: U, password: P, connect_string: C) -> Connector
Create a connector
Sourcepub fn privilege(&mut self, privilege: Privilege) -> &mut Connector
pub fn privilege(&mut self, privilege: Privilege) -> &mut Connector
§Examples
// connect system/manager as sysdba
let conn = Connector::new("system", "manager", "")
.privilege(Privilege::Sysdba)
.connect()?;
Sourcepub fn external_auth(&mut self, b: bool) -> &mut Connector
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()?;
Sourcepub fn prelim_auth(&mut self, b: bool) -> &mut Connector
pub fn prelim_auth(&mut self, b: bool) -> &mut Connector
Sets prelim auth mode to connect to an idle instance.
Sourcepub fn new_password<P>(&mut self, password: P) -> &mut Connector
pub fn new_password<P>(&mut self, password: P) -> &mut Connector
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),
};
Sourcepub fn purity(&mut self, purity: Purity) -> &mut Connector
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.
Sourcepub fn connection_class<S>(&mut self, connection_class: S) -> &mut Connector
pub fn connection_class<S>(&mut self, connection_class: S) -> &mut Connector
Sourcepub fn app_context<T1, T2, T3>(
&mut self,
namespace: T1,
name: T2,
value: T3,
) -> &mut Connector
pub fn app_context<T1, T2, T3>( &mut self, namespace: T1, name: T2, value: T3, ) -> &mut Connector
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");
Sourcepub fn events(&mut self, b: bool) -> &mut Connector
pub fn events(&mut self, b: bool) -> &mut Connector
Reserved for when advanced queuing (AQ) or continuous query notification (CQN) is supported.
Sourcepub fn edition<S>(&mut self, edition: S) -> &mut Connector
pub fn edition<S>(&mut self, edition: S) -> &mut Connector
Specifies edition of Edition-Based Redefinition.
Sourcepub fn driver_name<S>(&mut self, driver_name: S) -> &mut Connector
pub fn driver_name<S>(&mut self, driver_name: S) -> &mut Connector
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.
Sourcepub fn stmt_cache_size(&mut self, size: u32) -> &mut Connector
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
Sourcepub fn connect(&self) -> Result<Connection>
pub fn connect(&self) -> Result<Connection>
Connect an Oracle server using specified parameters