Re: ResultSet.getInt problem

Поиск
Список
Период
Сортировка
От Tomás A. Rossi
Тема Re: ResultSet.getInt problem
Дата
Msg-id 43F6269E.7090001@mecon.gov.ar
обсуждение исходный текст
Ответ на Re: ResultSet.getInt problem  (Kris Jurka <books@ejurka.com>)
Ответы Re: ResultSet.getInt problem
Список pgsql-jdbc
Kris Jurka escribió:

>
>
> On Fri, 17 Feb 2006, "Tomás A. Rossi" wrote:
>
>> ResultSet rs= con.select(query);
>> while (rs.next()) {
>>   id= rs.getInt("id");
>>   out.println(id); // prints 0 in every row!!
>>   name= rs.getString("name"); // ok
>>   ...
>>
>> Now if I change getInt("id") for the other overload getInt(1), it
>> works fine!
>> (it prints the correct id for every column)
>>
>
> I'm not sure what's going wrong here.  What do you get if you add some
> additional debugging code along the lines of the following:
>
> ResultSetMetaData rsmd = rs.getMetaData();
> for (int i=1; i<=rsmd.getColumnCount(); i++) {
>     System.out.println("["+rsmd.getColumnName()+"]");
> }
>
> Kris Jurka

The query formed is:

"SELECT * FROM sso.organismos o LEFT OUTER JOIN motivos_bloqueos m ON(
o.id_motivo_ultimo_bloqueo=m.id) WHERE no(o.baja_fisica) AND nombre ~*
'a' AND activo ORDER BY nombre"

The table is:

CREATE TABLE sso.organismos
(
  id serial NOT NULL,
  nombre text NOT NULL,
  dominio text NOT NULL,
  activo bool NOT NULL DEFAULT 't',
  fecha_ultima_baja timestamp,
  bloqueado bool NOT NULL DEFAULT 'f',
  cant_bloqueos_heredados int4,
  fecha_ultimo_bloqueo timestamp,
  detalle_ultimo_bloqueo text,
  id_motivo_ultimo_bloqueo int4,
  baja_fisica bool,
  descripcion text,
  CONSTRAINT organismos_pkey PRIMARY KEY (id),
  CONSTRAINT "$1" FOREIGN KEY (id_motivo_ultimo_bloqueo)
      REFERENCES sso.motivos_bloqueos (id)
      ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
  CONSTRAINT organismos_nombre_key UNIQUE (nombre)
)

Your debug code printed:
"[id] [nombre] [dominio] [activo] [fecha_ultima_baja] [bloqueado]
[cant_bloqueos_heredados] [fecha_ultimo_bloqueo]
[detalle_ultimo_bloqueo] [id_motivo_ultimo_bloqueo] [baja_fisica]
[descripcion] [id] [motivo] [baja_fisica]"

Seems that two columns has the same name (id) or something like that?
How to workaround this?
This didn't happen when using postgres 7.3 with driver 7.3.

Thank you very much,
Tom;

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: PGConnectionPoolDataSource is not a DataSource?
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: ResultSet.getInt problem