Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Random Questions from MS Access to a label

Posted on 2004-08-22
9
Medium Priority
?
186 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

670 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