4
I have the following problem: in an Insert that I am trying to accomplish, I don’t know if it is an error in the database or something in the java programming, but every time I try to perform an input of the client table returns me the error:
java.sql.Sqlexception: database locked
Until then everything was ok in Insert but I had to redo the bank from there started the problem I reviewed the code however it seems to be all correct, follows 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 creating the table but also could not identify any error, follows 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 database or in Java programming.
I’ve reviewed the get/set codes but they appear to be correct as well.
Most likely is dropping it open somewhere else that has exclusivity.
– Maniero
You refer to connection to the bank ?
– Leo Bufalo
That’s right.....
– Maniero