Results 1 to 3 of 3
  1. #1
    wiz6 is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default where to put the result of query?

    I have 2 classes and 2 tables:
    table1 "item_attribute_type":
    item_type;
    name;
    level;
    super_type_fk;

    table2 "type_attribute"
    type_attribute;
    item_type_fk;
    item_attribute_type_fk;
    orderby;
    required;

    classes are:
    ItemAttributeType and TypeAttribute
    Fields are same like in tables with getter and setter methods.

    My sql query(item_type_fk 10 comes from request parameter):
    Java Code:
    SELECT IAT.type_name,TA.item_attribute_type_fk,TA.required,TA.orderby,IAT.data_type FROM
    			 type_attribute TA INNER JOIN item_attribute_type IAT
    			 ON TA.item_attribute_type_fk = IAT.item_attribute_type WHERE TA.item_type_fk=10 AND
    			 TA.created_by_default='Y'
    Now i have method which must return the array of the query. First problem is what return type i have to use?
    Java Code:
    public "which class type" getData(){
    while(RS.next()){
     //Second problem: where to put the data from table(ItemAttributeType() or ItemAttributeType())
    
    }
    return ?
    }
    I hope you understand my problem :)

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: where to put the result of query?

    Hi,
    code a class "ResultObject" that has these members: IAT.type_name,TA.item_attribute_type_fk,TA.require d,TA.orderby,IAT.data_type
    Let getData() return a List<ResultObject>. in your while loop you create ResultObject instances and add them to the List.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    wiz6 is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: where to put the result of query?

    I thought the same. Thanks.

Similar Threads

  1. Using jTable to display query result
    By zenith666 in forum New To Java
    Replies: 2
    Last Post: 01-13-2012, 03:29 AM
  2. Replies: 1
    Last Post: 04-11-2011, 02:39 AM
  3. column result query
    By vikashkumar in forum JDBC
    Replies: 0
    Last Post: 04-03-2009, 03:23 PM
  4. Help!! how to turn query result to string
    By stefanybaez in forum Advanced Java
    Replies: 2
    Last Post: 12-11-2008, 12:42 PM
  5. Export query result, procces is to slow
    By Daniel in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 06-28-2007, 07:35 PM

Posting Permissions

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