String comparison

i have writen an SQL statement which returns a fields value within a table as a String.

for most of the instances in the table there is a value which returns a non empty String and the copmarison works fine, but for some instances the return is null....because it is empty

for this reason i keep getting errors

here is the code i am using to compare

connAdd = brokerQueries.queryAdd(count);

if (!connAdd.equals(""))

{

}

anyone have any clues?

[607 byte] By [ThierryHenrya] at [2007-11-26 23:40:02]
# 1

Tried

!"".equals(conAdd)

?

Or at least checking for null before calling any methods?

Edit: the above statement doesn't help in this case, sorry.

You need to explicitely check for null if you want to react in the same way on null and empty strings.

Message was edited by:

CeciNEstPasUnProgrammeur

CeciNEstPasUnProgrammeura at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...
# 2
i have tried
ThierryHenrya at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...
# 3

sorry pressed post by accident there

i have tried

if (!connAdd.equals(""))

{

}

and i have tried

if (!connAdd.equals(null))

{

}

and i tried

)[code]

!"".equals(connAdd)

[code]

ThierryHenrya at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...
# 4
how would i do that?
ThierryHenrya at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...
# 5
>for this reason i keep getting errorsPlease be more specific. What was the exact error? On what line of code?
DrLaszloJamfa at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...
# 6

hey sorry for the late reply i have been away for a while...i managed to fix the probelm

what i done was create one loop using

if ( connAdd == null)

{

}

and instead of putting in another if statement i put an else statement and it all seemed to work...

thanks for your help though

ThierryHenrya at 2007-7-11 15:06:17 > top of Java-index,Java Essentials,Java Programming...