[−][src]Struct hdbconnect::Connection
A synchronous connection to the database.
Implementations
impl Connection
[src]
pub fn new<P: IntoConnectParams>(p: P) -> HdbResult<Self>
[src]
Factory method for authenticated connections.
Example
use hdbconnect::Connection; let mut conn = Connection::new("hdbsql://my_user:my_passwd@the_host:2222").unwrap();
Errors
Several variants of HdbError
can occur.
pub fn statement<S: AsRef<str>>(&mut self, stmt: S) -> HdbResult<HdbResponse>
[src]
Executes a statement on the database.
This generic method can handle all kinds of calls,
and thus has the most generic return type.
In many cases it will be more convenient to use
one of the dedicated methods query()
, dml()
, exec()
below, which
internally convert the HdbResponse
to the
respective adequate simple result type.
Example
let mut response = connection.statement(&statement_string)?; // HdbResponse
Errors
Several variants of HdbError
can occur.
pub fn query<S: AsRef<str>>(&mut self, stmt: S) -> HdbResult<ResultSet>
[src]
Executes a statement and expects a single ResultSet
.
Should be used for query statements (like "SELECT ...") which return a single resultset.
Example
let mut rs = connection.query(&statement_string)?; // ResultSet
Errors
Several variants of HdbError
can occur.
pub fn dml<S: AsRef<str>>(&mut self, stmt: S) -> HdbResult<usize>
[src]
Executes a statement and expects a single number of affected rows.
Should be used for DML statements only, i.e., INSERT, UPDATE, DELETE, UPSERT.
Example
let count = connection.dml(&statement_string)?; //usize
Errors
Several variants of HdbError
can occur.
pub fn exec<S: AsRef<str>>(&mut self, stmt: S) -> HdbResult<()>
[src]
Executes a statement and expects a plain success.
Should be used for SQL commands like "ALTER SYSTEM ...".
Example
connection.exec(&statement_string)?;
Errors
Several variants of HdbError
can occur.
pub fn prepare<S: AsRef<str>>(&self, stmt: S) -> HdbResult<PreparedStatement>
[src]
Prepares a statement and returns a handle (a PreparedStatement
) to it.
Note that the PreparedStatement
keeps using the same database connection as
this Connection
.
Example
let query_string = "select * from phrases where ID = ? and text = ?"; let mut statement = connection.prepare(query_string)?; //PreparedStatement
Errors
Several variants of HdbError
can occur.
pub fn prepare_and_execute<S, T>(
&self,
stmt: S,
input: &T
) -> HdbResult<HdbResponse> where
S: AsRef<str>,
T: Serialize,
[src]
&self,
stmt: S,
input: &T
) -> HdbResult<HdbResponse> where
S: AsRef<str>,
T: Serialize,
pub fn commit(&mut self) -> HdbResult<()>
[src]
pub fn rollback(&mut self) -> HdbResult<()>
[src]
pub fn spawn(&self) -> HdbResult<Self>
[src]
Creates a new connection object with the same settings and authentication.
Errors
Several variants of HdbError
can occur.
pub fn multiple_statements_ignore_err<S: AsRef<str>>(&mut self, stmts: Vec<S>)
[src]
Utility method to fire a couple of statements, ignoring errors and return values.
Errors
Several variants of HdbError
can occur.
pub fn multiple_statements<S: AsRef<str>>(
&mut self,
stmts: Vec<S>
) -> HdbResult<()>
[src]
&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 ()
.
Errors
Several variants of HdbError
can occur.
pub fn pop_warnings(&self) -> HdbResult<Option<Vec<ServerError>>>
[src]
Returns warnings that were returned from the server since the last call to this method.
Errors
Only HdbError::Poison
can occur.
pub fn set_auto_commit(&mut self, ac: bool) -> HdbResult<()>
[src]
Sets the connection's auto-commit behavior for future calls.
Errors
Only HdbError::Poison
can occur.
pub fn is_auto_commit(&self) -> HdbResult<bool>
[src]
pub fn set_fetch_size(&mut self, fetch_size: u32) -> HdbResult<()>
[src]
pub fn get_lob_read_length(&self) -> HdbResult<u32>
[src]
pub fn set_lob_read_length(&mut self, l: u32) -> HdbResult<()>
[src]
Configures the connection's lob read length for future calls.
Errors
Only HdbError::Poison
can occur.
pub fn get_lob_write_length(&self) -> HdbResult<usize>
[src]
Configures the connection's lob write length for future calls.
The intention of the parameter is to allow reducing the number of roundtrips
to the database.
Values smaller than rust's buffer size (8k) will have little effect, since
each read() call to the Read impl in a HdbValue::LOBSTREAM
will cause at most one
write roundtrip to the database.
Errors
Only HdbError::Poison
can occur.
pub fn set_lob_write_length(&mut self, l: usize) -> HdbResult<()>
[src]
Configures the connection's lob write length for future calls.
Errors
Only HdbError::Poison
can occur.
pub fn id(&self) -> HdbResult<i32>
[src]
Returns the ID of the connection.
The ID is set by the server. Can be handy for logging.
Errors
Only HdbError::Poison
can occur.
pub fn server_usage(&self) -> HdbResult<ServerUsage>
[src]
Provides information about the the server-side resource consumption that is related to this Connection object.
Errors
Only HdbError::Poison
can occur.
pub fn get_call_count(&self) -> HdbResult<i32>
[src]
Returns the number of roundtrips to the database that have been done through this connection.
Errors
Only HdbError::Poison
can occur.
pub fn set_application<S: AsRef<str>>(&self, application: S) -> HdbResult<()>
[src]
Sets client information into a session variable on the server.
Example:
connection.set_application("MyApp, built in rust")?;
Errors
Only HdbError::Poison
can occur.
pub fn set_application_user<S: AsRef<str>>(&self, appl_user: S) -> HdbResult<()>
[src]
Sets client information into a session variable on the server.
Example:
connection.set_application_user("K2209657")?;
Errors
Only HdbError::Poison
can occur.
pub fn set_application_version<S: AsRef<str>>(
&mut self,
version: S
) -> HdbResult<()>
[src]
&mut self,
version: S
) -> HdbResult<()>
Sets client information into a session variable on the server.
Example:
connection.set_application_version("5.3.23")?;
Errors
Only HdbError::Poison
can occur.
pub fn set_application_source<S: AsRef<str>>(
&mut self,
source: S
) -> HdbResult<()>
[src]
&mut self,
source: S
) -> HdbResult<()>
Sets client information into a session variable on the server.
Example:
connection.set_application_source("update_customer.rs")?;
Errors
Only HdbError::Poison
can occur.
pub fn get_resource_manager(&self) -> Box<dyn ResourceManager>
[src]
Returns an implementation of dist_tx::rm::ResourceManager
that is
based on this connection.
pub fn execute_with_debuginfo<S: AsRef<str>>(
&mut self,
stmt: S,
module: S,
line: i32
) -> HdbResult<HdbResponse>
[src]
&mut self,
stmt: S,
module: S,
line: i32
) -> HdbResult<HdbResponse>
Tools like debuggers can provide additional information while stepping through a source.
Errors
Several variants of HdbError
can occur.
pub fn get_database_name(&self) -> HdbResult<Option<String>>
[src]
pub fn get_system_id(&self) -> HdbResult<Option<String>>
[src]
The system id is set by the server with the SAPSYSTEMNAME of the connected instance (for tracing and supportability purposes).
Errors
Only HdbError::Poison
can occur.
pub fn client_info(&self) -> HdbResult<Vec<(String, String)>>
[src]
Returns the information that is given to the server as client context.
Errors
Only HdbError::Poison
can occur.
pub fn connect_string(&self) -> HdbResult<String>
[src]
Returns a connect url (excluding the password) that reflects the options that were used to establish this connection.
Errors
Only HdbError::Poison
can occur.
pub fn get_full_version_string(&self) -> HdbResult<Option<String>>
[src]
Trait Implementations
impl Clone for Connection
[src]
pub fn clone(&self) -> Connection
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Connection
[src]
Auto Trait Implementations
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,