当前位置: 代码迷 >> Java相关 >> 求会jdbc的人指导一上。本人很菜。org.postgresql.util.PSQLException: 列索引溢出:0,列数目:4 这个是什么东东
  详细解决方案

求会jdbc的人指导一上。本人很菜。org.postgresql.util.PSQLException: 列索引溢出:0,列数目:4 这个是什么东东

热度:601   发布时间:2016-04-22 21:59:05.0
求会jdbc的人指导一下。。。本人很菜。。org.postgresql.util.PSQLException: 列索引溢出:0,列数目:4 这个是什么错误
org.postgresql.util.PSQLException: 列索引溢出:0,列数目:4 我报这个错误。。。我使用的structs1.3的框架,
部分代码如下:
String sql_password;
sql_password ="UPDATE USERS SET u_password=? u_mail=? u_sex=?  where u_Name=?";

//JDBC连接
Connection con = null;

try {

    //获取连接
con = JDBCUtil.getConnection();

System.out.println("连接成功");

System.out.println(u_Name + u_password + u_sex + u_mail);

//预编译SQL语句
ps = con.prepareStatement(sql_password);

System.out.println("预编译成功");

System.out.println(u_mail+u_Name);

//对修改用户SQL进行预处理
ps.setString(0, u_password);
ps.setString(1, u_mail);
ps.setString(2, u_sex);
ps.setString(3, u_Name);

System.out.println("处理成功");
貌似是在ps.setString()这个位置出错误了。。求大神指导撒

------解决方案--------------------
UPDATE USERS SET u_password=? u_mail=? u_sex=?  where u_Name=?说好的逗号呢?
UPDATE USERS SET u_password=?, u_mail=? ,u_sex=?  where u_Name=?
------解决方案--------------------
LZ,update多个字段,中间要加逗号
UPDATE USERS SET u_password=?, u_mail=? ,u_sex=?  where u_Name=?

还有ps.setString(0, u_password);
这个下标是从1开始的吧。。。


------解决方案--------------------
引用:
改好了。。O(∩_∩)O谢谢

呵呵,结贴吧!
  相关解决方案