galera, ta dando esse erro ai que postei no topico, mais nao sei onde… podem me ajudar?
/**
*
-
@author SuporteMdw
*/
public class cadastro extends javax.swing.JFrame {/**
- Creates new form cadastro
*/
Connection conecta;
PreparedStatement pst;
ResultSet rs;
String url = “jdbc:mysql://localhost/Cad_cliente”; String driver = “com.mysql.jdbc.Driver”; String user = “root”; String pass = “”;
public void abreconexao() { try{ Class.forName(driver);
conecta = (com.mysql.jdbc.Connection) DriverManager.getConnection(url, user, pass); pst = (PreparedStatement) conecta.createStatement(); System.out.println("conectado!"); } catch (ClassNotFoundException | SQLException erro){ System.out.println("Não conectado!"); }
}
public cadastro() throws ClassNotFoundException {
initComponents();}public void cadastraUsuario (){
//String sql = “insert into usuario (nome,senha) values (?, ?)”;try {
- Creates new form cadastro
------------------------------------------ ele da um erro aqui nessa linha de baixo —
PreparedStatement stmt = conecta.prepareStatement(“insert into usuario (nome,senha) values (?,?)”);
//pst = conecta.prepareStatement(stmt);
pst.setString(1,txt_nome.getText());
pst.setString(2,txt_senha.getText());
pst.execute();
pst.close();
System.out.println(“Gravado!”);
conecta.close();
JOptionPane.showMessageDialog(null, " inserido");
} catch (SQLException error) {
JOptionPane.showMessageDialog(null, error);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
txt_nome = new javax.swing.JTextField();
txt_senha = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
jLabel1.setText("Nome:");
getContentPane().add(jLabel1);
jLabel1.setBounds(20, 30, 31, 14);
getContentPane().add(txt_nome);
txt_nome.setBounds(70, 30, 90, 20);
getContentPane().add(txt_senha);
txt_senha.setBounds(70, 70, 90, 20);
jLabel2.setText("cpf");
getContentPane().add(jLabel2);
jLabel2.setBounds(20, 70, 15, 14);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(50, 120, 73, 23);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cadastraUsuario();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
new cadastro().setVisible(true);
} catch (ClassNotFoundException ex) {
Logger.getLogger(cadastro.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField txt_nome;
private javax.swing.JTextField txt_senha;
// End of variables declaration
}