• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database to jsp

 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m getting the below data from db table, and i m not able to figure out how to get the first 2 columns data into jsp. The first column values are duplicates and i need to maintain the insertion order .. any help


'July', 1, 'helpdesk'
'June', 1, 'helpdesk'
'July', 1, 'profile'
'June', 1, 'profile'
'August', 2, 'schedule interview'
'July', 2, 'schedule interview'
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you written so far, or are you just completely stuck?


and i need to maintain the insertion order

You should never rely on the insertion order of a database since this may change. Instead defind an extra field (you could call it creation data) and sort your records on that.


The first column values are duplicates

Do you not have a primary key? If you want to group the same values together SQL has a group by clause that can do it.

 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way i can pass the first 2 column values to the jsp. I m using group by in order to get those 'helpdesk', 'profile' , 'schedule interview' values, and right now I need to display only the month and count for each month in jsp.

Do i have to use seperate sql stmts for 'helpdesk', 'profile' , 'schedule interview'

thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there any way i can pass the first 2 column values to the jsp. I m using group by in order to get those 'helpdesk', 'profile' , 'schedule interview' values, and right now I need to display only the month and count for each month in jsp.

Yes. Have a read of this. It should get you going.


Do i have to use seperate sql stmts for 'helpdesk', 'profile' , 'schedule interview'

No.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the "distinct" keyword for the duplicates.

Also, when you say "database to JSP", I hope you mean Java class. Having JDBC code directly in a JSP is poor practice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic