I have the following problem: in an insert that I am trying to perform, I do not know if it is an error in the database or something in the programming in java, however every time I try to perform an insert of the client table I get the error: p>
java.sql.SQLException: database locked
Until then everything was ok in the insert but I had to redo the database from there started the problem I reviewed the code but everything seems to be correct, follow below insert code:
public class clienteDAO {
public void Create(cliente c){
Connection conn = javaConnect.ConnectDb();
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement("INSERT INTO cliente (cliente_nome,cliente_rg,cliente_cpf,end_rua,end_numero,end_bairro,end_cidade,end_estado,end_cep,telefone_celular, telefone_residencial, telefone_extra, cliente_email) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt.setString(1, c.getNome());
pstmt.setString(2, c.getRg());
pstmt.setString(3, c.getCpf());
pstmt.setString(4, c.getRua());
pstmt.setString(5, c.getNumero());
pstmt.setString(6, c.getBairro());
pstmt.setString(7, c.getCidade());
pstmt.setString(8, c.getEstado());
pstmt.setString(9, c.getCep());
pstmt.setString(10, c.getTelefone1());
pstmt.setString(11, c.getTelefone2());
pstmt.setString(12, c.getTelefone3());
pstmt.setString(13, c.getEmail());
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null, "Cadastro Realizado!");
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"Erro ao salvar: " + ex);
}
}
I tried to find the error tbm in the creation of the table but also could not identify any error, there is code I used to create the table:
CREATE TABLE cliente (
id_cliente integer PRIMARY KEY AUTOINCREMENT NOT NULL,
cliente_cpf varchar(20),
cliente_nome varchar(60),
end_rua varchar(40),
cliente_rg varchar(20),
end_bairro varchar(50),
end_estado varchar(40),
end_cidade varchar(40),
end_cep varchar(20),
end_numero varchar(10),
telefone_contato1 varchar(12),
telefone_contato2 varchar(12),
telefone_contato3 varchar(12),
cliente_email varchar(30)
)
Well, now I have no idea if the error is in the bank or programming in Java.
I also reviewed the get / Set codes but they look correct too.