ta dando esse erro e eu não sei o pq. o codigo nao da erro nenhum
package br.com.funeraria.controle;
import br.com.funeraria.model.Plano;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author Luan
*/
public class PlanoDAO {
ConexaoBD conex = new ConexaoBD();
Plano plan = new Plano();
public void Salvar(Plano plan) throws SQLException{
conex.conexao();
PreparedStatement pst;
try{
pst = conex.con.prepareStatement("INSERT INTO plano(Tipo_Plano, Descricao_Plano) VALUES (?,?)");
pst.setString(1, plan.getTipo_plano());
pst.setString(2, plan.getDescricao());
pst.execute();
pst.close();
JOptionPane.showMessageDialog(null, "Plano Cadastrado com Sucesso!!!");
} catch (SQLException ex){
JOptionPane.showMessageDialog(null, "Plano não foi cadastrado :(" + ex);
}
conex.desconecta();
}
public Plano buscarPlano(Plano pla){
conex.conexao();
conex.executaSQL("select * from plano where Tipo_Plano like '%" + plan.getPesquisar() + "%'");
try {
conex.rs.first();
pla.setIdPlano(conex.rs.getInt("idPlano"));
pla.setTipo_plano(conex.rs.getString("Tipo_Plano"));
pla.setDescricao(conex.rs.getString("Descricao_Plano"));
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erro ao inserir dados\n" +ex);
}
conex.desconecta();
return null;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.funeraria.view;
import br.com.funeraria.controle.PlanoDAO;
import br.com.funeraria.model.Plano;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author Eduardo
*/
public class CadPlano extends javax.swing.JFrame {
/**
* Creates new form CadPlano
*/
PlanoDAO plan = new PlanoDAO();
Plano pli = new Plano();
public CadPlano() {
initComponents();
}
/**
* 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() {
jInternalFrame1 = new javax.swing.JInternalFrame();
jScrollPane2 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();
jLayeredPane1 = new javax.swing.JLayeredPane();
jPanel1 = new javax.swing.JPanel();
Novo = new javax.swing.JButton();
Salvar = new javax.swing.JButton();
Cancelar = new javax.swing.JButton();
Editar = new javax.swing.JButton();
Excluir = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
TipoPlano = new javax.swing.JTextField();
PesquisarTXTFIELD = new javax.swing.JTextField();
Pesquisar = new javax.swing.JButton();
jScrollPane4 = new javax.swing.JScrollPane();
jTablePesquisar = new javax.swing.JTable();
jTextFieldDescricao = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jInternalFrame1.setVisible(true);
javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jTable2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(jTable2);
javax.swing.GroupLayout jLayeredPane1Layout = new javax.swing.GroupLayout(jLayeredPane1);
jLayeredPane1.setLayout(jLayeredPane1Layout);
jLayeredPane1Layout.setHorizontalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jLayeredPane1Layout.setVerticalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(525, 490));
setResizable(false);
getContentPane().setLayout(null);
jPanel1.setBackground(new java.awt.Color(36, 32, 58));
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel1.setLayout(null);
Novo.setBackground(new java.awt.Color(0, 0, 0));
Novo.setForeground(new java.awt.Color(255, 255, 255));
Novo.setText("Novo");
Novo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NovoActionPerformed(evt);
}
});
jPanel1.add(Novo);
Novo.setBounds(12, 34, 77, 23);
Salvar.setBackground(new java.awt.Color(0, 0, 0));
Salvar.setForeground(new java.awt.Color(255, 255, 255));
Salvar.setText("Salvar");
Salvar.setEnabled(false);
Salvar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SalvarActionPerformed(evt);
}
});
jPanel1.add(Salvar);
Salvar.setBounds(12, 63, 77, 23);
Cancelar.setBackground(new java.awt.Color(0, 0, 0));
Cancelar.setForeground(new java.awt.Color(255, 255, 255));
Cancelar.setText("Cancelar");
Cancelar.setEnabled(false);
jPanel1.add(Cancelar);
Cancelar.setBounds(12, 92, 75, 23);
Editar.setBackground(new java.awt.Color(0, 0, 0));
Editar.setForeground(new java.awt.Color(255, 255, 255));
Editar.setText("Editar");
Editar.setEnabled(false);
jPanel1.add(Editar);
Editar.setBounds(12, 121, 77, 23);
Excluir.setBackground(new java.awt.Color(0, 0, 0));
Excluir.setForeground(new java.awt.Color(255, 255, 255));
Excluir.setText("Excluir");
Excluir.setEnabled(false);
jPanel1.add(Excluir);
Excluir.setBounds(12, 150, 77, 23);
jLabel2.setBackground(new java.awt.Color(0, 0, 0));
jLabel2.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Tipo do Plano:");
jPanel1.add(jLabel2);
jLabel2.setBounds(240, 20, 108, 18);
jLabel3.setBackground(new java.awt.Color(0, 0, 0));
jLabel3.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Descrição:");
jPanel1.add(jLabel3);
jLabel3.setBounds(210, 50, 79, 18);
TipoPlano.setEnabled(false);
TipoPlano.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TipoPlanoActionPerformed(evt);
}
});
jPanel1.add(TipoPlano);
TipoPlano.setBounds(350, 10, 150, 30);
jPanel1.add(PesquisarTXTFIELD);
PesquisarTXTFIELD.setBounds(40, 200, 140, 30);
Pesquisar.setBackground(new java.awt.Color(0, 0, 0));
Pesquisar.setForeground(new java.awt.Color(255, 255, 255));
Pesquisar.setText("Pesquisar");
Pesquisar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PesquisarActionPerformed(evt);
}
});
jPanel1.add(Pesquisar);
Pesquisar.setBounds(190, 200, 100, 30);
jTablePesquisar.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{},
{},
{},
{}
},
new String [] {
}
));
jScrollPane4.setViewportView(jTablePesquisar);
jPanel1.add(jScrollPane4);
jScrollPane4.setBounds(42, 242, 450, 180);
jPanel1.add(jTextFieldDescricao);
jTextFieldDescricao.setBounds(300, 50, 200, 140);
getContentPane().add(jPanel1);
jPanel1.setBounds(0, 40, 523, 435);
jLabel1.setFont(new java.awt.Font("Arial Black", 1, 12)); // NOI18N
jLabel1.setText("Planos");
getContentPane().add(jLabel1);
jLabel1.setBounds(230, 10, 50, 20);
setSize(new java.awt.Dimension(531, 506));
setLocationRelativeTo(null);
}// </editor-fold>
private void TipoPlanoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void NovoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TipoPlano.setEnabled(true);
jTextFieldDescricao.setEnabled(true);
Salvar.setEnabled(true);
}
private void SalvarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pli.setTipo_plano(TipoPlano.getText());
pli.setDescricao(jTextFieldDescricao.getText());
try {
plan.Salvar(pli);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
TipoPlano.setText("");
jTextFieldDescricao.setText("");
TipoPlano.setEnabled(false);
jTextFieldDescricao.setEnabled(false);
Salvar.setEnabled(false);
}
private void PesquisarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pli.setPesquisar(PesquisarTXTFIELD.getText());
Plano pl = plan.buscarPlano(pli);
TipoPlano.setText(pl.getTipo_plano());
jTextFieldDescricao.setText(pl.getDescricao());
}
/**
* @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(CadPlano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CadPlano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CadPlano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CadPlano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CadPlano().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Cancelar;
private javax.swing.JButton Editar;
private javax.swing.JButton Excluir;
private javax.swing.JButton Novo;
private javax.swing.JButton Pesquisar;
private javax.swing.JTextField PesquisarTXTFIELD;
private javax.swing.JButton Salvar;
private javax.swing.JTextField TipoPlano;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLayeredPane jLayeredPane1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTable jTable2;
private javax.swing.JTable jTablePesquisar;
private javax.swing.JTextField jTextFieldDescricao;
// End of variables declaration
}