public Object getValue(String sql,Object... args) { Connection conn = null; Object obj= null; try { //拿conn conn = JdbcUtils.getConnection(); obj = queryRunner.query(conn, sql, new ScalarHandler(),args); } catch (Exception e) { e.printStackTrace(); System.out.println("BaseDao.getValue报的错"); }finally { JdbcUtils.closeConn(conn); } return obj; }

代码中的query的错误(update复制后忘为query)

Too many parameters: expected 1, was given 2 Query: SELECT count(id) FROM `user` WHERE username = ?; Parameters: [org.apache.commons.dbutils.handlers.ScalarHandler@453da22c, [李明]]的更多相关文章

  1. java.lang.RuntimeException: java.sql.SQLException: Too many parameters: expected 0, was given 1 Quer

    如果出现类似这样的错误,检查一下是否sql语句和参数的位置对调了. java.lang.RuntimeException: java.sql.SQLException: Too many parame ...

  2. [Angular2 Router] Optional Route Query Parameters - The queryParams Directive and the Query Parameters Observable

    In this tutorial we are going to learn how to use the Angular 2 router to pass optional query parame ...

  3. Database Initialization Parameters for Oracle E-Business Suite Release 12 (文档 ID 396009.1)

    In This Document Section 1: Common Database Initialization Parameters For All Releases Section 2: Re ...

  4. 解决 Jackson反序列化 Unexpected token ... , expected VALUE_STRING: need JSON String that contains type id (for subtype of ...)

    首先检查是否是 objectMapper.enableDefaultTyping(); 的受害者.优先考虑删除该配置. 使用Jackson把数组的json字符串反序列化为List时候报了个JsonMa ...

  5. SSIS Passing Parameters to an ADO .NET Source query;向ado.net数据源传递参数。

    使用SSIS的oledb数据源时的参数按钮如下图: 但是在使用ADO.NET源连接到MYSQL时,没有这个参数按钮,如何向数据流的sql command传递参数呢? steps: 1. 在 控制流 选 ...

  6. MyBatis3错误:Parameter 'id' not found. Available parameters are [arg2, arg1, arg0, param3, param1, param2]或者Parameter '0' not found. Available parameters are [arg2, arg1, arg0, param3, param1, param2]

    这个问题涉及到MyBatis3在使用select节点查询时传递多个参数的问题.问题分析如下: 1.如果是单个查询一般是这样配置: <select id="getUserArticles ...

  7. java.sql.SQLException: Cannot create com._51doit.pojo.User: com._51doit.pojo.User Query: select * from user where username = ? and password = ? Parameters: [AA, 123]

    在从数据库中查询数据,并存入javabean中去时,报这个错误 原因:在建立User类去存储信息时没有创建无参构造方法,创建一个无参构造方法即可

  8. dbutils中实现数据的增删改查的方法,反射常用的方法,绝对路径的写法(杂记)

    jsp的三个指令为:page,include,taglib... 建立一个jsp文件,建立起绝对路径,使用时,其他jsp文件导入即可 导入方法:<%@ include file="/c ...

  9. 20160410javaweb之JDBC---DBUtils框架

    DBUtils 1.DbUtils 工具类 2.QueryRunner -- 两行代码搞定增删改查 (1)QueryRunner() --需要控制事务时,使用这组方法 int update(Conne ...

随机推荐

  1. 自定义滑块Vue组件

    <div class="audio"> <audio id="audio" ref="audio" src="h ...

  2. css3 animatehue属性

    -webkit-perspective(-moz,-o,perspective下同)表示透视范围大小: -webkit-transform-style很好理解了,表示变换类型,preserve-3d看 ...

  3. Linux 学习 之 bash

    Anything is programmable with defined syntax and common lib. Bash Shell is created to programme to L ...

  4. mysql-5.7安装配置指导

    mysql 安装 yum 安装mysql 源码编译安装mysql 通过yum安装 下载yum仓库配置安装包 MySQL Yum Repository http://dev.mysql.com/down ...

  5. sharepoint 查阅项SPFieldLookup 赋值 .

    在项目中,经常会涉及列表或者文档库之间的相互引用,而这个时候我们用的更多的就是查阅项(lookup),以前没有去关注取值或者赋值的问题,今天正好碰到一个Case,就顺道总结一下.我们知道链接和图片的字 ...

  6. Servlet是线程安全的吗?

    Servlet不是线程安全的. 要解释为什么Servlet为什么不是线程安全的,需要了解Servlet容器(即Tomcat)使如何响应HTTP请求的. 当Tomcat接收到Client的HTTP请求时 ...

  7. 使用 Satis 搭建私有的 Composer 包仓库

    简述 iBrand 产品立项时是商业性质的项目,但是在搭建架构时考虑后续的通用性,因此每个模块都设计成一个 Package,作为公司内部用,因此这些包并不能提交到 packagist.org 上去. ...

  8. Makedown语法说明

    Markdown 语法说明 (简体中文版) / (点击查看快速入门) 概述 宗旨 兼容 HTML 特殊字符自动转换 区块元素 段落和换行 标题 区块引用 列表 代码区块 分隔线 区段元素 链接 强调 ...

  9. 二叉搜索树实现MAP

    二叉搜索树的基本实现. /* Date: 2014-04-29 purpose: An implementation of MAP using binary search tree. */ #ifnd ...

  10. MySQL一致性非锁定读

    一致性非锁定读(consistent nonlocking read)是指InnoDB存储引擎通过多版本控制(multi versionning)的方式来读取当前执行时间数据库中行的数据,如果读取的行 ...