I am setting a member boolean in a class file depending on whether a particular resultSet column is empty. (cartStatus = false if it's empty and cartStatus = true if it has string content.)
I find that if I try getting the field content that I get a null pointer exception later which I guess means that java doesn't get "" when it reads the field:
[red]if (rst.getString("order"=="" cartStatus = false;[/red]
(throws nullPointer)
and doing:
[red]if (rst.getString("order"==null) cartStatus = false;[/red]
would be an invalid type comparison.
so instead I did the whole thing another way which was to get the column value as an object (getObject() instead of getString()), compare it to null then read it later as a string:
in class declaration:
[red]public boolean cartObj;[/red]
one method:
[red]public void getCartStatus()
{
if ((cartObj=rst.getObject())==null) cartStatus = false;
else cartStatus = true;
}[/red]
then in another method:
[red]public void getCartOutput()
{
String cartString = cartObj.toString();
}[/red]
This works but it seems round about. Is there a more direct way to check whether a string field is zero length?
[sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
I find that if I try getting the field content that I get a null pointer exception later which I guess means that java doesn't get "" when it reads the field:
[red]if (rst.getString("order"=="" cartStatus = false;[/red]
(throws nullPointer)
and doing:
[red]if (rst.getString("order"==null) cartStatus = false;[/red]
would be an invalid type comparison.
so instead I did the whole thing another way which was to get the column value as an object (getObject() instead of getString()), compare it to null then read it later as a string:
in class declaration:
[red]public boolean cartObj;[/red]
one method:
[red]public void getCartStatus()
{
if ((cartObj=rst.getObject())==null) cartStatus = false;
else cartStatus = true;
}[/red]
then in another method:
[red]public void getCartOutput()
{
String cartString = cartObj.toString();
}[/red]
This works but it seems round about. Is there a more direct way to check whether a string field is zero length?
[sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]