Ola, quando tento passar para o poximo resgistro do banco, ele nao passa, sempre fica no primeiro!
qual eh meu erro? Sera que estou usando o mesmo Resul set 'rs' diversas vezes?
aguardo!
try
{
rs = comandos.executeQuery("SELECT ID_OBRA, ID_AUTOR, TOMBO, TITULO, QUANTIDADE, DTA_AQUISICAO, LOCALIZACAO, TIPO, ISBN, EDITORA, DTA_CRIACAO, PRODUTORA, ATOR_PRINCIPAL, DURACAO, GENERO FROM BIBLIOTECA_OBRA");
boolean res = rs.next();
if(res)
{
tombo.setEditable(false);
titulo.setEditable(false);
quantidade.setEditable(false);
dataaquisicao1.setEditable(false);
localizacao.setEditable(false);
isbn.setEditable(false);
editora.setEditable(false);
datacriacao.setEditable(false);
genero.setEditable(false);
getautores.setEditable(false);
atorprincipal.setEditable(false);
duracao.setEditable(false);
produtora.setEditable(false);
//Atualiza com o banco de dados
String a = rs.getString("ID_OBRA");
codigo.setText(rs.getString("ID_OBRA"));
tombo.setText(rs.getString("TOMBO"));
titulo.setText(rs.getString("TITULO"));
quantidade.setText(rs.getString("QUANTIDADE"));
dataaquisicao1.setText(rs.getString("DTA_AQUISICAO"));
localizacao.setText(rs.getString("LOCALIZACAO"));
if(rs.getString("TIPO").equals("F"))
tipo.setSelectedIndex(1);
else
tipo.setSelectedIndex(2);
isbn.setText(rs.getString("ISBN"));
editora.setText(rs.getString("EDITORA"));
datacriacao.setText(rs.getString("DTA_CRIACAO"));
produtora.setText(rs.getString("PRODUTORA"));
atorprincipal.setText(rs.getString("ATOR_PRINCIPAL"));
duracao.setText(rs.getString("DURACAO"));
genero.setText(rs.getString("GENERO"));
//Atualiza o combo box
try
{
String get = "SELECT O.ID_OBRA,A.NOME FROM BIBLIOTECA_OBRA O JOIN BIBLIOTECA_AUTOR A ON (O.ID_AUTOR = A.ID_AUTOR) WHERE O.ID_OBRA ="+a;
rs = comandos.executeQuery(get);
boolean resp = rs.next();
if(resp)
{
String nome = rs.getString("NOME");
for(int i=1;i<getautores.getItemCount();i++)
{
String item = getautores.getItemAt(i).toString();
if(nome.equals(item))
{
getautores.setSelectedItem(nome);
}
}
}
}
catch(SQLException ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(this,ex);
}
}
else
{
JOptionPane.showMessageDialog(this,"Não há mais dados!","Fim",JOptionPane.INFORMATION_MESSAGE);
rs.last();
}
//atualiza o form
tombo.setEditable(false);
titulo.setEditable(false);
quantidade.setEditable(false);
dataaquisicao1.setEditable(false);
localizacao.setEditable(false);
isbn.setEditable(false);
editora.setEditable(false);
datacriacao.setEditable(false);
genero.setEditable(false);
getautores.setEnabled(false);
atorprincipal.setEditable(false);
duracao.setEditable(false);
produtora.setEditable(false);
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(this,"Problemas no comando SQL: "+ex,"ERRO!",JOptionPane.ERROR_MESSAGE);
}