Boa tarde pessoal, estou tentando acessar meu Banco de Dados HSQLDB Servidor, para pegar dados e inseri-los numa JList, mas sempre que chega na parte em que o código tenta acessar o banco da o seguinte erro:
O código é este:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.ufal.ic.falibras.ihc.cadastro;
import br.ufal.ic.falibras.common.persistence.ErroBDException;
import br.ufal.ic.falibras.common.persistence.IBancoDeDadosFinal;
import java.util.List;
import javax.swing.JOptionPane;
/**
*
* @author Karlos
*/
public class CadastroPalavras extends javax.swing.JFrame {
private IBancoDeDadosFinal banco;
/**
* Creates new form CadastroPalavras
*/
public CadastroPalavras() {
initComponents();
LimpaFormulario();
inicializarGenerosExistentes();
inicializarNumerosExistentes();
inicializarTemposExistentes();
inicializarPessoasExistentes();
}
/**
* 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() {
jPanel1 = new javax.swing.JPanel();
Nome = new javax.swing.JLabel();
NomeText = new javax.swing.JTextField();
Radical = new javax.swing.JLabel();
RadicalText = new javax.swing.JTextField();
Genero = new javax.swing.JLabel();
jScrollPane5 = new javax.swing.JScrollPane();
jlGenero = new javax.swing.JList();
Numero = new javax.swing.JLabel();
jScrollPane6 = new javax.swing.JScrollPane();
jlNumero = new javax.swing.JList();
Tempo = new javax.swing.JLabel();
jScrollPane7 = new javax.swing.JScrollPane();
jlTempo = new javax.swing.JList();
Pessoa = new javax.swing.JLabel();
jScrollPane8 = new javax.swing.JScrollPane();
jlPessoa = new javax.swing.JList();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastro de Palavras"));
Nome.setText("Nome:");
Radical.setText("Radical:");
Genero.setText("Gênero:");
jlGenero.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jlGenero.setToolTipText("Gênero da Palavra");
jScrollPane5.setViewportView(jlGenero);
Numero.setText("Número:");
jlNumero.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jlNumero.setToolTipText("Gênero da Palavra");
jScrollPane6.setViewportView(jlNumero);
Tempo.setText("Tempo:");
jlTempo.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jlTempo.setToolTipText("Gênero da Palavra");
jScrollPane7.setViewportView(jlTempo);
Pessoa.setText("Pessoa:");
jlPessoa.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jlPessoa.setToolTipText("Gênero da Palavra");
jScrollPane8.setViewportView(jlPessoa);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addComponent(Genero))
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Numero)
.addGap(38, 38, 38)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(Tempo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 94, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Pessoa)
.addGap(35, 35, 35))
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Nome)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(NomeText)
.addGap(18, 18, 18)
.addComponent(Radical)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(RadicalText, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Nome)
.addComponent(NomeText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Radical)
.addComponent(RadicalText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Pessoa)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Genero)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Tempo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Numero)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(188, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
/**
* @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(CadastroPalavras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CadastroPalavras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CadastroPalavras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CadastroPalavras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CadastroPalavras().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel Genero;
private javax.swing.JLabel Nome;
private javax.swing.JTextField NomeText;
private javax.swing.JLabel Numero;
private javax.swing.JLabel Pessoa;
private javax.swing.JLabel Radical;
private javax.swing.JTextField RadicalText;
private javax.swing.JLabel Tempo;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JList jlGenero;
private javax.swing.JList jlNumero;
private javax.swing.JList jlPessoa;
private javax.swing.JList jlTempo;
// End of variables declaration
private void LimpaFormulario(){
//Variaveis de Dados
this.jlGenero.setEnabled(true);
this.jlGenero.setModel(this.jlGenero.getModel());
this.jlNumero.setEnabled(true);
this.jlNumero.setModel(this.jlNumero.getModel());
this.jlTempo.setEnabled(true);
this.jlTempo.setModel(this.jlTempo.getModel());
this.jlPessoa.setEnabled(true);
this.jlPessoa.setModel(this.jlPessoa.getModel());
}
private void inicializarGenerosExistentes() {
try {
this.jlGenero.setModel(new javax.swing.AbstractListModel() {
String[] strings = obterDadosGeneros();
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
} catch (ErroBDException ex) {
JOptionPane.showMessageDialog(null, "Erro na inicialização da janela!", "Mensagem Informativa", JOptionPane.PLAIN_MESSAGE, null);
}
}
private String[] obterDadosGeneros() throws ErroBDException {
List<String> dadosGeneros = this.banco.consultarNomesTodosGeneros();
String[] out = new String[dadosGeneros.size()];
for (int i = 0; i < out.length; i++) {
out[i] = dadosGeneros.get(i);
}
return out;
}
private void inicializarNumerosExistentes() {
try {
this.jlNumero.setModel(new javax.swing.AbstractListModel() {
String[] strings = obterDadosNumeros();
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
} catch (ErroBDException ex) {
JOptionPane.showMessageDialog(null, "Erro na inicialização da janela!", "Mensagem Informativa", JOptionPane.PLAIN_MESSAGE, null);
}
}
private String[] obterDadosNumeros() throws ErroBDException {
List<String> dadosNumeros = this.banco.consultarNomesTodosNumeros();
String[] out = new String[dadosNumeros.size()];
for (int i = 0; i < out.length; i++) {
out[i] = dadosNumeros.get(i);
}
return out;
}
private void inicializarTemposExistentes() {
try {
this.jlTempo.setModel(new javax.swing.AbstractListModel() {
String[] strings = obterDadosTempos();
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
} catch (ErroBDException ex) {
JOptionPane.showMessageDialog(null, "Erro na inicialização da janela!", "Mensagem Informativa", JOptionPane.PLAIN_MESSAGE, null);
}
}
private String[] obterDadosTempos() throws ErroBDException {
List<String> dadosTempos = this.banco.consultarNomesTodosTempos();
String[] out = new String[dadosTempos.size()];
for (int i = 0; i < out.length; i++) {
out[i] = dadosTempos.get(i);
}
return out;
}
private void inicializarPessoasExistentes() {
try {
this.jlPessoa.setModel(new javax.swing.AbstractListModel() {
String[] strings = obterDadosPessoas();
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
} catch (ErroBDException ex) {
JOptionPane.showMessageDialog(null, "Erro na inicialização da janela!", "Mensagem Informativa", JOptionPane.PLAIN_MESSAGE, null);
}
}
private String[] obterDadosPessoas() throws ErroBDException {
List<String> dadosPessoas = this.banco.consultarNomesTodasPessoas();
String[] out = new String[dadosPessoas.size()];
for (int i = 0; i < out.length; i++) {
out[i] = dadosPessoas.get(i);
}
return out;
}
}
eu não consigo ver nenhum valor nulo, o que pode estar acontecendo?