1
How to fix this error ? This is preventing you from connecting to the bank....
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // Eventoos do Botao inserir
    try {
        //Registra JDBC driver
        Class.forName("com.mysql.jdbc.Driver");
        //Abrindo a conexão: ATENÇÃO OS DOIS PARÂMETROS VAZIOS("") SÃO USUÁRIO E SENHA, RESPECTIVAMENTE.
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/escola?zeroDateTimeBehavior=convertToNull", "", "");
        //Executa a query de inserção
        java.sql.Statement st = conn.createStatement();
        st.executeUpdate("INSERT INTO aluno (id,nome,cpf) VALUES ("
                + this.jTextFieldId.getText() + ",'"
                + this.jTextFieldNome.getText() + "','"
                + this.jTextFieldCPF.getText() + "')");
        JOptionPane.showMessageDialog(rootPane, "Aluno inserido");
    } catch (SQLException | ClassNotFoundException e) {
        JOptionPane.showMessageDialog(rootPane, e);
    }//Fim try
}       
						
I don’t understand. What’s the mistake?
– Math
this underlined in red line and is not connecting to the bank...
– alexjosesilva
your IDE does not speak the error that is on the line?
– Rafael
yes...:cannot find Symbol. Symbol class: class Connection. Location Jframestudent
– alexjosesilva
In my view, you are missing add to
lib (.jar)from your database to your project, so that it finds these classes.– Ilario Junior
https://en.wikipedia.org/wiki/SQL_injection
– Victor Stafusa
Fixed...just import it
– alexjosesilva