|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.dbutils.AbstractQueryRunner
org.apache.commons.dbutils.QueryRunner
com.github.drinkjava2.jdbpro.ImprovedQueryRunner
com.github.drinkjava2.jdbpro.DbPro
public class DbPro
DbPro is the enhanced version of Apache Commons DbUtils's QueryRunner, add below improvements:
1)Use ConnectionManager to manage connection for better transaction support 2)normal style methods but no longer throw SQLException, methods named as nXxxxx() format 3)In-line style methods, methods named as iXxxxx() format 4)SQL Template style methods, methods named as tXxxxx() format
| Field Summary |
|---|
| Fields inherited from class com.github.drinkjava2.jdbpro.ImprovedQueryRunner |
|---|
allowShowSQL, batchSize, connectionManager, iocTool, logger, masters, masterSlaveOption, name, slaves, sqlHandlers, sqlTemplateEngine |
| Fields inherited from class org.apache.commons.dbutils.AbstractQueryRunner |
|---|
ds |
| Constructor Summary | |
|---|---|
DbPro()
|
|
DbPro(DataSource ds)
|
|
DbPro(DataSource ds,
DbProConfig config)
|
|
DbPro(DbProConfig config)
|
|
| Method Summary | ||
|---|---|---|
void |
________iXxxxStyles________()
|
|
void |
________nXxxxStyles________()
nXxxx style series methods are design to replace QueryRunner's xxxx method, the difference is nXxxx methods do not throw SqlException |
|
void |
________prepareMethods________()
|
|
void |
________pXxxxStyles________()
|
|
void |
________tXxxxStyles________()
|
|
protected boolean |
dealOneSqlItem(boolean iXxxStyle,
PreparedSQL predSQL,
Object item)
Here deal one SqlItem, if can deal it, return true, otherwise return false, subclass (like SqlBoxContext) can override this method |
|
PreparedSQL |
dealSqlItems(PreparedSQL lastPreSql,
boolean iXxxStyle,
Object... items)
Deal with multiple SqlItems |
|
|
iExecute(Object... inlineSQL)
Executes the in-line style execute statement |
|
|
iInsert(Object... inlineSQL)
Executes the in-line style insert statement |
|
PreparedSQL |
iPrepare(Object... items)
Prepare a PreparedSQL for iXxxx (Single SQL) style, unknown objects (include null) will automatically looked as SQL pieces, more detail see doPrepare method |
|
|
iQuery(Object... inlineSQL)
Executes the in-line style query statement |
|
long |
iQueryForLongValue(Object... inlineSQL)
In-line style execute query and force return a long value, runtime exception may throw if result can not be cast to long. |
|
List<Map<String,Object>> |
iQueryForMapList(Object... items)
In-Line style execute query and force return a List |
|
|
iQueryForObject(Object... inlineSQL)
Execute an In-line style query for an Object, only return the first row and first column's value if more than one column or more than 1 rows returned |
|
String |
iQueryForString(Object... inlineSQL)
In-line style execute query and force return a String object. |
|
int |
iUpdate(Object... inlineSQL)
Executes the in-line style INSERT, UPDATE, or DELETE statement |
|
|
nExecute(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
Execute an statement, including a stored procedure call, which returns one or more result sets. |
|
int |
nExecute(Connection conn,
String sql,
Object... params)
Execute an statement, including a stored procedure call, which does not return any result sets. |
|
|
nExecute(org.apache.commons.dbutils.ResultSetHandler rsh,
String sql,
Object... params)
Execute an statement, including a stored procedure call, which returns one or more result sets. |
|
int |
nExecute(String sql,
Object... params)
Execute an statement, including a stored procedure call, which does not return any result sets. |
|
|
nInsert(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
Executes the given INSERT SQL statement. |
|
|
nInsert(org.apache.commons.dbutils.ResultSetHandler rsh,
String sql,
Object... params)
Executes the given INSERT SQL statement. |
|
|
nQuery(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
Executes the given SELECT SQL query and returns a result object. |
|
|
nQuery(org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
Executes the given SELECT SQL query and returns a result object. |
|
long |
nQueryForLongValue(Connection conn,
String sql,
Object... params)
Execute query and force return a Long object, no need catch SQLException, runtime exception may throw if result can not be cast to long. |
|
long |
nQueryForLongValue(String sql,
Object... params)
Execute query and force return a Long object, no need catch SQLException, runtime exception may throw if result can not be cast to long |
|
List<Map<String,Object>> |
nQueryForMapList(Connection conn,
String sql,
Object... params)
Execute query and force return a List |
|
List<Map<String,Object>> |
nQueryForMapList(String sql,
Object... params)
Execute query and force return a List |
|
|
nQueryForObject(Connection conn,
String sql,
Object... params)
Query for an Object, only return the first row and first column's value if more than one column or more than 1 rows returned, a null object may return if no result found , DbProRuntimeException may be threw if some SQL operation Exception happen. |
|
|
nQueryForObject(String sql,
Object... params)
Query for an Object, only return the first row and first column's value if more than one column or more than 1 rows returned, a null object may return if no result found , DbProRuntimeException may be threw if some SQL operation Exception happen. |
|
String |
nQueryForString(Connection conn,
String sql,
Object... params)
Execute query and force return a String object, no need catch SQLException. |
|
String |
nQueryForString(String sql,
Object... params)
Execute query and force return a String object, no need catch SQLException |
|
int |
nUpdate(Connection conn,
String sql,
Object... params)
Executes the given INSERT, UPDATE, or DELETE SQL statement. |
|
int |
nUpdate(String sql,
Object... params)
Executes the given INSERT, UPDATE, or DELETE SQL statement. |
|
|
pExecute(Object... items)
Executes the pXxxx style execute statement |
|
|
pInsert(Object... items)
Executes the pXxxx style insert statement |
|
PreparedSQL |
pPrepare(Object... items)
Prepare a PreparedSQL for pXxxx (Single SQL) style, pXxxx style only allow single String (The first appeared) as SQL, unknown objects (include null) will automatically looked as SQL parameters, more detail see doPrepare method |
|
|
pQuery(Object... items)
Executes the pXxxx style query statement |
|
long |
pQueryForLongValue(Object... items)
pXxxx style execute query and force return a long value, runtime exception may throw if result can not be cast to long. |
|
List<Map<String,Object>> |
pQueryForMapList(Object... items)
pXxxx style execute query and force return a List |
|
|
pQueryForObject(Object... items)
Execute an pXxxx style query for an Object, only return the first row and first column's value if more than one column or more than 1 rows returned |
|
String |
pQueryForString(Object... items)
pXxxx style execute query and force return a String object. |
|
int |
pUpdate(Object... items)
Executes the pXxxx style INSERT, UPDATE, or DELETE statement |
|
int |
quiteExecute(String sql,
Object... params)
Quite execute a SQL, do not throw any exception, if any exception happen, return -1 |
|
|
tExecute(Object... items)
Executes the pXxxx style execute statement |
|
|
tInsert(Object... items)
Executes the pXxxx style insert statement |
|
|
tQuery(Object... items)
Executes the pXxxx style query statement |
|
long |
tQueryForLongValue(Object... items)
pXxxx style execute query and force return a long value, runtime exception may throw if result can not be cast to long. |
|
List<Map<String,Object>> |
tQueryForMapList(Object... items)
pXxxx style execute query and force return a List |
|
|
tQueryForObject(Object... items)
Execute an pXxxx style query for an Object, only return the first row and first column's value if more than one column or more than 1 rows returned |
|
String |
tQueryForString(Object... items)
pXxxx style execute query and force return a String object. |
|
int |
tUpdate(Object... items)
Executes the pXxxx style INSERT, UPDATE, or DELETE statement |
|
| Methods inherited from class org.apache.commons.dbutils.QueryRunner |
|---|
batch, batch, execute, execute, execute, execute, insert, insert, insert, insert, insertBatch, insertBatch, query, query, query, query, query, query, query, query, update, update, update, update, update, update |
| Methods inherited from class org.apache.commons.dbutils.AbstractQueryRunner |
|---|
close, close, fillStatementWithBean, fillStatementWithBean, getDataSource, isPmdKnownBroken, prepareStatement, rethrow, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DbPro()
public DbPro(DataSource ds)
public DbPro(DbProConfig config)
public DbPro(DataSource ds,
DbProConfig config)
| Method Detail |
|---|
public int quiteExecute(String sql,
Object... params)
public void ________prepareMethods________()
public PreparedSQL iPrepare(Object... items)
public PreparedSQL pPrepare(Object... items)
public PreparedSQL dealSqlItems(PreparedSQL lastPreSql,
boolean iXxxStyle,
Object... items)
protected boolean dealOneSqlItem(boolean iXxxStyle,
PreparedSQL predSQL,
Object item)
public void ________iXxxxStyles________()
public <T> T iQuery(Object... inlineSQL)
inlineSQL - the in-line style SQL
public <T> T iQueryForObject(Object... inlineSQL)
inlineSQL - params -
public long iQueryForLongValue(Object... inlineSQL)
public String iQueryForString(Object... inlineSQL)
public List<Map<String,Object>> iQueryForMapList(Object... items)
public int iUpdate(Object... inlineSQL)
inlineSQL - the in-line style SQL
public <T> T iInsert(Object... inlineSQL)
inlineSQL - the in-line style SQL
public <T> T iExecute(Object... inlineSQL)
inlineSQL - the in-line style SQL
public void ________pXxxxStyles________()
public <T> T pQuery(Object... items)
items - The items
public <T> T pQueryForObject(Object... items)
items - The items
public long pQueryForLongValue(Object... items)
public String pQueryForString(Object... items)
public List<Map<String,Object>> pQueryForMapList(Object... items)
public int pUpdate(Object... items)
items - the items
public <T> T pInsert(Object... items)
inlineSQL - the in-line style SQL
public <T> T pExecute(Object... items)
items - the items
public void ________tXxxxStyles________()
public <T> T tQuery(Object... items)
items - The items
public <T> T tQueryForObject(Object... items)
items - The items
public long tQueryForLongValue(Object... items)
public String tQueryForString(Object... items)
public List<Map<String,Object>> tQueryForMapList(Object... items)
public int tUpdate(Object... items)
items - the items
public <T> T tInsert(Object... items)
inlineSQL - the in-line style SQL
public <T> T tExecute(Object... items)
items - the items
public void ________nXxxxStyles________()
public <T> T nQuery(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
T - The type of object that the handler returnssql - the SQLrsh - The handler used to create the result object from the
ResultSet.params - the parameters if have
public <T> T nQueryForObject(Connection conn,
String sql,
Object... params)
sql - params -
public String nQueryForString(Connection conn,
String sql,
Object... params)
public long nQueryForLongValue(Connection conn,
String sql,
Object... params)
public List<Map<String,Object>> nQueryForMapList(Connection conn,
String sql,
Object... params)
public int nUpdate(Connection conn,
String sql,
Object... params)
sql - the SQLparams - the parameters if have
public <T> T nInsert(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
T - The type of object that the handler returnsrsh - The resultSetHandler used to create the result object from the
ResultSet of auto-generated keys.sql - the SQLparams - the parameters if have
public int nExecute(Connection conn,
String sql,
Object... params)
OutParameter will be registered as OUT parameters.
Use this method when invoking a stored procedure with OUT parameters that does not return any result sets.
sql - the SQL
public <T> List<T> nExecute(Connection conn,
org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
OutParameter
will be registered as OUT parameters. Note: This method does not close
connection.
Use this method when: a) running SQL statements that return multiple result
sets; b) invoking a stored procedure that return result sets and OUT
parameters.
T - The type of object that the handler returnsrsh - The result set handlersql - the SQL
public <T> T nQuery(org.apache.commons.dbutils.ResultSetHandler<T> rsh,
String sql,
Object... params)
T - The type of object that the handler returnssql - the SQLrsh - The resultSetHandler used to create the result object from the
ResultSet.params - the parameters if have
public <T> T nQueryForObject(String sql,
Object... params)
nQueryForObject in interface NormalJdbcToolsql - params -
public String nQueryForString(String sql,
Object... params)
public long nQueryForLongValue(String sql,
Object... params)
public List<Map<String,Object>> nQueryForMapList(String sql,
Object... params)
public int nUpdate(String sql,
Object... params)
nUpdate in interface NormalJdbcToolsql - the SQLparams - the parameters if have
public <T> T nInsert(org.apache.commons.dbutils.ResultSetHandler rsh,
String sql,
Object... params)
T - The type of object that the handler returnsrsh - The resultSetHandler used to create the result object from the
ResultSet of auto-generated keys.sql - the SQLparams - the parameters if have
public int nExecute(String sql,
Object... params)
OutParameter will be registered as OUT parameters.
Use this method when invoking a stored procedure with OUT parameters that does not return any result sets.
nExecute in interface NormalJdbcToolsql - the SQL
public <T> List<T> nExecute(org.apache.commons.dbutils.ResultSetHandler rsh,
String sql,
Object... params)
OutParameter
will be registered as OUT parameters.
Use this method when: a) running SQL statements that return multiple result
sets; b) invoking a stored procedure that return result sets and OUT
parameters.
T - The type of object that the handler returnsrsh - The result set handlersql - the SQL
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||