Creating a dynamic query by choosing the field and getting the report

Hi,
Is there a way to create a report by allowing the user to choose a field from the table and design a query based on that field.
Ex In a table students with fields
(StudentNo, StudentName,Age,Qualification,Hobbies, PlaceofBirth)
Is it possible to generate a query
select * from students where Hobbies=programming;
where the user can be given the option of selecting the field and the value (Hobbies, programming), the query is generated for that, then the report is designed for that query. How could the query be generated?
Regards,
Reshma

You sure can ;)
Here's an example.
You can create a JComboBox and have the different categories of hobbies in there and then use ActionListener on the JcomboBox.
The code will be something like this
public void actionPerformed(ActionEvent ae)
  if(ae.getSource()==combo)    //assuming the JComboBox object is combo
    String query=new String("");
    String st = combo.getSelectedItem().toString();
    Connection connection=DriverManager.getConnection("jdbc:odbc:DSN","user","password");
    Statement stmt=connection.createStatement();
    String qry="SELECT * FROM tablename WHERE hobby=";
    String query=qry+st;
    ResultSet rs=stmt.execute(query);     //Then do whatever you want with the ResultSet object
}

Similar Messages

  • Can't find instructions for setting a PDF form to allow users to type in the fields and save the form.  Thanks

    Can't find instructions for setting a PDF form to allow users to type in the fields and save the form.  Thanks

    Hi,
    Have a look at this page Acrobat refers to them as "Reader Extended PDF", Adobe Acrobat X Pro * Enable Reader users to save form data
    Regards
    Bruce

  • Compare a column with the another table coulmn(which contains the sequence) and get the value which has higher sequence

    Hi All,
    I have 2 tables 
    table1: col1 sequenceid, col2 code
    table2:col1 studentID , col2 code, col3 joindate
    in table 1 i have values as 
    1 Q
    2 W
    3 E
    4 R
    5 T
    6 Y
    Table2:
    A1 Q 
    1-04-2015
    A1 W
    2-04-2015
    A3 Q 
    1-04-2015
    A2 Q 
    1-04-2015
    A3 W
    2-04-2015
    A2 W
    2-04-2015
    A2  E
    2-04-2015
    A3  E
    2-04-2015
    A1  E
    2-04-2015
    A2  R
    2-04-2015
    Now i want ouput as 
    A3 E
    A2 R
    A1 E
    I want to group the values in table2 based on studentid order by the sequence in the table1 and get the latest which is having higher sequence (Note: the date field cannot be used to order the values)

    from @table2 a inner join @table1 b on a.col2=b.col2 collate database_default)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • I just downloaded a video in HD, but I found out after the download was over my computer doesn't play HD videos. Is there any way I can return the video and get the SD version, or upgrade my computer so it will play the HD video?

    I just downloaded a video in HD, but I found out after the download was over my computer doesn't play HD videos. Is there any way I can return the video and get the SD version, or upgrade my computer so it will play the HD video?

    From http://support.apple.com/kb/HT3209
    When you purchase an HD video on a supported device or computer, only HD video will be downloaded. To download the SD version, you need to download the video again from your Purchased page. Conversely, if you purchase an HD video on an unsupported device, the SD version will be downloaded. Then, you will need to download the HD version from your Purchased page. Learn more about downloading previous purchases.

  • Can I Trade in my Ipod 4, pay the diference and get the ipod 5

    Can I Trade in my Ipod 4, pay the diference and get the ipod 5

    Apple doesn’t do trade-ins and won’t give you more than 10% off a new device for sending an iPod touch in for recycling. If it’s in working order, you’re probably better off selling it to someone else.
    (110183)

  • Express Lane advised that I use the Install Disc to fix a problem.  I inserted the disc, pressed C as advised and restarted, nothing comes up, the computer just goes on and off - any advise on starting the laptop and getting the disc out?

    Stuck in restart mode -- Express Lane advised that I use the Install Disc to fix a problem.  I inserted the disc, pressed C as advised and restarted, nothing comes up, the computer just goes on and off - any advise on starting the laptop and getting the disc out?

    You insert the disk and restart while holding down the 'c' key until you see the apple and spinning cog. Is that precisely what you did?

  • HT201269 i don't know where to tell the iphone that it should look onto the icloud and get the back up from my old device.  This page says I will be prompted but I have not been.  Where should I look?

    i don't know where to tell the iphone that it should look onto the icloud and get the back up from my old device.  This page says I will be prompted but I have not been.  Where should I look?

    Settins > General > Reset and then Erase all content and settings. Then during setup assistant click restore from icloud backup

  • Highlighting TEXT - not the field - and clearing the set value for a new one

    I have a form in which various text fields are set with a message to inform the user as to what kind of information I want typed in. My goals are:
    1. Have the text get highlighted so when the user starts typing, the "old" value gets replaced with the "new"
    2. Or, when the user tabs or clicks in the field all of the "old" value is deleted and they can start typing the "new" value from the beginning of the field.
    I am trying to eliminate having to manually highlight the field in order to type in the needed information. But each field needs to start with a value so the user knows what kind of information I am looking for.
    Does this make sense? By the way, I have no JavaScript experience...uh oh!

    Use the Media Manager (under the File menu bar item).
    Link:
    What Can You Do with the Media Manager?

  • My computer will not start up. It powers up I get the gray screen with the apple and get the loading progress bar it loads to 25% and the screen goes black

    My computer will not start up. It powers up, I get the gray screen with the apple, then the loading progress bar starts loading to about 25% the the screen goes black. what can I try to get my computer up and running?

    Carolyn Samit wrote:
    iMac, Mac OS X (10.7.1)
    Use Command + R for Lion Recovery
    Try restarting, when you hear the startup tone hold down the Option key. Then choose the Recovery Partition.

  • How to Check the date and get the latest date?

    Hi Everyone,
    I've an internal table which holding few records which contain date field. How I can check this internal table by getting the record which contain "latest date" only? Kindly advise. Thank you.
    eg:
    I should only get the record which contain lastest date. (eg: I should picked up Record3)
    Table i_test
    Field 1              Field 2(date)
    Record1            20090322
    Record2            20090101
    Record3            20090601
    Moderator message - Please search before asking and do not ask basic questions - post locked
    Edited by: Rob Burbank on Jun 17, 2009 9:21 AM

    Its easy...sort the internal table using the field i.e. date field in DESCENDING manner
    SORT gt_final BY date_field DESCENDING.
    Read the first entry of the internal table..it will have what you require
    READ gt_final INDEX 1.

  • I open the ipad and get the icloud symbol. it says ignore or settings. no matter what i hit nothing happens.  HELP

    I am having problems with my new ipad.  when I open it I get the icloud backup symbol. it says ignor or settings.  But no matter what button I hit ---its frozen. nothing happens and I cannot get out of this. I cannot open it to anything???  HELP

    Try a Reset [Hold the Home and Sleep/Wake buttons down together for 10 seconds or so (until the Apple logo appears) and then release. When the screen goes blank then power ON again in the normal way.] It is 'appsolutely' safe!

  • HT1430 dueing the  update ios7 7.0.2 ipad can not open. They show the message is correct the itunes. I back the house and correct the itunes and get the recover the ipad but unsucessful. now the ipad is unavaible to start. pls help

    dueing the update IOS 7 7.0.2, ipad show the message is contact the itunes, when I back the house, ipad contact the PC and itunes for recovery the ipad but unsuccessful. Now ipad is not start.please help

    I hope this helps. If I understood your question properly, it is the same or similar problem many, including myself, had with the IOS7 update. I'll relay my situation & what I did to rectify it.  I have the iPad2 & MACBook Pro. I have an iPhone 5 but won't be updating it.
    IF YOU HAVEN'T YET UPDATED YOUR iPAD TO IOS 7... DON'T. NOT UNTIL YOU'RE CERTAIN YOU HAVE BACKED UP YOUR iPAD, AT LEAST. BE ABSOLUTELY CERTAIN YOU HAVE BACKED UP YOUR DEVICE.
    FIRST: BACK UP YOUR IPAD, & ALL YOUR DEVICES.
    NEXT: CHECK FOR UPDATES ON ALL DEVICES.
    I updated my iPad while away from my main wifi connection because using my main wifi for the last update subsequently interfered with my connection thereafter. New problem now.
    1.) Once I updated (was it successful/unsuccessful?) Because...
    My iPad showed a large apple with a line underneath; then it illustrated & said, "connect to iTunes." i can't accessa thing. (Huh? Doesn't Apple know people TRAVEL FAR away from their MAC with their iPads? I WAS RUDELY LEFT WITH AN INOP DEVICE on the road.)
    2.) On my MAC: I checked for all updates, & ensured my iTunes was updated.
    3.) I followed thre following instructions from a website (http://www.digitaltrends.com/mobile/ios-7-problems/) I found when researching this common problem. iPhone... iPad... same instructions...
    ...connect to iTunes and try DFU (Device Firmware Upgrade) mode.
    Potential solution:
    Hold down the Sleep/Wake button to turn your iPhone off.
    Open iTunes on your computer and connect your iPhone.
    Hold down the Sleep/Wake button and the Home button together for ten seconds, and then release the Sleep/Wake button.
    Continue to hold down the Home button until you see a pop-up on iTunes stating that “iTunes has detected an iPhone in recovery mode. You must restore this iPhone before it can be used with iTunes.”
    Your iPhone screen should be blank, if you see a logo or message on it then you are not in DFU (Device Firmware Upgrade) mode.
    Select your iPhone in the left hand column of iTunes and select Summary then Restore.
    You may need to install the iOS 7 update again.
    ------------------ THIS WORKED.
    I followed the instruction & so far so good. DO NOT DISCONNECT YOUR iPAD! It will continue to prompt you through SEVERAL items, including the re-installation of one of your previous back-ups. It appears the back-up was successful & that everything is now back to normal.
    Except that now I'm stuck with the juvenile appearance of this new IOS. My Notepad no longer looks like a notepad. Why don't I just type on DOS? My APPLE easthetice have disappeared. If I can, I will revert to IOS 6.
    Read more: http://www.digitaltrends.com/mobile/ios-7-problems/#ixzz2g7Y2neAU
    Follow us: @digitaltrends on Twitter | digitaltrendsftw on Facebook

  • How do I close programs in IOS7.  The old way with double tapping the button and getting the red X does not work.  Even rebooting the phone does not work.

    How do I close programs with IOS 7?  The old way of closing programs by double tapping on the button, holding down an icon until it started shaking and a red X appears does not work.  Every program I opened appears.  Turning on and off the phone does nopt work.

    I just found out.  Above the icon is a copy of the open page of the program(s).  You slide the pages up to close.

  • Can anyone recommend a good "How To" Book. I have switched to a MacBook pro 15 inch. and I woiuld really like to learn the basics and get the most out of my Mac.

    I want to be able to get the most out of my MacBook pro. Any suggestions on a good book to read?

    Switching to a Mac For Dummies, 2nd Edition

  • HT1848 when i go to the file and get the devices, i am unable to sync or transfer purchases or anything in that column. It appears white and not the usual black writing. What is the problem ?

    I am unable to sync and transfer purchased items to my computer as i am unable to open the the transfer tab (it is white instead of the usaul black writing). What is the problem ? (The itunes is authorised for my computer.)

    If this is a new computer you need to authorise it.  In itunes click on STORE and hten authorise this computer.
    After this if you cannot find your phone read these articles
    Phone not recognised in itunes
    device not recognised by iTunes on PC  or  device not recognised by iTunes on Mac

Maybe you are looking for

  • CX_SY_FILE_OPEN_MODE - short dump on production but not in Dev and Test

    Hello, I'm getting the follwoing short dump in production when I run the program which writes the data to application server. I have open data set and close data set. Same program when I in development and test I do not get any short dump. Can any kn

  • Downloaded latest version of Itunes and now it wont open

    I was running Itunes this morning when I was prompted to update to the new version, I went along with it and now when I try to open Itunes the computer loads for a moment, and then the program fails to launch. w.t.f.? help!

  • Is it ok to set "auto shrink" ON for reportserver and reportserverTempDB database?

    Is it ok to set "auto shrink" ON for the reportserver and reportserverTempDB databases? I have read multiple 'best practice' advice articles to not se 'auto shrink' to true, and I understand the potential issue with index fragmentation, but I perciev

  • FGI2 Printing

    Hi, i created a report using transaction FGI2 I have many column in my report for a total of 180 caracters width When i run FGI2 i see all the column, but when i print the reports, the report show only the first 132 caracters. The print is missing so

  • Sanity or similar app for BB Q10?

    Hello, I am new to this community and don't even have my BB yet [hopefully in a few days] but I am already looking for apps and reading manuals and so on. On my Android device [yes, I am switching  ] I have an app called Sanity which helps me when I