代码如下:
public boolean insert(CustomerBean customer) {
// TODO Auto-generated method stub
boolean b = false;

String sql = "insert into s_customer  values(s_customer_seq.nextval,?,?,?,?,?,?,?,?,?)";


try {
pstam = con.prepareStatement(sql);
System.out.println(pstam);
    System.out.println(sql);
    pstam.setLong(1, maxId() + 1);
pstam.setString(2,customer.getName());
pstam.setString(3,customer.getIcard() );
    pstam.setString(4,customer.getAddress() );
    pstam.setString(5, customer.getMobile()); 
    pstam.setString(6,customer.getCompany() ); 
    pstam.setString(7,customer.getPhone() );
    pstam.setInt(8, customer.getPost());
    pstam.setString(9, customer.getEmail());
    System.out.println(sql);
int i = pstam.executeUpdate();
if (i > 0) {
b = true;
}

} catch (SQLException e) {
System.out.println("在对customer表做插入操作的时候出错了" + e.getMessage());
} finally {
DButils.close(con, pstam, null);
}
return b;
}

解决方案 »

  1.   

    怀疑s_customer表实际只有9列。你应该把?号改成8个,然后第一个setLong去掉,其他依次减去1.
    也就是说你的第一列的值实际上已经有值了,就是s_customer_seq.nextval
      

  2.   

    你插入语句中有s_customer_seq.nextval通过序列来取值,如果不是11g,那么在Oracle中要这样取值
    select s_customer_seq.nextval into id from dual;