oi
sera que alguem pode me ajudar a encontrar o erro no cod abaixo
try{
if(t1.getText()!=null)
{
resultado=comando.executeQuery("select nome,cpf,matricula from aluno where Id='"+t1.getText()+"'");
resultado.next();
String h=resultado.getObject(1).toString();
String h1=resultado.getObject(2).toString();
String h2=resultado.getObject(3).toString();
t0.setText(h);t2.setText(h1);t3.setText(h2);
}
else if(t0.getText()!=null)
{
resultado=comando.executeQuery("select Id,cpf,matricula from aluno where nome='"+t0.getText()+"'");
resultado.next();
String h=resultado.getObject(1).toString();
String h1=resultado.getObject(2).toString();
String h2=resultado.getObject(3).toString();
t1.setText(h);t2.setText(h1);t3.setText(h2);
}
else if(t2.getText()!=null)
{
resultado=comando.executeQuery("select nome,Id,matricula from aluno where Id='"+t2.getText()+"'");
resultado.next();
String h=resultado.getObject(1).toString();
String h1=resultado.getObject(2).toString();
String h2=resultado.getObject(3).toString();
t0.setText(h);t1.setText(h1);t3.setText(h2);
}
else if(t3.getText()!=null)
{
resultado=comando.executeQuery("select nome,Id,cpf from aluno where matricula='"+t3.getText()+"'");
resultado.next();
String h=resultado.getObject(1).toString();
String h1=resultado.getObject(2).toString();
String h2=resultado.getObject(3).toString();
t0.setText(h);t1.setText(h1);t2.setText(h2);
}
}
catch(Exception e1)
{
JOptionPane.showMessageDialog(null, "O aluno nÃo esta cadastrado no banco!");
e1.printStackTrace();
}
tipo ele nao executa nenhum dos if’s e da este erro aqui
java.sql.SQLException: Illegal operation on empty result set.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:841)
at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4853)
at TelaDePesquisa$1.actionPerformed(TelaDePesquisa.java:197)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
tipo se eu uso so o primeiro if funciona perfeitamente mas eu gostaria de inserir outros tipos de pesquisa e nao so o criterio que estou usando no primeiro if =[
obrigada