Re: ResultSet.getInt problem

From: Kris Jurka <books(at)ejurka(dot)com>
To: "Tomás A(dot) Rossi" <tomas(at)mecon(dot)gov(dot)ar>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: ResultSet.getInt problem
Date: 2006-02-17 18:39:35
Message-ID: Pine.BSO.4.63.0602171336040.20250@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2006-02-17 18:50:35 Re: PGConnectionPoolDataSource is not a DataSource?
Previous Message Kris Jurka 2006-02-17 18:33:47 Re: setString and timestamps