Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default JDBC PreparedStatement

    I have to retrive the details of purchase bill and the database design is bill number is primary key and foreign key for bill items and each item in bill maintains other charges independently
    how to write a prepare statement so that retrieve one row in purchase bill
    multiple rows of item in a bill and other charges for each item

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    there is a good tutorial about database connectivity that covers also prepared statements here in this forum. click it ...

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default

    Probably three queries.
    One to get the bill.
    One to get the bill items for that bill.
    One to get the charges for each bill item.

    That'll result in multiple hits on the db, which may or may not be a problem, that's for you to determine.

    These can be squeezed together, getting the bill data and the items in one go, then all the charges in a second go, but that can look messy (you'd be getting multiple copies of the bill data for example, and you'd need some logic to extract the correct set of charges for a particular item).

    If your system is already modular, that is you have a BillDao, a BillItemDao and a BillItemChargesDao, then the former is the neater solution, albeit with more db traffic.

Similar Threads

  1. Replies: 10
    Last Post: 12-22-2009, 12:09 PM
  2. Regarding PreparedStatement
    By adeeb in forum JDBC
    Replies: 0
    Last Post: 06-09-2008, 10:07 PM
  3. Replies: 0
    Last Post: 04-01-2008, 11:17 AM
  4. Using PreparedStatement
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-22-2007, 12:24 PM
  5. Replies: 0
    Last Post: 09-28-2007, 01:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •