Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2008, 09:50 PM
Member
 
Join Date: Apr 2008
Posts: 1
Rep Power: 0
shaggymac is on a distinguished road
Arrow MySQL Database and Java
Hello

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

The table structure is

id
FirstName
LastName
MiddleInitial
StreetAddress
City
State
Zip
Comments

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
SELECT * FROM TABLE WHERE FIRSTNAME = 'JAMES')

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?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-01-2008, 10:01 PM
Member
 
Join Date: May 2008
Posts: 6
Rep Power: 0
lonelyShoes is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java program that transfers stock prices to MySQL database naipulb New To Java 2 04-17-2008 06:02 PM
problem in connecting to mysql database nancyv Java Servlet 6 04-02-2008 12:33 PM
Problem with jTable that is binded with a table in MySQL Database rajkenneth NetBeans 0 03-29-2008 04:36 PM
Help needed with updating mysql database SilentCodingOne New To Java 1 12-11-2007 11:23 PM
connecting to mysql database javagal NetBeans 2 08-04-2007 01:36 PM


All times are GMT +2. The time now is 03:39 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org