Struct r2d2_oracle::OracleConnectionManager
source · 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
§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