Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: ResultSet issues

  1. #1
    Member
    Join Date
    Dec 2010
    Posts
    69
    My Mood
    Busy
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default ResultSet issues

    Ok, I have this so far:
                String getCust = "SELECT FirstName, LastName FROM Customer WHERE FirstName = ?";
                PreparedStatement ps = con.prepareStatement(getCust);
                ps.setString(1, "Alexander");
                ResultSet rs = ps.executeQuery();

    I just can't figure out how to get it be able to be stored? I've attempted an ArrayList and failed (maybe did it wrong??) Also, I'm just trying to populate a jTable is what i am shooting for ultimately. Anyone have any advice?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: ResultSet issues

    What do you mean by stored? Often, I will map the results from the ResultSet to a class...as you iterate over each row of the ResultSet, get the values from the ResultSet and create a new class (which you have defined elsewhere), which you can then add to a List.

  3. #3
    Member
    Join Date
    Dec 2010
    Posts
    69
    My Mood
    Busy
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: ResultSet issues

    I basically am trying to figure out how to populate data into my jTable on my frame from my database. I just haven't added a feature to iterate (advanced for loop) through multiple entries. I just don't know how I'd go from pulling the data out and getting it to the jTable?

  4. #4
    Member
    Join Date
    Dec 2010
    Posts
    69
    My Mood
    Busy
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: ResultSet issues

    Nevermind I got it:
                while (rs.next()){
                    String s = rs.getString(1);
     
                }

Similar Threads

  1. Triangle issues
    By FrEaK in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 24th, 2010, 07:49 AM
  2. Having Issues Past this
    By baGoGoodies111 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 12th, 2009, 07:19 PM
  3. Replies: 0
    Last Post: October 2nd, 2009, 10:51 PM
  4. ResultSet is Closed
    By ramayya4u in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 24th, 2009, 03:54 AM