In my database application, I sometimes have to deal with rows nullin the database. In most cases, this is normal, but when it comes to displaying data in a form, Swing components - for example, with the help of JTextField- cannot process null strings. ( .setText(null)does not work)
( EDIT: I just noticed that it JTextFieldactually takes a string null, but the question remains for all other cases where unexpected values nullcan lead to problems.)
Zero values have no special meaning; they can (should) be considered as empty strings.
What is the best practice to solve this problem? Sorry, I cannot modify the database.
- Checking each value if it is
nullbefore the call setText()? - Adding a try-catch handler for each call
setText()? - Introducing a static method that filters all rows
null? - Replace all values
nullwith blank lines immediately after reading from the database? - ... [your suggestions]
source
share