Seguinte galera, faz uma semana que procuro nos fóruns espalhados por aí mas não consegui resolver meu problema.
Estou tentando inserir numa tabela de banco SQlite com campo auto_increment pelo PreparedStatement mas está dando erro.
O campo "id" é um tipo de dado AUTOINC NOT NULL.
try {
this.ptm = (PreparedStatement) this.conn.prepareStatement("INSERT INTO cheque (id,idpagamento,pedido,cliente,data,nome,cpf," +
"banco,cheque,valor,vencimento,telefone,celular,retirado,dataretirado) VALUES (0,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
this.ptm.setInt(1, cheque.getIdpagamento());
this.ptm.setInt(2, cheque.getPedido());
this.ptm.setInt(3, cheque.getCliente());
this.ptm.setString(4, String.valueOf(cheque.getData().getTime()));
this.ptm.setString(5, cheque.getNome());
this.ptm.setString(6, cheque.getCpf());
this.ptm.setString(7, cheque.getBanco());
this.ptm.setString(8, cheque.getCheque());
this.ptm.setDouble(9, cheque.getValor());
this.ptm.setString(10, String.valueOf(cheque.getVencimento().getTime()));
this.ptm.setString(11, cheque.getTelefone());
this.ptm.setString(12, cheque.getCelular());
this.ptm.setString(13, String.valueOf(cheque.isRetirado()));
this.ptm.setString(14, String.valueOf((cheque.getDataretirado().getTime())));
this.ptm.execute();
this.ptm.close();
} catch (SQLException e) {
e.printStackTrace();
}
-Já tentei [color=blue]null[/color] mas ele mostra este erro: [color=red]cheque.id may not be NULL[/color];
-Já tentei [color=blue]0[/color] mas quando vou adicionando só adiciona [color=blue]0[/color] no campo id, ou seja, não vai auto-incrementando;
-Já tentei tirar o "id" do parametro, mas também mostra este erro:[color=red]cheque.id may not be NULL[/color], código desta forma:
this.ptm = (PreparedStatement) this.conn.prepareStatement("INSERT INTO cheque (idpagamento,pedido,cliente,data,nome,cpf," +
"banco,cheque,valor,vencimento,telefone,celular,retirado,dataretirado) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
Não sei mais o que fazer.
Se alguem puder mim ajudar agradeço.