4
I am having the error "Column Count doesn’t match value Count at Row 1" when I try to register. I already checked my comic book and everything seems to be in order but nothing to solve this mistake.
My registration code.
            public void actionPerformed(java.awt.event.ActionEvent e) {
            System.out.println("actionPerformed()"); 
            // captura valor de radiobuttons
            String consignacao;
            if (consig_sim.isSelected()) {
                consignacao = consig_sim.getText();
            } else {
                consignacao = consig_nao.getText();
            }
            // /fim da captura
            String Cadastro = ("insert into livros (ISBN, titulo_livro, autor_livro, editora_livro, consignacao, preco, quantidade) values ('"
                    + jTextField.getText()
                    + ", "
                    + jTextField1.getText()
                    + ","
                    + jTextField2.getText()
                    + ", "
                    + jTextField3.getText()
                    + ", "
                    + consignacao
                    + ", "
                    + jTextField4.getText()
                    + ", "
                    + jTextField5.getText() + "')");
            try {
                cadastro.Executar("select * from livros");
                cadastro.stm.executeUpdate(Cadastro); //de acordo com o eclipse o erro esta acontecendo aqui
                cadastro.stm.close();
                cadastro.Executar("select * from livros");
                JOptionPane
                        .showMessageDialog(null, "Cadastro efetuado");
            } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
query class.
package modulo;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Query {
public static Object resultset;
public Statement stm;
public ResultSet Resultado;
private boolean conectado = false;
static Conexao data_base = new Conexao();
public ResultSet Executar(String Sql) {
    try {
        if (!conectado) {
            data_base.conectar();
            conectado = true;
        }
        stm = data_base.con.createStatement();
        Resultado = stm.executeQuery(Sql);
    } catch (SQLException ex) {
    }
    return Resultado;
}
}
						
He is saying that the number of columns passed is not tapping. You have already checked whether you are passing all values that are set in the query?
– Luitame
I checked yes, even through Debug it shows that all data is being passed correctly.
– Luis Henrique Hendges
The result of the Debug is as follows: INSERT INTO books (ISBN, title book, author_book, editora_book, consignment, price, quantity) VALUES ('111111111', 'test', 'test','test','No','1.34','1')
– Luis Henrique Hendges
Have you tested what @Tony suggested below? It worked?
– Luitame
I just tested, the error persists.
– Luis Henrique Hendges
If possible, add the error message.
– Tony
Then, I repeated the test and the registration was done correctly, but in the console appeared the following message: ERROR: JDWP Unable to get JNI 1.2 Environment, jvm->Getenv() Return code = -2 JDWP Exit error AGENT_ERROR_NO_JNI_ENV(183): [. /.. /.. /src/share/back/util. c:838]
– Luis Henrique Hendges
This error does not seem to be related to Mysql. Maybe some more knowledgeable colleague will clarify this.
– Tony