Struct odbc_api::handles::Connection
source · [−]pub struct Connection<'c> { /* private fields */ }
Expand description
The connection handle references storage of all information about the connection to the data source, including status, transaction state, and error information.
Implementations
sourceimpl<'c> Connection<'c>
impl<'c> Connection<'c>
sourcepub unsafe fn new(handle: HDbc) -> Self
pub unsafe fn new(handle: HDbc) -> Self
Safety
Call this method only with a valid (successfully allocated) ODBC connection handle.
sourcepub fn connect(
&mut self,
data_source_name: &SqlText<'_>,
user: &SqlText<'_>,
pwd: &SqlText<'_>
) -> SqlResult<()>
pub fn connect(
&mut self,
data_source_name: &SqlText<'_>,
user: &SqlText<'_>,
pwd: &SqlText<'_>
) -> SqlResult<()>
Establishes connections to a driver and a data source.
Arguments
data_source_name
- Data source name. The data might be located on the same computer as the program, or on another computer somewhere on a network.user
- User identifier.pwd
- Authentication string (typically the password).
sourcepub fn connect_with_connection_string(
&mut self,
connection_string: &SqlText<'_>
) -> SqlResult<()>
pub fn connect_with_connection_string(
&mut self,
connection_string: &SqlText<'_>
) -> SqlResult<()>
An alternative to connect
. It supports data sources that require more connection
information than the three arguments in connect
and data sources that are not defined in
the system information.
sourcepub unsafe fn driver_connect(
&mut self,
connection_string: &SqlText<'_>,
parent_window: HWnd,
completed_connection_string: &mut OutputStringBuffer,
driver_completion: DriverConnectOption
) -> Option<SqlResult<()>>
pub unsafe fn driver_connect(
&mut self,
connection_string: &SqlText<'_>,
parent_window: HWnd,
completed_connection_string: &mut OutputStringBuffer,
driver_completion: DriverConnectOption
) -> Option<SqlResult<()>>
sourcepub fn disconnect(&mut self) -> SqlResult<()>
pub fn disconnect(&mut self) -> SqlResult<()>
Disconnect from an ODBC data source.
sourcepub fn allocate_statement(&self) -> SqlResult<StatementImpl<'_>>
pub fn allocate_statement(&self) -> SqlResult<StatementImpl<'_>>
Allocate a new statement handle. The Statement
must not outlive the Connection
.
sourcepub fn set_autocommit(&self, enabled: bool) -> SqlResult<()>
pub fn set_autocommit(&self, enabled: bool) -> SqlResult<()>
Specify the transaction mode. By default, ODBC transactions are in auto-commit mode (unless SQLSetConnectAttr and SQLSetConnectOption are not supported, which is unlikely). Switching from manual-commit mode to auto-commit mode automatically commits any open transaction on the connection.
sourcepub fn fetch_database_management_system_name(
&self,
buf: &mut Vec<SqlChar>
) -> SqlResult<()>
pub fn fetch_database_management_system_name(
&self,
buf: &mut Vec<SqlChar>
) -> SqlResult<()>
Fetch the name of the database management system used by the connection and store it into
the provided buf
.
sourcepub fn max_catalog_name_len(&self) -> SqlResult<u16>
pub fn max_catalog_name_len(&self) -> SqlResult<u16>
Maximum length of catalog names.
sourcepub fn max_schema_name_len(&self) -> SqlResult<u16>
pub fn max_schema_name_len(&self) -> SqlResult<u16>
Maximum length of schema names.
sourcepub fn max_table_name_len(&self) -> SqlResult<u16>
pub fn max_table_name_len(&self) -> SqlResult<u16>
Maximum length of table names.
sourcepub fn max_column_name_len(&self) -> SqlResult<u16>
pub fn max_column_name_len(&self) -> SqlResult<u16>
Maximum length of column names.
Trait Implementations
sourceimpl<'c> AsHandle for Connection<'c>
impl<'c> AsHandle for Connection<'c>
sourcefn as_handle(&self) -> Handle
fn as_handle(&self) -> Handle
The raw underlying ODBC handle used to talk to the ODBC C API. The handle must be valid.
sourcefn handle_type(&self) -> HandleType
fn handle_type(&self) -> HandleType
The type of the ODBC handle returned by as_handle
. This is a method rather than a constant
in order to make the type object safe. Read more
Auto Trait Implementations
impl<'c> RefUnwindSafe for Connection<'c>
impl<'c> !Send for Connection<'c>
impl<'c> !Sync for Connection<'c>
impl<'c> Unpin for Connection<'c>
impl<'c> UnwindSafe for Connection<'c>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more