Deixa eu postar o fonte:
Não sei porque essa porcaria não quer aceitar o addRow, eu tento tento e nada.
package visual;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class FormAluno extends javax.swing.JDialog {
String url = "";
String acaoCadastro = "";
Statement st;
PreparedStatement pst;
Connection con;
/** Creates new form FormAluno */
public FormAluno(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.setLocationRelativeTo(null);
desabilitaBotao();
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
con = DriverManager.getConnection("jdbc:firebirdsql://localhost/C:/ProjetoIntegrador/database/DBSISTEMA.FDB","SYSDBA","masterkey");
st = con.createStatement();
System.out.println("Conexão efetuada com sucesso.");
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this,"Ocorreu um erro ao tentar acessar o banco!","Ops",JOptionPane.ERROR_MESSAGE);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this,"Ocorreu um erro ao tentar acessar o banco!","Ops",JOptionPane.ERROR_MESSAGE);
}
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Código Gerado ">
private void initComponents() {
jbtnSair = new javax.swing.JButton();
jtpAlunos = new javax.swing.JTabbedPane();
jpPesquisaAlunos = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jtfNomePesquisa = new javax.swing.JTextField();
jbtnPesquisar = new javax.swing.JButton();
jspTabela = new javax.swing.JScrollPane();
jtTabelaAlunos = new javax.swing.JTable();
jpCadastroAlunos = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jbtnNovo = new javax.swing.JButton();
jbtnAlterar = new javax.swing.JButton();
jbtnExcluir = new javax.swing.JButton();
jbtnSalvar = new javax.swing.JButton();
jbtnCancelar = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jtfCodigo = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jtfNome = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jtfTelefone = new javax.swing.JTextField();
jtfEmail = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jtaObservacao = new javax.swing.JTextArea();
jpAulasAluno = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jtAulasAlunos = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Cadastro de Alunos");
setResizable(false);
jbtnSair.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\clearFilter.gif"));
jbtnSair.setText("Sair");
jbtnSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnSairActionPerformed(evt);
}
});
jLabel6.setText("Nome aluno:");
jbtnPesquisar.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\liveResults.gif"));
jbtnPesquisar.setText("Pesquisar");
jbtnPesquisar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnPesquisarActionPerformed(evt);
}
});
jtTabelaAlunos.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Código", "Nome", "Telefone", "E-mail"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jspTabela.setViewportView(jtTabelaAlunos);
javax.swing.GroupLayout jpPesquisaAlunosLayout = new javax.swing.GroupLayout(jpPesquisaAlunos);
jpPesquisaAlunos.setLayout(jpPesquisaAlunosLayout);
jpPesquisaAlunosLayout.setHorizontalGroup(
jpPesquisaAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpPesquisaAlunosLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfNomePesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnPesquisar, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addContainerGap())
.addComponent(jspTabela, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
);
jpPesquisaAlunosLayout.setVerticalGroup(
jpPesquisaAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpPesquisaAlunosLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jpPesquisaAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jpPesquisaAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfNomePesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbtnPesquisar))
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
.addComponent(jspTabela, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jtpAlunos.addTab("Pesquisa Alunos", jpPesquisaAlunos);
jbtnNovo.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\new.gif"));
jbtnNovo.setMnemonic('N');
jbtnNovo.setText("Novo");
jbtnNovo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnNovoActionPerformed(evt);
}
});
jbtnAlterar.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\paste.gif"));
jbtnAlterar.setMnemonic('A');
jbtnAlterar.setText("Alterar");
jbtnAlterar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnAlterarActionPerformed(evt);
}
});
jbtnExcluir.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\trash-icon.gif"));
jbtnExcluir.setMnemonic('E');
jbtnExcluir.setText("Excluir");
jbtnExcluir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnExcluirActionPerformed(evt);
}
});
jbtnSalvar.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\save.gif"));
jbtnSalvar.setMnemonic('S');
jbtnSalvar.setText("Salvar");
jbtnSalvar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnSalvarActionPerformed(evt);
}
});
jbtnCancelar.setIcon(new javax.swing.ImageIcon("C:\\ProjetoIntegrador\\src\\resources\\delete.gif"));
jbtnCancelar.setMnemonic('C');
jbtnCancelar.setText("Cancelar");
jbtnCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnCancelarActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(68, Short.MAX_VALUE)
.addComponent(jbtnNovo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnAlterar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnExcluir)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnSalvar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnCancelar)
.addGap(39, 39, 39))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbtnNovo)
.addComponent(jbtnAlterar)
.addComponent(jbtnExcluir)
.addComponent(jbtnSalvar)
.addComponent(jbtnCancelar))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLabel1.setText("C\u00f3digo:");
jtfCodigo.setEditable(false);
jLabel2.setText("Nome:");
jLabel3.setText("Fone:");
jLabel4.setText("E-mail:");
jLabel5.setText("Observa\u00e7\u00e3o:");
jtaObservacao.setColumns(20);
jtaObservacao.setRows(5);
jScrollPane2.setViewportView(jtaObservacao);
javax.swing.GroupLayout jpCadastroAlunosLayout = new javax.swing.GroupLayout(jpCadastroAlunos);
jpCadastroAlunos.setLayout(jpCadastroAlunosLayout);
jpCadastroAlunosLayout.setHorizontalGroup(
jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jpCadastroAlunosLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpCadastroAlunosLayout.createSequentialGroup()
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtfEmail)
.addComponent(jtfNome, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))))
.addContainerGap(85, Short.MAX_VALUE))
);
jpCadastroAlunosLayout.setVerticalGroup(
jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jpCadastroAlunosLayout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(17, 17, 17)
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jtfNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jtfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jpCadastroAlunosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(jtfEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(82, Short.MAX_VALUE))
);
jtpAlunos.addTab("Cadastro de Alunos", jpCadastroAlunos);
jtAulasAlunos.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Nome Aluno", "Turma", "Aula", "Tipo Aula"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(jtAulasAlunos);
javax.swing.GroupLayout jpAulasAlunoLayout = new javax.swing.GroupLayout(jpAulasAluno);
jpAulasAluno.setLayout(jpAulasAlunoLayout);
jpAulasAlunoLayout.setHorizontalGroup(
jpAulasAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
);
jpAulasAlunoLayout.setVerticalGroup(
jpAulasAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
);
jtpAlunos.addTab("Aulas do Aluno", jpAulasAluno);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jbtnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jtpAlunos, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jbtnSair)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jtpAlunos, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
private void jbtnSairActionPerformed(java.awt.event.ActionEvent evt) {
try {
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
dispose();
}
private void jbtnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {
String sql = "select alunos.alcodigo,alunos.alnome,alunos.altelefone,alunos.alemail,alunos.aleobservacao " +
"from alunos where alunos.alnome containing 'a'";
try {
ResultSet rs = st.executeQuery(sql);
while( rs.next() ) {
}
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this,"Ocorreu um erro ao tentar executar a pesquisa!","Ops",JOptionPane.ERROR_MESSAGE);
}
}
private void jbtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {
acaoCadastro = "";
desabilitaBotao();
}
private void jbtnSalvarActionPerformed(java.awt.event.ActionEvent evt) {
if (acaoCadastro == "NOVO"){
String sql = "insert into alunos (alunos.alnome,alunos.altelefone,alunos.alemail,alunos.aleobservacao) values (?,?,?,?)";
try {
pst = con.prepareStatement(sql);
pst.setString(1,jtfNome.getText());
pst.setString(2,jtfTelefone.getText());
pst.setString(3,jtfEmail.getText());
pst.setString(4,jtaObservacao.getText());
pst.executeUpdate();
acaoCadastro = "";
} catch (SQLException ex) {
ex.printStackTrace();
}
} else
if (acaoCadastro == "ALTERAR"){
String sql = "insert into alunos (alunos.alnome,alunos.altelefone,alunos.alemail,alunos.aleobservacao) values (?,?,?,?)";
try {
pst = con.prepareStatement(sql);
pst.setString(1,jtfNome.getText());
pst.setString(2,jtfTelefone.getText());
pst.setString(3,jtfEmail.getText());
pst.setString(4,jtaObservacao.getText());
acaoCadastro = "";
} catch (SQLException ex) {
ex.printStackTrace();
}
} else if (acaoCadastro == ""){
JOptionPane.showMessageDialog(this,"Não há uma operação em andamento","Sem ação",JOptionPane.ERROR_MESSAGE);
}
desabilitaBotao();
}
private void jbtnExcluirActionPerformed(java.awt.event.ActionEvent evt) {
desabilitaBotao();
}
private void jbtnAlterarActionPerformed(java.awt.event.ActionEvent evt) {
habilitaBotao();
}
private void jbtnNovoActionPerformed(java.awt.event.ActionEvent evt) {
acaoCadastro = "NOVO";
habilitaBotao();
}
// <editor-fold defaultstate="collapsed" desc=" Acoes botoes ">
public void habilitaBotao(){
jbtnNovo.setEnabled(false);
jbtnAlterar.setEnabled(false);
jbtnExcluir.setEnabled(false);
jbtnSalvar.setEnabled(true);
jbtnCancelar.setEnabled(true);
}
public void desabilitaBotao(){
jbtnNovo.setEnabled(true);
jbtnAlterar.setEnabled(true);
jbtnExcluir.setEnabled(true);
jbtnSalvar.setEnabled(false);
jbtnCancelar.setEnabled(false);
}
// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormAluno(new javax.swing.JFrame(), true).setVisible(true);
}
});
}
// <editor-fold defaultstate="collapsed" desc=" Itens GUI e Declaracao de variaveis ">
// Declaração de variáveis - não modifique
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JButton jbtnAlterar;
private javax.swing.JButton jbtnCancelar;
private javax.swing.JButton jbtnExcluir;
private javax.swing.JButton jbtnNovo;
private javax.swing.JButton jbtnPesquisar;
private javax.swing.JButton jbtnSair;
private javax.swing.JButton jbtnSalvar;
private javax.swing.JPanel jpAulasAluno;
private javax.swing.JPanel jpCadastroAlunos;
private javax.swing.JPanel jpPesquisaAlunos;
private javax.swing.JScrollPane jspTabela;
private javax.swing.JTable jtAulasAlunos;
private javax.swing.JTable jtTabelaAlunos;
private javax.swing.JTextArea jtaObservacao;
private javax.swing.JTextField jtfCodigo;
private javax.swing.JTextField jtfEmail;
private javax.swing.JTextField jtfNome;
private javax.swing.JTextField jtfNomePesquisa;
private javax.swing.JTextField jtfTelefone;
private javax.swing.JTabbedPane jtpAlunos;
// Fim da declaração de variáveis
// </editor-fold>
}