View Single Post

   
  #2 (permalink)  
Old 04-16-2008, 12:57 AM
Kris Jurka
 
Posts: n/a
Default Re: ResultSet.getInt problem



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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote