Struct oracle::Connection [] [src]

pub struct Connection { /* fields omitted */ }

Connection to an Oracle database

Methods

impl Connection
[src]

[src]

Connects to an Oracle database with username, password and connect_string.

When you need to set more parameters before connecting to the server, see Connector.

Examples

To connect to a local database.

let conn = oracle::Connection::new("scott", "tiger", "").unwrap();

To connect to a remote database specified by easy connect naming.

let conn = oracle::Connection::new("scott", "tiger", "server_name:1521/service_name").unwrap();

[src]

Prepares a statement and returns it for subsequent execution/fetching

Examples

let conn = oracle::Connection::new("scott", "tiger", "").unwrap();
let mut stmt = conn.prepare("insert into emp(empno, ename) values (:1, :2)").unwrap();

// insert one row.
stmt.execute(&(113, "John")).unwrap();

// insert another row.
stmt.execute(&(114, "Smith")).unwrap();

[src]

Prepares a statement, binds values and executes it in one call.

Examples

let conn = oracle::Connection::new("scott", "tiger", "").unwrap();

// execute a statement without bind parameters
conn.execute("insert into emp(empno, ename) values (113, 'John')", &()).unwrap();

// execute a statement with bind parameters
conn.execute("insert into emp(empno, ename) values (:1, :2)", &(114, "Smith")).unwrap();

[src]

Cancels execution of running statements in the connection

[src]

Commits the current active transaction

[src]

Rolls back the current active transaction

[src]

Closes the connection before the end of lifetime.

This fails when open statements or LOBs exist.

[src]

Gets information about the server version

Examples

let conn = oracle::Connection::new("scott", "tiger", "").unwrap();
let (version, banner) = conn.server_version().unwrap();
println!("Oracle Version: {}", version);
println!("--- Version Banner ---");
println!("{}", banner);
println!("---------------------");

[src]

Changes the password for the specified user

[src]

Pings the connection to see if it is still alive

[src]

Gets current schema associated with the connection

[src]

Sets current schema associated with the connection

[src]

Gets edition associated with the connection

[src]

Gets external name associated with the connection

[src]

Sets external name associated with the connection

[src]

Gets internal name associated with the connection

[src]

Sets internal name associated with the connection

[src]

Gets the statement cache size

[src]

Sets the statement cache size

[src]

Sets module associated with the connection

This is same with calling DBMS_APPLICATION_INFO.SET_MODULE but without executing a statement. The module name is piggybacked to the server with the next network round-trip.

[src]

Sets action associated with the connection

This is same with calling DBMS_APPLICATION_INFO.SET_ACTION but without executing a statement. The action name is piggybacked to the server with the next network round-trip.

[src]

Sets client info associated with the connection

This is same with calling DBMS_APPLICATION_INFO.SET_CLIENT_INFO but without executing a statement. The client info is piggybacked to the server with the next network round-trip.

[src]

Sets client identifier associated with the connection

This is same with calling DBMS_SESSION.SET_IDENTIFIER but without executing a statement. The client identifier is piggybacked to the server with the next network round-trip.

[src]

Sets name of the database operation to be monitored in the database. Sets to '' if you want to end monitoring the current running database operation.

This is same with calling DBMS_SQL_MONITOR.BEGIN_OPERATION but without executing a statement. The database operation name is piggybacked to the server with the next network round-trip.

See Monitoring Database Operations in Oracle Database SQL Tuning Guide

[src]

Starts up a database

This corresponds to sqlplus command startup nomount. You need to connect the databas as system privilege in prelim_auth mode in advance. After this method is executed, you need to reconnect the server as system privilege without prelim_auth and executes alter database mount and then alter database open.

Examples

Connect to an idle instance as sysdba and start up a database

use oracle::{Connector, AuthMode};
// connect to an idle instance
let conn = Connector::new("sys", "change_on_install", "")
             .prelim_auth(true) // required to connect to an idle instance
             .auth_mode(AuthMode::SYSDBA) // connect as sysdba
             .connect().unwrap();

// start the instance
conn.startup_database(&[]).unwrap();
conn.close().unwrap();

// connect again without prelim_auth
let conn = Connector::new("sys", "change_on_install", "")
             .auth_mode(AuthMode::SYSDBA) // connect as sysdba
             .connect().unwrap();

// mount and open a database
conn.execute("alter database mount", &()).unwrap();
conn.execute("alter database open", &()).unwrap();

Start up a database in restricted mode

Be careful when using this code, it's not being tested!
...
conn.startup_database(&[StartupMode::Restrict]).unwrap();
...

If the database is running, shut it down with mode ABORT and then start up in restricted mode

Be careful when using this code, it's not being tested!
...
conn.startup_database(&[StartupMode::Force, StartupMode::Restrict]).unwrap();
...

[src]

Shuts down a database

When this method is called with ShutdownMode::Default, ShutdownMode::Transactional, ShutdownMode::TransactionalLocal or ShutdownMode::Immediate, execute "alter database close normal" and "alter database dismount" and call this method again with ShutdownMode::Final.

When this method is called with ShutdownMode::Abort, the database is aborted immediately.

Examples

Same with shutdown immediate on sqlplus.

use oracle::{Connector, AuthMode, ShutdownMode};
// connect
let conn = Connector::new("sys", "change_on_install", "")
             .auth_mode(AuthMode::SYSDBA) // connect as sysdba
             .connect().unwrap();

// begin 'shutdown immediate'
conn.shutdown_database(ShutdownMode::Immediate).unwrap();

// close and dismount the database
conn.execute("alter database close normal", &()).unwrap();
conn.execute("alter database dismount", &()).unwrap();

// finish shutdown
conn.shutdown_database(oracle::ShutdownMode::Final).unwrap();

Same with shutdown abort on sqlplus.

use oracle::{Connector, AuthMode, ShutdownMode};
// connect
let conn = Connector::new("sys", "change_on_install", "")
             .auth_mode(AuthMode::SYSDBA) // connect as sysdba
             .connect().unwrap();

// 'shutdown abort'
conn.shutdown_database(ShutdownMode::Abort).unwrap();

// The database is aborted here.

Trait Implementations

impl Drop for Connection
[src]

[src]

Executes the destructor for this type. Read more