Solved

Random Questions from MS Access to a label

Posted on 2004-08-22
9
174 Views
Last Modified: 2010-03-31
I want to ask about JDBC Java.
I have created an application "Examination System" but the final problem I encountered is that I have placed a "Label" in a Window and  I need this label to get the random questions from Database of MS Access but the question already appeared should not be comeup again next time for another label.
 
Required features are :
1 Database file containing questions
1 GUI Window with 1 Label
and a connection between my database questions and label.
0
Comment
Question by:vicky2k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11867648
Set the label text with setText().

Keep a Set of question ids. Make sure the new question not already in the Set
0
 
LVL 35

Expert Comment

by:girionis
ID: 11867659
How many question do you have? You can load all of them up, put them in a collection and then shuffle. Then use the collection to display the question to a label.
0
 
LVL 35

Accepted Solution

by:
girionis earned 250 total points
ID: 11867669
Lets say you have a ResultSet "rs" with all the questions:

ArrayList list = new ArrayList();
while (rs.next())
{
    list.add(rs.getString(1));
}

Collections.shuffle(list);

label.setText(list.get(index));

You could have an instance variable "index" that increments everytime a question is requested from the collection.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:girionis
ID: 11867671
You will also need to cast the list element to String.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11867676
girionis' suggestion is similar, but if you place the questions in a Set, they'll already be 'shuffled' as a Set is unordered.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11867689
Forget that last suggestion of mine - it'll make it difficult to remove a question from the Set. Stick with girionis
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question