pub struct ODBCConnection<'a, AC: AutocommitMode>(/* private fields */);Implementations§
Source§impl<'a, AC: AutocommitMode> ODBCConnection<'a, AC>
impl<'a, AC: AutocommitMode> ODBCConnection<'a, AC>
Sourcepub fn raw(&self) -> &Connection<'a, AC>
pub fn raw(&self) -> &Connection<'a, AC>
Examples found in repository?
More examples
examples/connect_pool.rs (line 16)
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§
impl Send for ODBCConnection<'static, AutocommitOff>
impl Send for ODBCConnection<'static, AutocommitOn>
Auto Trait Implementations§
impl<'a, AC> Freeze for ODBCConnection<'a, AC>
impl<'a, AC> RefUnwindSafe for ODBCConnection<'a, AC>where
AC: RefUnwindSafe,
impl<'a, AC> !Send for ODBCConnection<'a, AC>
impl<'a, AC> !Sync for ODBCConnection<'a, AC>
impl<'a, AC> Unpin for ODBCConnection<'a, AC>where
AC: Unpin,
impl<'a, AC> UnsafeUnpin for ODBCConnection<'a, AC>
impl<'a, AC> UnwindSafe for ODBCConnection<'a, AC>where
AC: UnwindSafe,
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