Package com.groiss.store.external
Interface XStore
- All Superinterfaces:
AutoCloseable
,SilentCloseable
Can be used to access other databases.
Provides a level of abstraction above pure JDBC access.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Commits the connection and releases it.void
commit()
Commit the operations on this XStore.int
executeStatement
(String statement, Object... bindVars) Execute a SQL statement.Get a connection to the external database.Get the description.getId()
Get the unique id.Execute a SQL query which returns a list of rows.Execute a SQL query which returns one row.int
Get the Query timeoutExecute a SQL query which returns one value.Execute a SQL query which returns one value.void
rollback()
Roll back the operations on this XStore.
-
Method Details
-
getId
String getId()Get the unique id.- Returns:
- the id
-
getDescription
String getDescription()Get the description.- Returns:
- the description
-
getTimeout
int getTimeout()Get the Query timeout- Returns:
- the timeout (in seconds)
-
getConnection
Connection getConnection()Get a connection to the external database.If such a connection has not been used in the current UserTransaction, a new one is created, else the existing connection is reused.
Autocommit is off for the connection and the transaction isolation level is set to RECD_COMMITTED.
- Returns:
- the connection
-
commit
void commit()Commit the operations on this XStore. Does not release the connection. -
rollback
void rollback()Roll back the operations on this XStore. Does not release the connection. -
close
void close()Commits the connection and releases it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSilentCloseable
-
getValue
Execute a SQL query which returns one value. The query is executed, the first row fetched and from the result set the first element is returned.- Parameters:
query
- the SQL query text.bindVars
- if the query contains placeholders for binding variables this parameter should contain the values- Returns:
- the value as object.
-
getValue
Execute a SQL query which returns one value. The query is executed, the first row fetched and from the result set the first element is returned.- Parameters:
sqlType
- if a special mapping of the database type to java type is needed, the type (java.sql.Types) can be specified here.query
- the SQL statement text.bindVars
- if the query contains placeholders for binding variables, this should contain the values- Returns:
- the value as object.
-
getRow
Execute a SQL query which returns one row. The query is executed, the first row is fetched returned.- Parameters:
query
- the SQL statement text.bindVars
- if the query contains placeholders for binding variables, this should contain the values- Returns:
- the row
-
getList
Execute a SQL query which returns a list of rows.- Parameters:
query
- the SQL statement text.bindVars
- if the query contains placeholders for binding variables, this should contain the values- Returns:
- the list of rows
-
executeStatement
Execute a SQL statement.- Parameters:
statement
- the SQL statement text.bindVars
- if the statement contains placeholders for binding variables this parameter should contain the values- Returns:
- the number of rows changed
-