博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JDBC -- DBUtils
阅读量:4619 次
发布时间:2019-06-09

本文共 1916 字,大约阅读时间需要 6 分钟。

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

你可能感兴趣的文章
ddd
查看>>
死磕 java同步系列之AQS起篇
查看>>
利用Lucene把文本的字体格式进行改动,然后输出到一个新的文件里
查看>>
[Openstack] Expecting an auth URL via either --os-auth-url or env[OS_AUTH_URL]
查看>>
How to Create Modifiers Using the API QP_MODIFIERS_PUB.PROCESS_MODIFIERS
查看>>
待飞笔记(第一天 )
查看>>
用Winrar批量解压缩有密码文件方法,只需输入一次密码
查看>>
解惑好文:移动端H5页面高清多屏适配方案
查看>>
traefik添加多证书
查看>>
PhantomJs 笔记
查看>>
js设计模式--语言类型
查看>>
C#多线程之二:ManualResetEvent和AutoResetEvent
查看>>
忽略UserInterfaceState.xcuserstate
查看>>
ReactNative--Flexbox布局
查看>>
java实现读取文件大全
查看>>
[Cordova] 无法显示Alert视窗
查看>>
借助过度区选择阈值
查看>>
价格正则
查看>>
评论列表显示及排序,个人中心显示
查看>>
JavaWeb学习笔记总结 目录篇
查看>>