0

Here we go.

  1. I'm having 2 JFrames.

  2. JFrame1 is having a list of Employee names loaded from database.

  3. JFrame2 is use to show up more details of selected employee by getting details from database. (Full name, age, address, telephone, salary, etc...)

    I know how to connect to a db or get data from it. But my question is :

"How or where to store all the primary keys I loaded in JFrame1 for pass it to JFrame2 when someone select an employee?" [I need the primary key to get data for specific employee]

Using an "Int array" is useless, unless if i knew how many employees are there & searching by employer's name in JFrame2 is useless as there can be employees who's having same name.

Thank you all!

Community
  • 1
  • 1
Malindu
  • 135
  • 1
  • 12
  • 1) There is no need to add the major tag in the title. 2) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Dec 14 '13 at 16:50

1 Answers1

1

You need to use a List object

List<Integer> ids = new ArrayList<Integer>();

for (/* loop over your results set */) {
    int primaryKey = // the primary key on this iteration
    ids.add(primaryKey);
}
robbmj
  • 16,085
  • 8
  • 38
  • 63