No value specified for parameter 1

方法:
@Override
public int update(String sql, Object[] parameters) {
Connection conn = DBConnectUtils.getConnection();
PreparedStatement pstmt = null;
if (parameters == null || parameters.length == 0) {
return 0;
}

    for (int i = 0; i < parameters.length; i++) {

        // pstmt.setObject(第几个参数, 替换成什么);
        try {
            pstmt = conn.prepareStatement(sql);
            pstmt.setObject(i + 1, parameters[i]);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    int j = 0;
    try {
        pstmt = conn.prepareStatement(sql); //这里出问题 不知道应该写什么
        j = pstmt.executeUpdate();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    System.out.println("j: " + j);

    DBCloseUtils.closeCS(conn, pstmt);

    return j;
}


测试:
sql = "update user_info set password = ? where id = ?";
    databaseFactory.update(sql, new Object[] { "444", 25 });
    System.out.println(sql);

参考http://bbs.csdn.net/topics/250087570
pstmt.setObject(i + 1, parameters[i]);
你上面还知道set参数,下面就
pstmt = conn.prepareStatement(sql); //这里出问题 不知道应该写什么
j = pstmt.executeUpdate();
直接set参数就执行了啊