null in 2 dimensional array problem
I have a problem on checking process to determine validity.
Code is something like :
Code:
private boolean isInOtherAField() {
try {
qfield.setQuery("SELECT afield, acode FROM test WHERE afield = '" + txAField.getText().toString().trim() + "';");
} catch (SQLException e) {
e.printStackTrace();
};
if (!(qfield.getValueAt(0, 0).toString().trim()).equals(txAField.getText().toString().trim())){
return true;
} else {
return false;
}
}
qfield is tablemodel extended from abstracttablemodel.
Then in my main code I call isInOtherAField() and determine what to do on true and false return value.
When the query returns a row whether it's true or false, it works fine.
However then there's problem when the query returns empty result (in case of a new field code), which gives me :
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
is there any way to handle this null 2-dimensional array ?
Thanks in advance,
Re: null in 2 dimensional array problem
Not sure what you are asking but generally you would check the length of an array before trying to access an element in the array.
Re: null in 2 dimensional array problem
I skipped checking array length, now doing the length checking first and seems fine
If there's no more post then it's solved
Thanks,
Re: null in 2 dimensional array problem
Quote:
Originally Posted by
Levian
If there's no more post then it's solved
If you are satisfied with others' comments you can mark the thread solved.
Re: null in 2 dimensional array problem
Quote:
Originally Posted by
Eranga
If you are satisfied with others' comments you can mark the thread solved.
How does one do this with the new forum software?
Re: null in 2 dimensional array problem
Quote:
Originally Posted by
Fubarable
How does one do this with the new forum software?
Sorry about that, with our new s/w we cannot do that as far as I know. Just by editing the thread we can do that. Sorry, since I get use of to do that I think others will do the same.
Re: null in 2 dimensional array problem
Quote:
Originally Posted by
Fubarable
How does one do this with the new forum software?
Sorry about that, with our new s/w we cannot do that as far as I know. Just by editing the thread we can do that. Sorry, since I get use of to do that I think others will do the same.
Re: null in 2 dimensional array problem
Just have this checked and yes, it was answered and problem solved, but how to do that SOLVED mark that you said ?
So far I have most if not all are solved thanks to the ppl here.
Just let me know how-to and I'll mark it solved.
Thanks,
Re: null in 2 dimensional array problem
Quote:
Originally Posted by
Levian
Just have this checked and yes, it was answered and problem solved, but how to do that SOLVED mark that you said ?
So far I have most if not all are solved thanks to the ppl here.
Just let me know how-to and I'll mark it solved.
Thanks,
Sure I'll let you know.