aspose file tools*
The moose likes JDBC and the fly likes retrive data from db2 as month and year wise    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "retrive data from db2 as month and year wise    " Watch "retrive data from db2 as month and year wise    " New topic
Author

retrive data from db2 as month and year wise

saswat rashmi
Greenhorn

Joined: Jul 31, 2007
Posts: 14
hi everyone and good morning

i have problem ,
in my jsp page there is option for month and year .in the month drop down list of month it coming and in year drop down list of year it s coming .

now i have to get the data from db2 based on selection of month and year .but in db2 the data is stored as int he form of YYYY/MM/DD

i dont how to write the code for this in jsp .please help .please some example how to write the code for this
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Saswat,
If you have a date/calendar object, you can call get(Calendar.MONTH) and get(Calendar.YEAR) to get these fields. If your value is stored in a date/time field in db2, you can use resultSet.getDate() to get a Date object right away.

If it really is stored as a char/varchar in the format "YYYY/MM/DD", you will need to call SimpleDateFormat to create a date first.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

I should also mention that it is considered poor practice to have code - especially JDBC code - in a JSP. Better to put it in a Java class or servlet. This makes the code easier to debug and maintain.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrive data from db2 as month and year wise