Package com.appslandia.common.record
Class DbManager
- java.lang.Object
-
- com.appslandia.common.record.DbManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class DbManager extends java.lang.Object implements java.lang.AutoCloseable- Author:
- Loc Ha
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertNotAutoCommit()protected voidassertNotClosed()voidclose()voidcommit()intdelete(Record key, Table table)protected intdelete(Record key, Table table, boolean addBatch)voiddeleteBatch(Record key, Table table)voidexecuteBatch()java.util.List<Record>executeList(java.lang.String sql)<T> java.util.List<T>executeList(java.lang.String sql, ResultSetMapper<T> mapper)<T> java.util.List<T>executeList(java.lang.String sql, ResultSetMapper<T> mapper, java.util.List<T> list)<T> java.util.List<Record>executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params)<T> java.util.List<T>executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper)<T> java.util.List<T>executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper, java.util.List<T> list)<K,V>
java.util.Map<K,V>executeMap(java.lang.String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper)<K,V>
java.util.Map<K,V>executeMap(java.lang.String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, java.util.Map<K,V> map)<K,V>
java.util.Map<K,V>executeMap(java.lang.String sql, java.lang.String keyColumn, java.lang.String valueColumn)<K,V>
java.util.Map<K,V>executeMap(java.lang.String sql, java.lang.String keyColumn, java.lang.String valueColumn, java.util.Map<K,V> map)<K,V>
java.util.Map<K,V>executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper)<K,V>
java.util.Map<K,V>executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, java.util.Map<K,V> map)<K,V>
java.util.Map<K,V>executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String keyColumn, java.lang.String valueColumn)<K,V>
java.util.Map<K,V>executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String keyColumn, java.lang.String valueColumn, java.util.Map<K,V> map)voidexecuteQuery(java.lang.String sql, ResultSetHandler handler)voidexecuteQuery(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetHandler handler)<T> TexecuteScalar(java.lang.String sql)<T> TexecuteScalar(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params)RecordexecuteSingle(java.lang.String sql)<T> TexecuteSingle(java.lang.String sql, ResultSetMapper<T> mapper)RecordexecuteSingle(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params)<T> TexecuteSingle(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper)intexecuteUpdate(java.lang.String sql)intexecuteUpdate(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params)booleanexists(Record key, Table table)booleangetAutoCommit()java.sql.ConnectiongetConnection()static javax.sql.DataSourcegetDataSource()RecordgetRecord(Record key, Table table)java.lang.Objectinsert(Record record, Table table)protected java.lang.Objectinsert(Record record, Table table, boolean addBatch)voidinsertBatch(Record record, Table table)voidrollback()voidsetAutoCommit(boolean autoCommit)static voidsetDataSource(javax.sql.DataSource ds)protected voidsetParameter(StatementImpl stat, java.lang.String parameterName, java.lang.Object val, int sqlType)protected voidsetParameters(StatementImpl stat, java.util.Map<java.lang.String,java.lang.Object> params)intupdate(Record record, Table table)protected intupdate(Record record, Table table, boolean addBatch)voidupdateBatch(Record record, Table table)
-
-
-
Method Detail
-
getConnection
public java.sql.Connection getConnection()
-
setParameter
protected void setParameter(StatementImpl stat, java.lang.String parameterName, java.lang.Object val, int sqlType) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setParameters
protected void setParameters(StatementImpl stat, java.util.Map<java.lang.String,java.lang.Object> params) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
insert
public java.lang.Object insert(Record record, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
insertBatch
public void insertBatch(Record record, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
insert
protected java.lang.Object insert(Record record, Table table, boolean addBatch) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
update
public int update(Record record, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
updateBatch
public void updateBatch(Record record, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
update
protected int update(Record record, Table table, boolean addBatch) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
delete
public int delete(Record key, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
deleteBatch
public void deleteBatch(Record key, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
delete
protected int delete(Record key, Table table, boolean addBatch) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getRecord
public Record getRecord(Record key, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
exists
public boolean exists(Record key, Table table) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeList
public java.util.List<Record> executeList(java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeList
public <T> java.util.List<Record> executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeSingle
public Record executeSingle(java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeSingle
public Record executeSingle(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String sql, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, java.util.Map<K,V> map) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<K> keyMapper, ResultSetMapper<V> valueMapper, java.util.Map<K,V> map) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String sql, java.lang.String keyColumn, java.lang.String valueColumn) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String sql, java.lang.String keyColumn, java.lang.String valueColumn, java.util.Map<K,V> map) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String keyColumn, java.lang.String valueColumn) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeMap
public <K,V> java.util.Map<K,V> executeMap(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String keyColumn, java.lang.String valueColumn, java.util.Map<K,V> map) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeList
public <T> java.util.List<T> executeList(java.lang.String sql, ResultSetMapper<T> mapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeList
public <T> java.util.List<T> executeList(java.lang.String sql, ResultSetMapper<T> mapper, java.util.List<T> list) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeList
public <T> java.util.List<T> executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeList
public <T> java.util.List<T> executeList(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper, java.util.List<T> list) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeSingle
public <T> T executeSingle(java.lang.String sql, ResultSetMapper<T> mapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeSingle
public <T> T executeSingle(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetMapper<T> mapper) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeScalar
public <T> T executeScalar(java.lang.String sql) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeScalar
public <T> T executeScalar(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
executeQuery
public void executeQuery(java.lang.String sql, ResultSetHandler handler) throws java.lang.Exception- Throws:
java.lang.Exception
-
executeQuery
public void executeQuery(java.lang.String pSql, java.util.Map<java.lang.String,java.lang.Object> params, ResultSetHandler handler) throws java.lang.Exception- Throws:
java.lang.Exception
-
executeBatch
public void executeBatch() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
rollback
public void rollback() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
assertNotAutoCommit
protected void assertNotAutoCommit() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
assertNotClosed
protected void assertNotClosed() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
close
public void close() throws java.sql.SQLException- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.sql.SQLException
-
getDataSource
public static javax.sql.DataSource getDataSource() throws java.lang.IllegalStateException- Throws:
java.lang.IllegalStateException
-
setDataSource
public static void setDataSource(javax.sql.DataSource ds)
-
-