Olá galera
Estou tentando iserir uns dados no banco e nao ta dando certo
Oq tem de errado no código
tabela no bancoCREATE TABLE `monitoria`.`pessoas` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(40) NOT NULL,
`endereco` varchar(40) NOT NULL,
`cpf` varchar(12) NOT NULL,
`telefone` varchar(12) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
public void addPessoa(Pessoa p){
String sql = "INSERT INTO pessoas(nome, endereco, cpf, telefone) VALUES (????)";
try{
Connection conn = ConnectionDB.getConnection();
PreparedStatement pstm = conn.prepareStatement(sql);
pstm.setString(1, p.getNome());
pstm.setString(2, p.getEndereco());
pstm.setString(3, p.getCpf());
pstm.setString(4, p.getTelefone());
System.out.println("execute AddPessoa");
pstm.execute();
}catch(Exception e){
e.printStackTrace();
}
}
java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:995)
jah vi e revi e nao acho o erro disso
se alguem puder ajudar
agradeço desde já
Att.