Skip to main content

ODBCConnectionManager

Struct ODBCConnectionManager 

Source
pub struct ODBCConnectionManager { /* private fields */ }

Implementations§

Source§

impl ODBCConnectionManager

Source

pub fn new<S: Into<String>>(connection_string: S) -> ODBCConnectionManager

Creates a new ODBCConnectionManager.

Examples found in repository?
examples/execute_query.rs (line 20)
18fn connect() -> Result<(), Box<dyn Error>> {
19    // TODO: Update with your actual database connection details
20    let manager = ODBCConnectionManager::new("DRIVER={IBM DB2 ODBC DRIVER};DATABASE=SAMPLE;HOSTNAME=db.example.com;PORT=50000;UID=db_user;PWD=YourPassword123");
21    let pool = r2d2::Pool::new(manager).unwrap();
22    let pool = pool.clone();
23    let pool_conn = pool.get().unwrap();
24    let conn = pool_conn.raw();
25    execute_statement(&conn)
26}
More examples
Hide additional examples
examples/connect_pool.rs (line 8)
6fn main() {
7    // TODO: Update with your actual database connection details
8    let manager = ODBCConnectionManager::new("DRIVER={IBM DB2 ODBC DRIVER};DATABASE=SAMPLE;HOSTNAME=db.example.com;PORT=50000;UID=db_user;PWD=YourPassword123");
9    let pool = r2d2::Pool::new(manager).unwrap();
10
11    let mut children = vec![];
12    for i in 0..10i32 {
13        let pool = pool.clone();
14        let pool_conn = pool.get().unwrap();
15        children.push(thread::spawn(move || {
16            let conn = pool_conn.raw();
17            let stmt = Statement::with_parent(&conn).unwrap();
18            if let Data(mut stmt) = stmt.exec_direct("select * from dbtest.GLWTACT").unwrap() {
19                while let Some(mut cursor) = stmt.fetch().unwrap() {
20                    if let Some(val) = cursor.get_data::<&str>(1).unwrap() {
21                        println!("THREAD {} {}", i, val);
22                    }
23                }
24            }
25        }));
26    }
27
28    for child in children {
29        let _ = child.join();
30    }
31}

Trait Implementations§

Source§

impl Debug for ODBCConnectionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ManageConnection for ODBCConnectionManager

Source§

type Connection = ODBCConnection<'static, AutocommitOn>

The connection type this manager deals with.
Source§

type Error = ODBCError

The error type returned by Connections.
Source§

fn connect(&self) -> Result<Self::Connection, Self::Error>

Attempts to create a new connection.
Source§

fn is_valid(&self, _conn: &mut Self::Connection) -> Result<(), Self::Error>

Determines if the connection is still connected to the database. Read more
Source§

fn has_broken(&self, _conn: &mut Self::Connection) -> bool

Quickly determines if the connection is no longer usable. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.