Im am looking for a way to verify if the number the user entered corresponds with data stored in a database. Eg. If the user entered ‘5132’ it would load all the data from a specific column into a the array and then I would loop that data and compare the input to it in the hopes of finding a match.
Simply: How do I parse data from a database (resultset) into an int array?
A simple example of what Im trying to get at
String s = JOptionPane.showInputDialog(...);
int intS = Integer.parseInt(s);
boolean correct = false;
Get database info
count++; //for every data entry
int TagNumber [] = new int [count];
for (int i=0;i<count;i++) {
if (intS == TagNumber[i]) {
correct =true;
break;
}
}
If you really want to load the values from the database and check for a specific value from the user, then you could use a Binary search, otherwise you could use a SQL query as well.
Below is an implementation (Binary Search) to find a value in an Array.
The database functionality