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]
fn new(username: &str, password: &str, connect_string: &str) -> Connector
[src]
Creates a connection builder.
fn connect(&self) -> Result<Connection>
[src]
Establishes a connection.
fn auth_mode<'a>(&'a mut self, auth_mode: AuthMode) -> &'a mut Connector
[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();
fn prelim_auth<'a>(&'a mut self, prelim_auth: bool) -> &'a mut Connector
[src]
Sets prelim_auth mode. This is required to connect to an idle instance.
This is required only when starting up a database.
fn events<'a>(&'a mut self, events: bool) -> &'a mut Connector
[src]
fn edition<'a>(&'a mut self, edition: &str) -> &'a mut Connector
[src]
fn new_password<'a>(&'a mut self, password: &str) -> &'a mut Connector
[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()), };
fn app_context<'a>(
&'a mut self,
namespace: &str,
name: &str,
value: &str
) -> &'a mut Connector
[src]
&'a mut self,
namespace: &str,
name: &str,
value: &str
) -> &'a mut Connector
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");
fn driver_name<'a>(&'a mut self, name: &str) -> &'a mut Connector
[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.