I guess your query is not ok.
But that's something you will have to figure out with your DB.
The forming of the array looks fine to me.
Addition
Here is a little example code.
You should probably check if you can simply return the Vector. A Vector is often simpler to work with.
Faster would be a HashMap, e.g. if you need to pick certain values out o the given set of data.
import java.util.Vector;
public class Example {
private Integer[] getValues(){
Vector<Integer> oVector = new Vector<Integer>();
oVector.add(new Integer(1));
oVector.add(new Integer(2));
oVector.add(new Integer(3));
return oVector.toArray(new Integer[oVector.size()]);
}
public static void main(String[] args) {
Example oExample = new Example();
Integer[] oArray = oExample.getValues();
for (Integer oValue : oArray) {
System.out.println("Value is " + oValue);
}
}
}