• Post Reply Bookmark Topic Watch Topic
  • New Topic

Traversing records with swing and jdbc  RSS feed

 
Arunkumar Gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm having a mysql database and using jdbc i'm accessing the data from database. I'm countering with some delay in displaying text in the text field. Please help me with what i'm doing.

I'm learning java application development using swing and jdbc and trying to build a student record application. Please help me











 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "I'm countering with some delay in displaying text in the text field" mean, exactly? Maybe it's caused by the DB being slow to respond? Is there a delay after the data has been returned from the DB?

As an aside, the code is retrieving the entire query results every time one of the buttons is clicked, but the query is always the same - you should cache the results in some appropriate data structure, and only retrieve a fresh set of data if the user specifically asks for it.
 
Arunkumar Gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes actually getting data from db and to display it in text field takes more time. how to retrieve a fresh set of data ? I'm a beginner
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes actually getting data from db and to display it in text field takes more time.

Does this mean you have established that the delay occurs because of the DB access? That would be good, because DB access time you can optimize independently of this app.

how to retrieve a fresh set of data ?

You already have the code to get the data. Now it's a matter of rearchitecting your app so that it retrieves the data only once at startup, then stores it locally in some data structure, and displays data out of those data structures instead of directly out of the ResultSet.
 
Arunkumar Gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means i have to store resultset object in arrays ? so that i can use the array to set values in text fields am i correct ?
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your query is getting all records in your table. So, either you should get the data and put it in a list of some sort outside of the button and then when the button is clicked then get the next record from the list. Or, if you do not want to get the entire table of data at once, then you should change your query each time but you would need to know your id or some value to know what the next record it. Some people like to populate a JTable with all the data from the table and then as you move from record to record, then display that records detail in a panel. Then you can make changes in the detail panel. Then you would use a button for a new record. A button for updating a record and a button for removing a record.
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Arunkumar Gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Michelle Streeter. Now it makes sense.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!