This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Who can help me resolve this big problem?

Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a table named channel in my database(sqlServer2000). It�s data structure as follow:
The letter c refers to channel.

Channel_is_father:If this column has children, it is inserted 1, otherwise 0.
Column1 is the top column, so it�s channel_father_id is set 0. However the column 3 is the second layer column. Its father is 102 named column2, and so on.
Ok. I want to get the data by the layer structure from database and to display on the web.
For example:

I wrote java codes to realize this function ,but failed. I don�t know why.
My codes:

Output as fellow:
Not Father101
Not Father113
Not Father109

The method channelIsFather is used to verify the column whether or not is father column.if so it return 1 ,but 0;
The method getChannelId is used to retrieve the channelID.If the channel_id is the father column, which will recall the the method itself again till the condition turned false.
Thank u very very much!
[ April 03, 2003: Message edited by: frank yang ]
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've not followed in detail what is happening, but you can't possibly expect recursion to work with all those instance variables. Get rid of them! Turn them into method-local variables and things might work a whole lot better. Don't declare all of them at the start of the method -- choose the smallest possible scope for each.
If this is simply one-off testing code, then please disregard the following; otherwise, consider these points: Take care to close() statements and connections in finally clauses. Don't catch and absorb Exception. Try to use the proper data types when retrieving JDBC data: returnID should be an int. If you're querying on the primary key, express that in your code: use if ( than while ( Use PreparedStatement for oft-repeated queries like these. Not only is it more efficient, it can also save you data representation headaches (escaping quotes and other special characters in Strings, formatting date and time, that kind of thing).
- Peter
Hey cool! They got a blimp! But I have a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic