• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Displaying SELECT results into swing interface

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am implementing a search interface in eclipse working with mysql. I believe I have the SELECT statement right, but I am unsure of how to display the results of the search on my interface. I am working on the search for the 'city search' currently and haven't finished the select statement for the 'tag search' yet as I don't want to get ahead of myself. Is 'result' used to display the selected values from my database table or something else?

I originally had a JList instead of a JTable to try and display the search results in but switched it. It wasn't working right than either.

 
Sheriff
Posts: 24761
59
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That all looked pretty good to me the first, and second, time I looked through it. You've got a JTable, you fill a TableModel with data from the ResultSet, you make that be the JTable's model -- that's all right and should work.

Then the third time I scanned the code:



Yup, that looks more or less right. There could be some details you got wrong there which I didn't recognize but then I don't write this code every day.



And then you throw that table model away and replace it with another one? Don't do that.

By the way it's clear that you weren't happy about the output of your code. It would help in future if you describe what you saw and how it differs from what you expected.
 
Taylor Manley
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the output to be displayed in the Jtable, but I don't get any output at all. So the lack of output comes from creating a different .getModel?
 
Paul Clapham
Sheriff
Posts: 24761
59
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessarily. It might be that your query doesn't return any rows. But I'd fix the known error first.

I'm assuming that you see an empty JTable in your GUI? You haven't said what you do see yet.
 
Taylor Manley
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when I run the program, my gui pops up and the JTable is empty. If I enter something for the "?" parameter and hit the "search city" button, I get no response from the program. I do have at least row that wold fill the parameter, but I get no return output into the JTable and it remains empty.
 
Taylor Manley
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe I got it to work. I'm now receiving an output in the Jtable. Thank you for all your help.

One more question, is there a way to have the SELECT statement search for semantics or partial words or does it only search for verbatim results?

My current code for the database part is


 
Paul Clapham
Sheriff
Posts: 24761
59
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good work! Glad to hear it's working.

Taylor Manley wrote:One more question, is there a way to have the SELECT statement search for semantics or partial words or does it only search for verbatim results?



Yes, I'm sure you can do that. I think you'd use the LIKE operator rather than the = operator.
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!