错误信息如下:
0:13:58,218 INFO SbxxServiceImpl:19 - 开始执行SbxxServiceImpl类的 createSblx 方法 !
10:13:58,218 INFO SbxxDaoImpl:24 - 开始执行SbxxDaoImpl类的 createSblx 方法 !
10:13:58,218 INFO SbxxDaoImpl:32 - 执行新增设备类型操作 方法 ,调用存储过程 : call ps_ddgl_sblx_insert(yyyy ,yyy ,yyyyy,3,0) ;
10:13:58,218 ERROR SbxxDaoImpl:47 - 执行新增设备类型操作出错了,导致原因可能是:< Parameter index of 5 is out of range (1, 4)>
10:13:58,218 ERROR SbxxDaoImpl:50 - com.mysql.jdbc.CallableStatement.checkParameterIndexBounds(CallableStatement.java:1002)
10:13:58,218 ERROR SbxxDaoImpl:50 - com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:971)
10:13:58,218 ERROR SbxxDaoImpl:50 - com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:864)
10:13:58,218 ERROR SbxxDaoImpl:50 - org.apache.commons.dbcp.DelegatingCallableStatement.registerOutParameter(DelegatingCallableStatement.java:95)
10:13:58,218 ERROR SbxxDaoImpl:50 - org.apache.commons.dbcp.DelegatingCallableStatement.registerOutParameter(DelegatingCallableStatement.java:95)
10:13:58,218 ERROR SbxxDaoImpl:50 - com.zichen.zhhwd.sbxx.dao.impl.SbxxDaoImpl.createSblx(SbxxDaoImpl.java:39)
10:13:58,218 ERROR SbxxDaoImpl:50 - com.zichen.zhhwd.sbxx.service.impl.SbxxServiceImpl.createSblx(SbxxServiceImpl.java:20)
10:13:58,218 ERROR SbxxDaoImpl:50 - com.zichen.zhhwd.action.sbxx.SblxAction.doaddsblx(SblxAction.java:68)
10:13:58,218 ERROR SbxxDaoImpl:50 - sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:13:58,234 ERROR SbxxDaoImpl:50 - sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
10:13:58,234 ERROR SbxxDaoImpl:50 - sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
10:13:58,234 ERROR SbxxDaoImpl:50 - java.lang.reflect.Method.invoke(Method.java:597)
存储过程源码 :
CREATE
PROCEDURE ps_ddgl_sblx_insert(IN ps_lxmc VARCHAR(20) CHARACTER SET UTF8, IN ps_lxjx VARCHAR(3) CHARACTER SET UTF8, IN ps_lxbz VARCHAR(50) CHARACTER SET UTF8, IN ps_ggwsx int(11),OUT exceResult INT)
COMMENT '新增设备类型'
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
SET exceResult =0;
START TRANSACTION;
select count(*) into @likeset from ddgl_sblx where lxmc = ps_lxmc or lxjx= ps_lxjx ;
if (@likeset >0) then
SET exceResult = 2;
else
INSERT INTO ddgl_sblx ( lxmc, lxjx, lxbz,ggwsx) VALUES (ps_lxmc, ps_lxjx, ps_lxbz,ps_ggwsx);
COMMIT;
SET exceResult = 1;
end if ;
END
java 程序代码 :
Logger log = Logger.getLogger(SbxxDaoImpl.class);
public int createSblx(Sblx item) {
log.info("开始执行SbxxDaoImpl类的 createSblx 方法 !");
Connection con = null;
CallableStatement ps = null;
int insertResult = 0;
try {
con = JdbcUtil.getInstance().getConnection();
con.setAutoCommit(false);
ps = con.prepareCall(" call ps_ddgl_sblx_insert(?,?,?,?,?) ; ");
log.info(" 执行新增设备类型操作 方法 ,调用存储过程 : call ps_ddgl_sblx_insert("
+ item.getLxmc() + " ," + item.getLxjx() + " ,"
+ item.getLxbz() +","+item.getGgwsx()+",0) ;");
ps.setString(1, item.getLxmc());
ps.setString(2, item.getLxjx());
ps.setString(3, item.getLxbz());
ps.setInt(4, item.getGgwsx());
ps.registerOutParameter(5, Types.INTEGER);
ps.execute();
insertResult = ps.getInt(5);
if (insertResult == 1) {
log.info("执行新增设备类型操作 操作数据库成功!");
return insertResult;
}
} catch (SQLException e) {
log.error(" 执行新增设备类型操作出错了,导致原因可能是:< " + e.getMessage() + "> ");
StackTraceElement[] error = e.getStackTrace();
for (StackTraceElement stackTraceElement : error) {
log.error(stackTraceElement.toString());
}
} finally {
JdbcUtil.close(null, ps, con);
}
return insertResult;
}
相关解决方案
- mysql 简单化 or能否实现
- 请问registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister
- MySQL 5.5 Command Line Client 窗口1输密码就退出
- 请问上Linux平台上怎么搭建JDK \TOMCAT\MYSQL
- index.jsp经过模拟action接口 转发 到login.jsp页面后,页面背景无法显示
- 在LINUX上配置 MySQL 开机自动 启动
- mysql 转 orocle java ssh项目一条 sql 句不通!
- 急求帮忙!mysql 【 Column count doesn't match value count 】,该怎么解决
- jsp中的注册登录系统(mysql)
- java.sql.SQLException: Parameter #一 has not been set
- 上了个 MySQL 5.5.25 但是安装时出错了
- 求jsp博客源代码mvc+mysql,该如何解决
- java mysql 中文乱码有关问题
- Parameter index out of range (五 > number of parameters, which is 4)
- 求高手看一看!index.jsp可以进,在往上点就出现有关问题了
- 请教各位,使用PreparedStatement mysql 数据库 不回滚,盼望解答。多谢。 具体如上
- mysql Statement parameter 一 not set
- java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306,该怎么处理
- MyBatis 读取 Mysql Blob类型的SQL如何写呢
- JDBC MYSQL 驱动加载失败 JSP DAO ECLIPSE,该怎么解决
- tomcat启动出现Caused by: java.lang.StringIndexOutOfBoundsException: String index out解决方法
- Only a type can be imported. com.mysql.jdbc.Driver resolves to a package解决方案
- tomcat 中抛异com.mysql.jdbc.exceptions.MySQLTransactionRollbackException,该如何处理
- Enumeration<String> 和 Parameter,该如何处理
- struts+iBatis+mysql,该如何解决
- mysql 有外键的插入解决方案
- JSP有关问题 index.jsp使用meta 页面都跳转不过去
- JSP 更新 MySQL 语句时遇到异常了= =
- mysql,该如何处理
- +++++ mysql 插入成功,查询不到记录?