public final class Manager extends java.lang.Object implements Constant, SqlRunner
Constant.JdbcProperty, Constant.UpdateStrategy| 限定符和类型 | 方法和说明 |
|---|---|
java.sql.Connection |
beginTransaction()
Initiates a database transaction.
|
void |
disposePool()
dispose pool
|
void |
endTransaction(boolean commit)
Releases connection used for the transaction and performs a commit or rollback.
|
protected static void |
fillPrepareStatement(java.sql.PreparedStatement ps,
java.lang.Object[] argList)
填充PreparedStatement中的参数对象
|
java.sql.Connection |
getConnection()
Gets an auto commit connection.
|
static Manager |
getInstance()
Returns the manager singleton instance.
|
static <T> T |
getObject(java.sql.ResultSet rs,
int columnIndex,
java.lang.Class<T> type)
For compatibility with old version
ResultSet without getObject(int,Class) method |
static void |
injectProperties(java.util.EnumMap<Constant.JdbcProperty,java.lang.String> properties)
inject properties to
databasePropertiesbe effected only while called before initializing singleton instance |
static void |
injectProperties(java.util.Map<java.lang.String,java.lang.String> properties)
inject properties to
databasePropertiesbe effected only while called before initializing singleton instance |
void |
loadProperties(java.util.Properties properties)
configure with the parameters given in the properties object
|
void |
releaseConnection(java.sql.Connection c)
Releases the database connection.
|
<T> T |
runAsTransaction(java.util.concurrent.Callable<T> fun)
Run
Callable<T> as a transaction. |
void |
runAsTransaction(java.lang.Runnable fun)
Run
Runnable as a transaction.no return |
<T> java.util.List<T> |
runSqlAsList(java.lang.Class<T> targetType,
java.lang.String sql,
java.lang.Object... argList)
Load all the elements using a SQL statement specifying a fields to be retrieved.
|
java.util.List<BaseBean> |
runSqlAsList(java.lang.String sql,
java.lang.Object... argList)
Load all the elements using a SQL statement specifying a list of fields to be retrieved.
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
runSqlForMap(java.util.Map<java.lang.String,java.lang.Class<?>> targetType,
java.lang.String sql,
java.lang.Object... argList)
Load all the elements using a SQL statement specifying a list of fields to be retrieved.
|
<T> T |
runSqlForValue(java.lang.Class<T> targetType,
java.lang.String sql,
java.lang.Object... argList)
Load all the elements using a SQL statement specifying a row of a field to be retrieved.
|
void |
setDebug(boolean isDebug) |
protected static void |
setPreparedStatement(java.sql.PreparedStatement ps,
int pos,
java.lang.Object value,
int sqlType) |
public static final void injectProperties(java.util.Map<java.lang.String,java.lang.String> properties)
databasePropertiesproperties - JdbcPropertypublic static final void injectProperties(java.util.EnumMap<Constant.JdbcProperty,java.lang.String> properties)
databasePropertiesproperties - public static Manager getInstance()
public void disposePool()
public void loadProperties(java.util.Properties properties)
properties - the properties object to be usedpublic java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLExceptionpublic void releaseConnection(java.sql.Connection c)
public java.sql.Connection beginTransaction() throws java.sql.SQLException
java.sql.SQLExceptionpublic void endTransaction(boolean commit) throws java.sql.SQLException
commit - tells whether this connection should be committed
true for commit(), false for rollback()java.sql.SQLExceptionpublic <T> T runAsTransaction(java.util.concurrent.Callable<T> fun) throws RuntimeDaoException
SqlRunnerCallable<T> as a transaction.SQLException threw by Callable<T> is wrapped into RuntimeExceptionNullPointerException if fun be nullrunAsTransaction 在接口中 SqlRunnerT - type of return resultfun - RuntimeDaoExceptionpublic void runAsTransaction(java.lang.Runnable fun) throws RuntimeDaoException
Runnable as a transaction.no returnrunAsTransaction 在接口中 SqlRunnerfun - DaoExceptionRuntimeDaoExceptionSqlRunner.runAsTransaction(Runnable)public static <T> T getObject(java.sql.ResultSet rs, int columnIndex, java.lang.Class<T> type) throws java.sql.SQLException
ResultSet without getObject(int,Class) methodrs - columnIndex - type - java.sql.SQLExceptionpublic java.util.List<java.util.Map<java.lang.String,java.lang.Object>> runSqlForMap(java.util.Map<java.lang.String,java.lang.Class<?>> targetType, java.lang.String sql, java.lang.Object... argList) throws RuntimeDaoException
SqlRunnerrunSqlForMap 在接口中 SqlRunnertargetType - map of target type for column name or nullsql - the SQL statement for retrievingargList - the arguments to use fill given prepared statement,may be nullRuntimeDaoExceptionpublic java.util.List<BaseBean> runSqlAsList(java.lang.String sql, java.lang.Object... argList) throws RuntimeDaoException
SqlRunnerrunSqlAsList 在接口中 SqlRunnersql - the SQL statement for retrievingargList - the arguments to use fill given prepared statement,may be nullRuntimeDaoExceptionpublic <T> java.util.List<T> runSqlAsList(java.lang.Class<T> targetType, java.lang.String sql, java.lang.Object... argList) throws RuntimeDaoException
SqlRunnerrunSqlAsList 在接口中 SqlRunnertargetType - target type for column or nullsql - the SQL statement for retrievingargList - the arguments to use fill given prepared statement,may be nullRuntimeDaoExceptionpublic <T> T runSqlForValue(java.lang.Class<T> targetType, java.lang.String sql, java.lang.Object... argList) throws RuntimeDaoException
SqlRunnerrunSqlForValue 在接口中 SqlRunnertargetType - target type for column or nullsql - the SQL statement for retrievingargList - the arguments to use fill given prepared statement,may be nullRuntimeDaoExceptionprotected static void fillPrepareStatement(java.sql.PreparedStatement ps, java.lang.Object[] argList) throws DaoException
ps - argList - java.sql.SQLExceptionDaoExceptionprotected static void setPreparedStatement(java.sql.PreparedStatement ps, int pos, java.lang.Object value, int sqlType) throws java.sql.SQLException
java.sql.SQLExceptionpublic void setDebug(boolean isDebug)
Copyright © 2019. All Rights Reserved.