hey everyone , i have a simple question about result in a result set that gives back null , if my code looks like this : System.out.println("Street : " + rs.getString("STREET")); output (it actually writes 'null'): " Street : null "; i don't want it to happen , i wish to it like this ... output: " Street : "; if(rs.getStreet("STREET") == null) //this returns false if(rs.getStreet("STREET").equals("null")) //of course.. NullPointerException if(rs.getStreet("STREET") != null) //returns false too. i can only do something like this : String str = rs.getString("STREET"); if(str != null) System.out.println("Street : " + str) // OK else System.out.println("Street : ") which cause the code to run very slow ... and resources are low , is there a way to compare a rs.getString("STREET") (or ay other type) to NULL... ! :-) thanks a lot jonathan
hi! ResultSet interface provides a method for testing column values within a result set to determine if it is null. The wasNull() method returns true if the last col read from the ResultSet object was null. if(rs.wasNull()) System.out.println("No Address");
jonathan mozes
Greenhorn
Joined: Jan 21, 2001
Posts: 13
posted
0
thank you , but i don't wish to invoke wasNull() cause it's being called after the value retrived , i wish to test the value when i invoke getXXX method. your JonathanM