JDBC -- DBUtils

DBUtils framework:

  Constructor:

    QueryRunner(); 

    QueryRunner(DataSource dataSource);

  Method:

    batch:

      batch(Connection conn, String sql, Object[][] params);  ----->  when you use the default constructor

      batch(String sql, Object[][] params);  ----->  high dimensionality: the amount of statement low dimensionality: the parameter each statement needs

    query:

      <T> T query(String sql, ResultSetHandler<T> rsh, Object... params);

      <T> T query(Connection conn, String sql, ResultSetHandler<T> rsh, Object... params);

    update:

      update(String sql, Object... parmas);

      update(Connection conn, String sql, Object... params);

    When you want to call the update method for several times, pleas use update(Connection conn, String sql, Object... parmas), and the default constructor is needed.

ResultSetHandler of DBUtils:

  ArrayHandler: used when the result set has only one result in the set, the return value is Object[], the records in the list is the data of every column.

  ArrayListHandler: used when the result set has many results in the set, the return value is List<Object[]> , the records are encapsulated in the List, every Object[] represents one row of data.

  BeanHandler: return one JavaBean record 

  BeanListHandler: return a List of JavaBean record

  ColumnListHandler: used when want to query one column, the return value is List<Object>, the value in the List is the column's values.

  KeyedHandler: used when the result set has many records, the return value is Map<Object,Map<String,Object>>

  MapHandler: used when the result set has only one record, the return value is Map<String,Object>, key is the filed name, value is the filed value.

  MapListHandler: ... the return value is List<Map<String,Object>>

  ScalarHandler: used when the result has only one row and one column, the return value is Object

 

转载于:https://www.cnblogs.com/ppcoder/p/7491992.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值