pub struct OracleConnectionManager { /* private fields */ }
Expand description
An r2d2::ManageConnection
for oracle::Connection
s.
§Example
use std::thread;
use r2d2_oracle::OracleConnectionManager;
let manager = OracleConnectionManager::new("user", "password", "localhost");
let pool = r2d2::Pool::builder()
.max_size(15)
.build(manager)
.unwrap();
for _ in 0..20 {
let pool = pool.clone();
thread::spawn(move || {
let conn = pool.get().unwrap();
// use the connection
// it will be returned to the pool when it falls out of scope.
});
}
Implementations§
Source§impl OracleConnectionManager
impl OracleConnectionManager
Sourcepub fn new(
username: &str,
password: &str,
connect_string: &str,
) -> OracleConnectionManager
pub fn new( username: &str, password: &str, connect_string: &str, ) -> OracleConnectionManager
Initialise the connection manager with the data needed to create new connections.
Refer to the documentation of oracle::Connection
for further details on the parameters.
§Example
let manager = OracleConnectionManager::new("user", "password", "localhost");
Sourcepub fn from_connector(connector: Connector) -> OracleConnectionManager
pub fn from_connector(connector: Connector) -> OracleConnectionManager
Initialise the connection manager with the data needed to create new connections using oracle::Connector
.
This allows setting additional connection data.
If a connection can be established only with a username, password and connect string, use new
instead.
§Example
// connect system/manager as sysdba
let mut connector = oracle::Connector::new("system", "manager", "");
connector.privilege(oracle::Privilege::Sysdba);
let manager = OracleConnectionManager::from_connector(connector);
Trait Implementations§
Source§impl Debug for OracleConnectionManager
impl Debug for OracleConnectionManager
Source§impl ManageConnection for OracleConnectionManager
impl ManageConnection for OracleConnectionManager
Source§type Connection = Connection
type Connection = Connection
The connection type this manager deals with.
Source§fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
Determines if the connection is still connected to the database. Read more
Source§fn has_broken(&self, conn: &mut Connection) -> bool
fn has_broken(&self, conn: &mut Connection) -> bool
Quickly determines if the connection is no longer usable. Read more
Auto Trait Implementations§
impl Freeze for OracleConnectionManager
impl RefUnwindSafe for OracleConnectionManager
impl Send for OracleConnectionManager
impl Sync for OracleConnectionManager
impl Unpin for OracleConnectionManager
impl UnwindSafe for OracleConnectionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more