- java.lang.Object
-
- com.appslandia.common.record.DbContext
-
- All Implemented Interfaces:
AutoCloseable
public class DbContext extends Object implements AutoCloseable
- Author:
- Loc Ha
-
-
Constructor Summary
Constructors Modifier Constructor Description DbContext()protectedDbContext(ConnectionImpl conn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertTransactional()voidclose()voidcommit()intdelete(String tableName, Key key)intdelete(String tableName, Key key, boolean addBatch)voidexecuteBatch()booleanexecuteExists(String sql)booleanexecuteExists(String pSql, Object... params)booleanexecuteExists(String pSql, Map<String,Object> params)List<Record>executeList(String sql)<T> List<T>executeList(String sql, ResultSetMapper<T> mapper, List<T> list)<T> List<Record>executeList(String pSql, Object... params)<T> List<T>executeList(String pSql, Object[] params, ResultSetMapper<T> mapper, List<T> list)<T> List<Record>executeList(String pSql, Map<String,Object> params)<T> List<T>executeList(String pSql, Map<String,Object> params, ResultSetMapper<T> mapper, List<T> list)<K,V>
Map<K,V>executeMap(String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map)<K,V>
Map<K,V>executeMap(String pSql, Object[] params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map)<K,V>
Map<K,V>executeMap(String pSql, Object[] params, String keyColumn, String valueColumn, Map<K,V> map)<K,V>
Map<K,V>executeMap(String sql, String keyColumn, String valueColumn, Map<K,V> map)<K,V>
Map<K,V>executeMap(String pSql, Map<String,Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map)<K,V>
Map<K,V>executeMap(String pSql, Map<String,Object> params, String keyColumn, String valueColumn, Map<K,V> map)voidexecuteNStream(String pSql, Object[] params, String streamLabel, Writer out, ResultSetHandler handler)voidexecuteNStream(String sql, String streamLabel, Writer out, ResultSetHandler handler)voidexecuteNStream(String pSql, Map<String,Object> params, String streamLabel, Writer out, ResultSetHandler handler)voidexecuteQuery(String sql, ResultSetHandler handler)voidexecuteQuery(String pSql, Object[] params, ResultSetHandler handler)voidexecuteQuery(String pSql, Map<String,Object> params, ResultSetHandler handler)<T> TexecuteScalar(String sql)<T> TexecuteScalar(String pSql, Object... params)<T> TexecuteScalar(String pSql, Map<String,Object> params)RecordexecuteSingle(String sql)<T> TexecuteSingle(String sql, ResultSetMapper<T> mapper)RecordexecuteSingle(String pSql, Object... params)<T> TexecuteSingle(String pSql, Object[] params, ResultSetMapper<T> mapper)RecordexecuteSingle(String pSql, Map<String,Object> params)<T> TexecuteSingle(String pSql, Map<String,Object> params, ResultSetMapper<T> mapper)voidexecuteStream(String pSql, Object[] params, String streamLabel, OutputStream out, ResultSetHandler handler)voidexecuteStream(String pSql, Object[] params, String streamLabel, Writer out, ResultSetHandler handler)voidexecuteStream(String sql, String streamLabel, OutputStream out, ResultSetHandler handler)voidexecuteStream(String sql, String streamLabel, Writer out, ResultSetHandler handler)voidexecuteStream(String pSql, Map<String,Object> params, String streamLabel, OutputStream out, ResultSetHandler handler)voidexecuteStream(String pSql, Map<String,Object> params, String streamLabel, Writer out, ResultSetHandler handler)intexecuteUpdate(String sql)intexecuteUpdate(String pSql, Object... params)intexecuteUpdate(String pSql, Object[] params, boolean addBatch)intexecuteUpdate(String pSql, Map<String,Object> params)intexecuteUpdate(String pSql, Map<String,Object> params, boolean addBatch)booleanexists(String tableName, Key key)RecordgetRecord(String tableName, Key key)TablegetTable(String tableName)voidinsert(String tableName, Record record)Objectinsert(String tableName, Record record, boolean addBatch)booleanisTransactional()protected StatementImplprepareStatement(String pSql, Map<String,Object> params)voidrollback()voidsetTransactional(boolean transactional)intupdate(String tableName, Record record)intupdate(String tableName, Record record, boolean addBatch)
-
-
-
Constructor Detail
-
DbContext
public DbContext()
-
DbContext
protected DbContext(ConnectionImpl conn)
-
-
Method Detail
-
insert
public void insert(String tableName, Record record) throws SQLException
- Throws:
SQLException
-
insert
public Object insert(String tableName, Record record, boolean addBatch) throws SQLException
- Throws:
SQLException
-
update
public int update(String tableName, Record record) throws SQLException
- Throws:
SQLException
-
update
public int update(String tableName, Record record, boolean addBatch) throws SQLException
- Throws:
SQLException
-
delete
public int delete(String tableName, Key key) throws SQLException
- Throws:
SQLException
-
delete
public int delete(String tableName, Key key, boolean addBatch) throws SQLException
- Throws:
SQLException
-
getRecord
public Record getRecord(String tableName, Key key) throws SQLException
- Throws:
SQLException
-
exists
public boolean exists(String tableName, Key key) throws SQLException
- Throws:
SQLException
-
prepareStatement
protected StatementImpl prepareStatement(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeList
public List<Record> executeList(String sql) throws SQLException
- Throws:
SQLException
-
executeList
public <T> List<Record> executeList(String pSql, Object... params) throws SQLException
- Throws:
SQLException
-
executeList
public <T> List<Record> executeList(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeSingle
public Record executeSingle(String sql) throws SQLException
- Throws:
SQLException
-
executeSingle
public Record executeSingle(String pSql, Object... params) throws SQLException
- Throws:
SQLException
-
executeSingle
public Record executeSingle(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String pSql, Object... params) throws SQLException
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String pSql, Object[] params, boolean addBatch) throws SQLException
- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String pSql, Map<String,Object> params, boolean addBatch) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String pSql, Object[] params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String pSql, Map<String,Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String sql, String keyColumn, String valueColumn, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String pSql, Object[] params, String keyColumn, String valueColumn, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeMap
public <K,V> Map<K,V> executeMap(String pSql, Map<String,Object> params, String keyColumn, String valueColumn, Map<K,V> map) throws SQLException
- Throws:
SQLException
-
executeList
public <T> List<T> executeList(String sql, ResultSetMapper<T> mapper, List<T> list) throws SQLException
- Throws:
SQLException
-
executeList
public <T> List<T> executeList(String pSql, Object[] params, ResultSetMapper<T> mapper, List<T> list) throws SQLException
- Throws:
SQLException
-
executeList
public <T> List<T> executeList(String pSql, Map<String,Object> params, ResultSetMapper<T> mapper, List<T> list) throws SQLException
- Throws:
SQLException
-
executeSingle
public <T> T executeSingle(String sql, ResultSetMapper<T> mapper) throws SQLException
- Throws:
SQLException
-
executeSingle
public <T> T executeSingle(String pSql, Object[] params, ResultSetMapper<T> mapper) throws SQLException
- Throws:
SQLException
-
executeSingle
public <T> T executeSingle(String pSql, Map<String,Object> params, ResultSetMapper<T> mapper) throws SQLException
- Throws:
SQLException
-
executeScalar
public <T> T executeScalar(String sql) throws SQLException
- Throws:
SQLException
-
executeScalar
public <T> T executeScalar(String pSql, Object... params) throws SQLException
- Throws:
SQLException
-
executeScalar
public <T> T executeScalar(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeExists
public boolean executeExists(String sql) throws SQLException
- Throws:
SQLException
-
executeExists
public boolean executeExists(String pSql, Object... params) throws SQLException
- Throws:
SQLException
-
executeExists
public boolean executeExists(String pSql, Map<String,Object> params) throws SQLException
- Throws:
SQLException
-
executeQuery
public void executeQuery(String sql, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeQuery
public void executeQuery(String pSql, Object[] params, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeQuery
public void executeQuery(String pSql, Map<String,Object> params, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String sql, String streamLabel, OutputStream out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String pSql, Object[] params, String streamLabel, OutputStream out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String pSql, Map<String,Object> params, String streamLabel, OutputStream out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String sql, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String pSql, Object[] params, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeStream
public void executeStream(String pSql, Map<String,Object> params, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeNStream
public void executeNStream(String sql, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeNStream
public void executeNStream(String pSql, Object[] params, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeNStream
public void executeNStream(String pSql, Map<String,Object> params, String streamLabel, Writer out, ResultSetHandler handler) throws Exception
- Throws:
Exception
-
executeBatch
public void executeBatch() throws SQLException- Throws:
SQLException
-
setTransactional
public void setTransactional(boolean transactional) throws SQLException- Throws:
SQLException
-
isTransactional
public boolean isTransactional() throws SQLException- Throws:
SQLException
-
commit
public void commit() throws SQLException- Throws:
SQLException
-
rollback
public void rollback() throws SQLException- Throws:
SQLException
-
assertTransactional
protected void assertTransactional() throws SQLException- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException
-
getTable
public Table getTable(String tableName) throws UncheckedSQLException
- Throws:
UncheckedSQLException
-
-