This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying data resulting from a query select statment  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am just wondering if anyone have any suggestions for me:
Right now, I am working on connecting to the DB and to display the data. It should be pretty straight forward using JDBC. However, I have a problem with displaying the data. I am pulling out the price for 5 consecutive days for each ID. So, the way the data displays on the DB is 5 seperate rows with one ID. The way I want to do it is 5 days price on one row, next to each other with the corresponding ID.
Any suggestions on how to do this will be greatly appreciated!
thanks much,
shirley
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be this will help...
For each row read, check the ID, if it is the same as the previous row's ID, write it on the same line using print. Else, write it on the next line using println.

Bosun
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shirley,
You'll have to do this via code. You can't get the JDBC to return you 1 row if the database really contains 5 rows to hold the information.
-Peter
 
Shirley Li
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Bosun,
Thanks very much!! i'll try that.
shirley
 
Shirley Li
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, peter

Originally posted by Peter Tran:
Shirley,
You'll have to do this via code. You can't get the JDBC to return you 1 row if the database really contains 5 rows to hold the information.
-Peter


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!