Struct hdbconnect::Connection
source · pub struct Connection { /* private fields */ }
Expand description
Connection object.
The connection to the database.
Example
use hdbconnect::{Connection, IntoConnectParams};
let params = "hdbsql://my_user:my_passwd@the_host:2222"
.into_connect_params()
.unwrap();
let mut connection = Connection::new(params).unwrap();
Implementations§
source§impl Connection
impl Connection
sourcepub fn new(params: ConnectParams) -> HdbResult<Connection>
pub fn new(params: ConnectParams) -> HdbResult<Connection>
Factory method for authenticated connections.
sourcepub fn set_auto_commit(&mut self, ac: bool) -> HdbResult<()>
pub fn set_auto_commit(&mut self, ac: bool) -> HdbResult<()>
Sets the connection’s auto-commit behavior for future calls.
sourcepub fn is_auto_commit(&self) -> HdbResult<bool>
pub fn is_auto_commit(&self) -> HdbResult<bool>
Returns the connection’s auto-commit behavior.
sourcepub fn set_fetch_size(&mut self, fetch_size: u32) -> HdbResult<()>
pub fn set_fetch_size(&mut self, fetch_size: u32) -> HdbResult<()>
Configures the connection’s fetch size for future calls.
sourcepub fn get_lob_read_length(&self) -> HdbResult<i32>
pub fn get_lob_read_length(&self) -> HdbResult<i32>
Configures the connection’s lob read length for future calls.
sourcepub fn set_lob_read_length(&mut self, lob_read_length: i32) -> HdbResult<()>
pub fn set_lob_read_length(&mut self, lob_read_length: i32) -> HdbResult<()>
Configures the connection’s lob read length for future calls.
sourcepub fn get_server_resource_consumption_info(
&self
) -> HdbResult<ServerResourceConsumptionInfo>
pub fn get_server_resource_consumption_info(
&self
) -> HdbResult<ServerResourceConsumptionInfo>
sourcepub fn get_call_count(&self) -> HdbResult<i32>
pub fn get_call_count(&self) -> HdbResult<i32>
Returns the number of roundtrips to the database that have been done through this connection.
sourcepub fn set_application_user(&self, appl_user: &str) -> HdbResult<()>
pub fn set_application_user(&self, appl_user: &str) -> HdbResult<()>
Sets client information into a session variable on the server.
Example:
connection.set_application_user("K2209657")?;
sourcepub fn set_application_version(&mut self, version: &str) -> HdbResult<()>
pub fn set_application_version(&mut self, version: &str) -> HdbResult<()>
Sets client information into a session variable on the server.
Example:
connection.set_application_version("5.3.23")?;
sourcepub fn set_application_source(&mut self, source: &str) -> HdbResult<()>
pub fn set_application_source(&mut self, source: &str) -> HdbResult<()>
Sets client information into a session variable on the server.
Example:
connection.set_application_source("5.3.23","update_customer.rs")?;
sourcepub fn statement(&mut self, stmt: &str) -> HdbResult<HdbResponse>
pub fn statement(&mut self, stmt: &str) -> HdbResult<HdbResponse>
Executes a statement on the database.
This generic method can handle all kinds of calls, and thus has the most complex return type. In many cases it will be more appropriate to use one of the methods query(), dml(), exec(), which have the adequate simple result type you usually want.
sourcepub fn query(&mut self, stmt: &str) -> HdbResult<ResultSet>
pub fn query(&mut self, stmt: &str) -> HdbResult<ResultSet>
Executes a statement and expects a single ResultSet.
sourcepub fn dml(&mut self, stmt: &str) -> HdbResult<usize>
pub fn dml(&mut self, stmt: &str) -> HdbResult<usize>
Executes a statement and expects a single number of affected rows.
sourcepub fn exec(&mut self, stmt: &str) -> HdbResult<()>
pub fn exec(&mut self, stmt: &str) -> HdbResult<()>
Executes a statement and expects a plain success.
sourcepub fn prepare(&self, stmt: &str) -> HdbResult<PreparedStatement>
pub fn prepare(&self, stmt: &str) -> HdbResult<PreparedStatement>
Prepares a statement and returns a handle to it.
Note that the handle keeps using the same connection.
sourcepub fn spawn(&self) -> HdbResult<Connection>
pub fn spawn(&self) -> HdbResult<Connection>
Creates a new connection object with the same settings and authentication.
sourcepub fn multiple_statements_ignore_err<S: AsRef<str>>(&mut self, stmts: Vec<S>)
pub fn multiple_statements_ignore_err<S: AsRef<str>>(&mut self, stmts: Vec<S>)
Utility method to fire a couple of statements, ignoring errors and return values
sourcepub fn multiple_statements<S: AsRef<str>>(
&mut self,
stmts: Vec<S>
) -> HdbResult<()>
pub fn multiple_statements<S: AsRef<str>>(
&mut self,
stmts: Vec<S>
) -> HdbResult<()>
Utility method to fire a couple of statements, ignoring their return values; the method returns with the first error, or with ()
sourcepub fn pop_warnings(&self) -> HdbResult<Option<Vec<ServerError>>>
pub fn pop_warnings(&self) -> HdbResult<Option<Vec<ServerError>>>
Returns warnings that were returned from the server since the last call to this method.
sourcepub fn get_resource_manager(&self) -> Box<dyn ResourceManager>
pub fn get_resource_manager(&self) -> Box<dyn ResourceManager>
Returns an implementation of dist_tx::rm::ResourceManager
that is
based on this connection.
sourcepub fn execute_with_debuginfo(
&mut self,
stmt: &str,
module: &str,
line: i32
) -> HdbResult<HdbResponse>
pub fn execute_with_debuginfo(
&mut self,
stmt: &str,
module: &str,
line: i32
) -> HdbResult<HdbResponse>
Tools like debuggers can provide additional information while stepping through a source