Click here to Skip to main content
15,889,116 members
Home / Discussions / Java
   

Java

 
SuggestionRe: Rising error in Constructor-based Dependency Injection, Spring Framework Pin
Richard MacCutchan30-Oct-13 22:05
mveRichard MacCutchan30-Oct-13 22:05 
AnswerRe: Rising error in Constructor-based Dependency Injection, Spring Framework Pin
Bernhard Hiller31-Oct-13 1:31
Bernhard Hiller31-Oct-13 1:31 
QuestionJSpinner value from Database. Pin
chdboy27-Oct-13 2:31
chdboy27-Oct-13 2:31 
AnswerRe: JSpinner value from Database. Pin
jschell30-Oct-13 8:18
jschell30-Oct-13 8:18 
Questionpublic and private RSA keys Pin
Beulah Dalrymple25-Oct-13 11:41
Beulah Dalrymple25-Oct-13 11:41 
AnswerRe: public and private RSA keys Pin
Richard MacCutchan25-Oct-13 22:58
mveRichard MacCutchan25-Oct-13 22:58 
QuestionNavigationa with ResultSet Pin
chdboy24-Oct-13 21:55
chdboy24-Oct-13 21:55 
AnswerRe: Navigationa with ResultSet Pin
Nagy Vilmos24-Oct-13 22:41
professionalNagy Vilmos24-Oct-13 22:41 
Separate your actions...

0. Method to query the data, then store the record set.
1. Method to display a record.

Something like [untested code]

Java
class Hatstand
  extends Stuff
{
  private RecordSet recordSet;
  // need to initialise & stuff.

  /**
   * Query the data
   */
  private void submitQuery()
  {
    Statement stmt = null;
    String query = "select * from Employer";
    try
    {
       stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);	        
       this.recordSet = stmt.executeQuery(query);
    } 
    catch (SQLException e )
    {
       // message box'd be better
       e.printStackTrace();
       this.recordSet = null;
    }
    finally
    {
      setRecord(true);
    }
  }

  /**
   * Set the displayed record
   * called after query and by next/previous buttons.
   */
  private void setRecord(boolean forward)
  {
    // set the record:
    boolean isNull = true;
    if (this.RecordSet != null)
    {
      if (forward && !this.RecordSet.isLast())
      {
        this.RecordSet.next();
        isNull = false;
      }
      else if (!forward && !this.RecordSet.isFirst())
      {
        this.RecordSet.previous();
        isNull = false;
      }
    }

    if (isNull)
    {
      firstNameTextField.setText(null);
      lastNameTextField.setText(null);
      addressTextField.setText(null);    }
    }
    else
    {
      firstNameTextField.setText(rs.getString(2));
      lastNameTextField.setText(rs.getString(3));
      addressTextField.setText(rs.getString(4));    }
    }
  }
}

speramus in juniperus

GeneralRe: Navigationa with ResultSet Pin
chdboy26-Oct-13 20:57
chdboy26-Oct-13 20:57 
QuestionPutting a split String in a printout. Pin
chdboy23-Oct-13 19:58
chdboy23-Oct-13 19:58 
AnswerRe: Putting a split String in a printout. Pin
Richard MacCutchan23-Oct-13 21:30
mveRichard MacCutchan23-Oct-13 21:30 
GeneralRe: Putting a split String in a printout. Pin
chdboy23-Oct-13 23:16
chdboy23-Oct-13 23:16 
GeneralRe: Putting a split String in a printout. Pin
Richard MacCutchan23-Oct-13 23:23
mveRichard MacCutchan23-Oct-13 23:23 
GeneralRe: Putting a split String in a printout. Pin
chdboy24-Oct-13 0:53
chdboy24-Oct-13 0:53 
Questionapplets Pin
Member 1035631323-Oct-13 18:28
Member 1035631323-Oct-13 18:28 
AnswerRe: applets Pin
Richard MacCutchan23-Oct-13 21:28
mveRichard MacCutchan23-Oct-13 21:28 
QuestionRe: applets Pin
Member 1035631324-Oct-13 16:30
Member 1035631324-Oct-13 16:30 
AnswerRe: applets Pin
Richard MacCutchan24-Oct-13 21:15
mveRichard MacCutchan24-Oct-13 21:15 
SuggestionRe: applets Pin
Member 1035631324-Oct-13 22:01
Member 1035631324-Oct-13 22:01 
QuestionSomething is wrong with the print command. Pin
chdboy21-Oct-13 3:31
chdboy21-Oct-13 3:31 
AnswerRe: Something is wrong with the print command. Pin
angrybobcat21-Oct-13 23:01
angrybobcat21-Oct-13 23:01 
GeneralRe: Something is wrong with the print command. Pin
chdboy21-Oct-13 23:37
chdboy21-Oct-13 23:37 
SuggestionRe: Something is wrong with the print command. Pin
Richard MacCutchan21-Oct-13 23:50
mveRichard MacCutchan21-Oct-13 23:50 
GeneralRe: Something is wrong with the print command. Pin
chdboy22-Oct-13 23:33
chdboy22-Oct-13 23:33 
GeneralRe: Something is wrong with the print command. Pin
Richard MacCutchan23-Oct-13 3:19
mveRichard MacCutchan23-Oct-13 3:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.