Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2008, 10:50 PM
Member
 
Join Date: Apr 2008
Posts: 1
shaggymac is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 05-01-2008, 11:01 PM
Member
 
Join Date: May 2008
Posts: 6
lonelyShoes is on a distinguished road
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
Sponsored Links
Reply


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

vB 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 07:02 PM
problem in connecting to mysql database nancyv Java Servlet 6 04-02-2008 01:33 PM
Problem with jTable that is binded with a table in MySQL Database rajkenneth NetBeans 0 03-29-2008 05:36 PM
Help needed with updating mysql database SilentCodingOne New To Java 1 12-12-2007 12:23 AM
connecting to mysql database javagal NetBeans 2 08-04-2007 02:36 PM


All times are GMT +3. The time now is 12:50 PM.


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