Results 1 to 2 of 2
  1. #1
    shaggymac is offline Member
    Join Date
    Apr 2008
    Rep Power

    Arrow MySQL Database and Java


    I created a Form using SWING. I have 1 Table in the database.

    The table structure is


    The purpose of this application is to "Browse" or view data stored in the database.

    At the moment, I run an SQL query everytime data is needed.

    On my GUI, I have 4 JButtons, 2 JRadioButtons

    and all fields are "Editable" but data can not be saved.

    So the 4 buttons on my screen are

    CLEAR - Clears the contents of all my fields

    SEARCH - uses the filled in fields to perform a Dynamic search on the DB

    (so if user enters first name as JAMES, it will automatically build a SQL String

    NEXT - moves to next record. This runs an SQL Statement

    SELECT * FROM TABLE WHERE id=(current+1)

    PREVIOUS - moves back a record

    SELECT * FROM TABLE WHERE id=(current-1)

    Two JRadioButtons
    The first one is called EXACT. The EXACT one will build the SQL String so it uses the = operator for the where clause (example SELECT * FROM TABLE WHERE FIRSTNAME='JOHN')

    The second one is called PARTIAL. The PARTIAL one will build the SQL String so it uses the LIKE operator for the where clause (example SELECT * FROM TABLE WHERE FIRSTNAME LIKE '*JOHN*')

    Here is the problem and I think it could be many things that may contibute to the problem

    1. When searching for a record, I get the first record. Then when using the NEXT button, it gets the current record + 1. but the next record may not have a sequential id. I may find records with the following id

    1, 45, 90, 103

    Likewise, the previous button doesn't work.

    So the question is how do I figure out what the next record or previous record is when getting data from the DB?

  2. #2
    lonelyShoes is offline Member
    Join Date
    May 2008
    Rep Power


    My first instinct would be to check where/how you are setting the value of 'current' and to check whether it is getting reset after clicking the 'Next' and 'Previous' buttons.

Similar Threads

  1. Replies: 2
    Last Post: 04-17-2008, 05:02 PM
  2. problem in connecting to mysql database
    By nancyv in forum Java Servlet
    Replies: 6
    Last Post: 04-02-2008, 11:33 AM
  3. Replies: 0
    Last Post: 03-29-2008, 04:36 PM
  4. Help needed with updating mysql database
    By SilentCodingOne in forum New To Java
    Replies: 1
    Last Post: 12-11-2007, 11:23 PM
  5. connecting to mysql database
    By javagal in forum NetBeans
    Replies: 2
    Last Post: 08-04-2007, 12:36 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