× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.





I have built a prepared statement that links data from 2 DB2/400 tables. Left
join is used because there will not always be a key matched row in table B but I
would always expect 1 row from table A.

PreparedStatement stmt1 = connection.prepareStatement("SELECT AFIELD1, AFIELD2,
BFIELD1, BFIELD2
     FROM A LEFT JOIN B ON AFIELD1 = BFIELD1 WHERE AFIELD1 = ?")

After I do a stmt1.executeQuery() into a ResultSet (rs) and then extract BFIELD2
as
     String FIELDX = rs.getString("BFIELD2").trim()
If a matched row in file B exists when I load FIELDX, then everything works fine
but ,if not ,then I get a NullPointerException.

I tried testing rs.getString for null prior to FIELDX load but no success.  Any
comments and suggestions on how to check for null would be very welcome!

Thanks,

Keith




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.