RE: [INTERFACES] JDBC next() method
От | Peter Mount |
---|---|
Тема | RE: [INTERFACES] JDBC next() method |
Дата | |
Msg-id | A9DCBD548069D211924000C00D001C441D9BDF@exchange.maidstone.gov.uk обсуждение исходный текст |
Список | pgsql-interfaces |
That's correct (we use that syntax in the driver's source ourselves). wasNull() is only valid after a getxxx() call, but only for the last call. Peter -- Peter T Mount, IT Section petermount@it.maidstone.gov.uk Anything I write here are my own views, and cannot be taken as the official words of Maidstone Borough Council -----Original Message----- From: Jon Barnett [mailto:jbarnett@pobox.com] Sent: Wednesday, April 14, 1999 3:37 PM To: 'Peter Mount'; 'pgsql-interfaces@hub.org' Subject: RE: [INTERFACES] JDBC next() method On Wednesday, 14 April 1999 23:18, Peter Mount [SMTP:petermount@it.maidstone.gov.uk] wrote: > This looks ok. > > queryResult is null if there was an error in the query, so you should > check for that. > > However, normal use would have the result parsed within a > while(queryResult.next()) {} loop, so your interpretation is correct. I don't think the query should give an error - as the query is at least syntactically correct. Certainly, if I check for a queryResult == null, the condition doesn't occur for an empty table. I just had a quick browse on some old JDBC notes and it looks like the correct solution is: queryResult = dbStatement.executeQuery("select max(history_id) from history"); queryResult.next(); nextID = queryResult.getLong(1) + 1; if (queryResult.wasNull()) nextID = 0; Note: queryResult.wasNull() only works immediately after calling a getxxx method. Thanks. JonB.
В списке pgsql-interfaces по дате отправления: