pub struct OracleConnectionManager { /* private fields */ }
Expand description
A bb8::ManageConnection
for oracle::Connection
s.
§Example
use std::thread;
use bb8_oracle::OracleConnectionManager;
let manager = OracleConnectionManager::new("user", "password", "localhost");
let pool = bb8::Pool::builder()
.max_size(15)
.build(manager).await
.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<U: Into<String>, P: Into<String>, C: Into<String>>(
username: U,
password: P,
connect_string: C,
) -> OracleConnectionManager
pub fn new<U: Into<String>, P: Into<String>, C: Into<String>>( username: U, password: P, connect_string: C, ) -> 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 = Arc<Connection>
type Connection = Arc<Connection>
The connection type this manager deals with.
Source§async fn connect(&self) -> Result<Self::Connection, Self::Error>
async fn connect(&self) -> Result<Self::Connection, Self::Error>
Attempts to create a new connection.
Source§async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>
Determines if the connection is still connected to the database.
Source§fn has_broken(&self, conn: &mut Self::Connection) -> bool
fn has_broken(&self, conn: &mut Self::Connection) -> bool
Synchronously determine if the connection is no longer usable, if possible.
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