Results 1 to 6 of 6

Thread: JList and mysql

  1. #1
    gedas is offline Member
    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    0

    Default JList and mysql

    hey,

    is there a way of dynamically adding data from MySql database to a jlist?
    any code snippets or tutorials of how this could be done would be greatly appreciated

    thank you

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by gedas View Post
    is there a way of dynamically adding data from MySql database to a jlist?
    any code snippets or tutorials of how this could be done would be greatly appreciated
    It's a two step process:

    1) you submit your query and get a ResultSet back;
    2) you populate your JList given the values in the ResultSet.

    Set 2) usually is a while loop until you've fetched all the values you want from the Resultset. There is no magic fillMyJListFromADatabase( ... ) method.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    gedas is offline Member
    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    0

    Default

    thanks i just thought their might be such a method lol

    anyway i have sorted the problem
    thanks

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    As part of 2 in Jos's list, you will be turning each row into an object of some class you have defined in your model that represents that returned data.

    That will be what your List consists of.
    So you'll return a List<MyClass>.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    So you'll return a List<MyClass>
    Um, the question was about a badly capitalized JList

    db

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    Oh....bugger.
    I need my eyes testing!


    ...again.

    Anyway. My point still stands. You would still return a List<MyClass>, and not a JList, since the GUI and db access should not be munged into the same bit of code.

    So there...:p

Similar Threads

  1. Link one JList to another JList
    By mib1bee in forum AWT / Swing
    Replies: 1
    Last Post: 12-31-2010, 07:10 PM
  2. Link one JList to another JList
    By mib1bee in forum Advanced Java
    Replies: 1
    Last Post: 12-30-2010, 06:35 PM
  3. Link one JList to another JList
    By mib1bee in forum New To Java
    Replies: 1
    Last Post: 12-30-2010, 06:24 PM
  4. How to use a JList?
    By glhansen in forum New To Java
    Replies: 3
    Last Post: 03-24-2009, 10:27 AM
  5. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •