Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Flight Table Column Indexing

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find there is no way to tell which column is airport origin and destination unless it is by means of hardcoding the index like 1 and 2 in the following coding. This also happens to the seat column. Is there anyway I can obtain the value of index 1 and 2 without hardcoding.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shure. just code a method
int getColumnIndex(String colName)...
into your TableModel.
But then you no longer have integer constants hardcoded but String constants. So this does not really help.
But since this is done on the client only, I think it's OK.
I think you have always fixed references somewhere in your code, even if it's just a simple SQL statement.

Rainer
 
R Bischof
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooops, I just found a
public int findColumn(String columnName)
in the Abstract TableModel.
HTH
Rainer
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, the string constant is also a means of hardcoding, but in a more meaningful way. I am gonna to set the index 1 and 2 to a constant.
 
A tiny monkey bit me and I got tiny ads:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic