[][src]Struct hdbconnect::Connection

pub struct Connection { /* fields omitted */ }

A connection to the database.

Methods

impl Connection[src]

pub fn new(params: ConnectParams) -> HdbResult<Connection>[src]

Factory method for authenticated connections.

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();

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 powerful 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

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

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

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)?;

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

pub fn commit(&mut self) -> HdbResult<()>[src]

Commits the current transaction.

pub fn rollback(&mut self) -> HdbResult<()>[src]

Rolls back the current transaction.

pub fn spawn(&self) -> HdbResult<Connection>[src]

Creates a new connection object with the same settings and authentication.

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

pub fn multiple_statements<S: AsRef<str>>(
    &mut self,
    stmts: Vec<S>
) -> HdbResult<()>
[src]

Utility method to fire a couple of statements, ignoring their return values; the method returns with the first error, or with ()

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.

pub fn set_auto_commit(&mut self, ac: bool) -> HdbResult<()>[src]

Sets the connection's auto-commit behavior for future calls.

pub fn is_auto_commit(&self) -> HdbResult<bool>[src]

Returns the connection's auto-commit behavior.

pub fn set_fetch_size(&mut self, fetch_size: u32) -> HdbResult<()>[src]

Configures the connection's fetch size for future calls.

pub fn get_lob_read_length(&self) -> HdbResult<i32>[src]

Configures the connection's lob read length for future calls.

pub fn set_lob_read_length(&mut self, l: i32) -> HdbResult<()>[src]

Configures the connection's lob read length for future calls.

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.

pub fn get_server_resource_consumption_info(
    &self
) -> HdbResult<ServerResourceConsumptionInfo>
[src]

pub fn get_call_count(&self) -> HdbResult<i32>[src]

Returns the number of roundtrips to the database that have been done through this connection.

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:

This example is not tested
connection.set_application_user("K2209657")?;

pub fn set_application_version<S: AsRef<str>>(
    &mut self,
    version: S
) -> HdbResult<()>
[src]

Sets client information into a session variable on the server.

Example:

This example is not tested
connection.set_application_version("5.3.23")?;

pub fn set_application_source<S: AsRef<str>>(
    &mut self,
    source: S
) -> HdbResult<()>
[src]

Sets client information into a session variable on the server.

Example:

This example is not tested
connection.set_application_source("5.3.23","update_customer.rs")?;

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]

Tools like debuggers can provide additional information while stepping through a source

pub fn get_database_name(&self) -> HdbResult<Option<String>>[src]

(MDC) Database name.

pub fn get_system_id(&self) -> HdbResult<Option<String>>[src]

The SystemID is set by the server with the SAPSYSTEMNAME of the connected instance (for tracing and supportability purposes).

pub fn get_full_version_string(&self) -> HdbResult<Option<String>>[src]

HANA Full version string.

Trait Implementations

impl Debug for Connection[src]

Auto Trait Implementations

impl Send for Connection

impl Sync for Connection

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self