数据库错误:Parameter   index   out   of   range   (1   >   number   of   parameters,   which   is   0).

错误发生原因其实很简单,就是当设置参数时,没有相应的问号与之匹配(或者根本就没有?号).
如果是:Parameter   index   out   of   range   (26   >   number   of   parameters,  which   is   25). 
翻译为:找到了25个问号,却插入了26个值,导致参数越界(根据得到的信息打印将很容易判断数据是否与数据库字段匹配等小问题)。
 
与sql语句有关的原因如下:
1.?号被单引号包围。
(如setString(1,"slkdjfkd");时sql语句为:insert into table1 (c1,c2) values ('?','?'))。
此时?会被作为参数传入,而不会再传入 setString里面的值。
 
2.sql语句中没有?号,在后面用到了set语句。(如:select * from table);
此时无需传值。传值就会出错。
 
3.初学者很常见的错误:?---?
这两个问号是不同了,因为一个是中文,一个是英文,如果在sql语句中写入的是英文,将无法识别。
 
 
其他原因:
1.连接已经关闭。 
 如果与其他操作语句一起公用conn时,如果上一操作已经关闭连接,则会报错。表现为:时而能够进行操作,时而不能。
2.pstm没有初始化,无驱动包,得到连接出错等基础问题……
 
都是一些比较基础的东西,希望大家不要犯这种错误,浪费宝贵时间。
(欢迎转载,请注明出处。http://blog.sina.com.cn/s/blog_6df227a40101709h.html)

Parameter index out of range (1 > number of parameters, which is 0).的更多相关文章

  1. Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0

    1.错误描述 [ERROR:]2015-05-05 16:35:50,664 [异常拦截] org.hibernate.exception.GenericJDBCException: error ex ...

  2. mybatis中Parameter index out of range (1 > number of parameters, which is 0).

    Parameter index out of range (1 > number of parameters, which is 0).(参数索引超出范围) 在mybatis里面写就是应该是 l ...

  3. java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

    java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). at co ...

  4. Parameter index out of range(1 > number of parameters, which is 0)参数索引超出范围

    今天在写项目的过程中,有一个模块是做多选删除操作,通过servlet获得多选框的value组,然后执行sql操作.如下: 1 @RequestMapping( "/delteCouse.do ...

  5. org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback.....Parameter index out of range (1 > number of parameters, which is 0).;

    sql有误,一般是   sql语句少了问号.

  6. 【Mybatis异常】Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

    一.错误原因分析 从错误提示可以看出:实际传入的参数大于sql中待设置的参数,也就是sql中的?少于参数或?根本没有产生原因:  ?号被单引号包围 如: sql += " and artic ...

  7. [转]操作MySQL数据库报出:Parameter index out of range (1 > number of parameters, which is

    原文地址:https://blog.csdn.net/zdx_y/article/details/52072914 对MySQL进行insert操作,控制台抛出以下错误:Parameter index ...

  8. Parameter index out of range (2 > number of parameters, which is 1)

    今天在实现一个功能时遇到一个问题,解决了很久.结果是#{}与${}使用错误的原因.但是具体原因还不是很清楚,写此篇总结,知道的可以交流. 具体描述为:通过教师的头衔(1高级讲师2首席讲师)及名称进行模 ...

  9. java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2).

    java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2). java. ...

随机推荐

  1. Maven_自动化构建和构建环节

    [构建过程的几个主要环节] ①清理:删除以前的编译结果,为重新编译做好准备. ②编译:将 Java 源程序编译为字节码文件. ③测试:针对项目中的关键点进行测试,确保项目在迭代开发过程中关键点的正确性 ...

  2. 通过混合编程分析的方法和机器学习预测Web应用程序的漏洞

    通过混合编程分析的方法和机器学习预测Web应用程序的漏洞 由于时间和资源的限制,web软件工程师需要支持识别出有漏洞的代码.一个实用的方法用来预测漏洞代码可以提高他们安全审计的工作效率.在这篇文章中, ...

  3. 一个DBA对于开发人员使用MySQL的tips

    http://neoremind.net/2011/06/%E4%B8%80%E4%B8%AAdba%E5%AF%B9%E4%BA%8E%E5%BC%80%E5%8F%91%E4%BA%BA%E5%9 ...

  4. tomcat上传图片失败

    今天,突然遇到个奇怪的问题,tomcat上传图片时好时坏,经查线上四台服务有一台服务器硬盘满了. 解决一下硬盘空间的问题,有好使了,那么图片上传通过流写到远程对象存储服务中,并没有落盘和硬盘满有哪些关 ...

  5. 1. 找出数组中的单身狗OddOccurrencesInArray Find value that occurs in odd number of elements.

    找出数组中的单身狗: 1. OddOccurrencesInArray Find value that occurs in odd number of elements. A non-empty ze ...

  6. 【打CF,学算法——二星级】Codeforces Round #312 (Div. 2) A Lala Land and Apple Trees

    [CF简单介绍] 提交链接:A. Lala Land and Apple Trees 题面: A. Lala Land and Apple Trees time limit per test 1 se ...

  7. C 基础 全局变量

    /** 被static修饰的局部变量 1.只有一份内存, 只会初始化一次 2.生命周期会持续到程序结束 3.static改变了局部变量的生命周期, 但是不能改变局部变量的作用域 被static修饰的全 ...

  8. JXLS-----JXLS导出Excel

  9. Android隐藏状态栏和标题栏,相当于全屏效果

    隐藏标题栏需要使用预定义样式:android:theme=”@android:style/Theme.NoTitleBar”. 隐藏状态栏:android:theme=”@android:style/ ...

  10. ALSA声卡驱动中的DAPM详解之一:kcontrol

    DAPM是Dynamic Audio Power Management的缩写,直译过来就是动态音频电源管理的意思,DAPM是为了使基于linux的移动设备上的音频子系统,在任何时候都工作在最小功耗状态 ...