Results 1 to 8 of 8

Thread: List problem

  1. #1
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Posts
    32
    Rep Power
    0

    Default List problem

    I am using LIST to display table names,
    now after i got the names i want to select the item(table name) in the List and use it as
    table name after "FROM" clause but it doesnt seem to be working ,it does not print anything im trying to print

    any help please:
    below is my code
    planlockarea1 is a List name.
    --------------------------------------------------------------------
    if(e.getItemSelectable()==planlockarea1){
    item =planlockarea1.getSelectedItem();
    // String tab=item.trim();


    try {
    String lock = "select HOST_NAME, PROD_CODE FROM "+item ;

    statement = connection.createStatement();
    ResultSet rs = statement.executeQuery(lock);
    while (rs.next()) {

    String hnam = rs.getString("HOST_NAME");
    String prdctcode= rs.getString("PROD_CODE");


    System.out.println("where is locks");
    System.out.println(hnam);
    }
    } catch (SQLException ex) {
    Logger.getLogger(freeUserUI.class.getName()).log(L evel.SEVERE, null, ex);
    }

    }

    }
    --------------------------------------------------------------------------

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    Two thoughts:
    Does rs.next() ever return true? Add a println() outside the while() to show its initial value.
    Does the Logger ever write out anything?

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    765
    Rep Power
    6

    Default

    Like Norm told println.

    Anotrher suggestion for all these dynamic value assignment use PreparedStatement.
    Ramya:cool:

  4. #4
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Posts
    32
    Rep Power
    0

    Default

    The initial value is giving null ,Logger prints nothing but i do manage to get the table name printed if i try to print it out.

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

    Default

    What's giving null?
    Have you tried running the query against the db directly?

  6. #6
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Posts
    32
    Rep Power
    0

    Default

    {solved:)}

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

    Default

    Quote Originally Posted by Bulelakes View Post
    {solved:)}
    It would be nice for the other readers to know what your solution is ...

    kind regards,

    Jos

  8. #8
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Posts
    32
    Rep Power
    0

Similar Threads

  1. list sorting problem.
    By bit_bit in forum Advanced Java
    Replies: 2
    Last Post: 02-26-2010, 04:17 AM
  2. assignment problem with List<T>
    By Newbie666 in forum New To Java
    Replies: 11
    Last Post: 01-21-2010, 12:12 PM
  3. problem with implementing list
    By timkd127 in forum New To Java
    Replies: 3
    Last Post: 04-13-2009, 03:54 AM
  4. Array List problem
    By kurenai in forum New To Java
    Replies: 2
    Last Post: 06-25-2008, 07:30 AM
  5. list problem
    By fareez in forum New To Java
    Replies: 3
    Last Post: 06-28-2007, 10:26 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
  •