|
Patrick & Joel You're absolutely right - the problem was with using the .trim() method up front. The two step process listed below worked fine. Thanks and regards, Keith "Patrick L Archibald" <Patrick.Archibald@HOMETELCO.COM> on 31/07/2002 13:48:32 Please respond to java400-l@midrange.com To: java400-l@midrange.com cc: (bcc: Keith McCully/Wunderman/GB) Subject: RE: ResultSet null column Have you tried? String FIELDX = rs.getString("BFIELD2"); if (FIELDX != null) FIELDX = FIELDX.trim(); Thanx, PLA -----Original Message----- From: java400-l-admin@midrange.com [mailto:java400-l-admin@midrange.com]On Behalf Of Keith_McCully@wunderman.co.uk Sent: Wednesday, July 31, 2002 8:18 AM To: java400-l@midrange.com Subject: ResultSet null column 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 _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
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.