Results 1 to 6 of 6

Thread: Display output

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    7

    Display output

    My query to display total according to the type of particular product is as below:

    String query = "SELECT COUNT(Type) FROM Sales " +
    "GROUP BY Type DESC" ;

    JOptionPane.showMessageDialog(null,"Sending Query....Please wait");

    ResultSet rs = statement.executeQuery(query);
    display(rs);

    JOptionPane.showMessageDialog(null,"Query Succcessful !!!");
    statement.close();


    Above codes inside try{}.

    Now how can i display it in a particular textArea(displaySales)..??..My display method is as below..:


    public void display(ResultSet rs){


    try{

    rs.next();

    int recordNumber = rs.getInt(1);

    if (recordNumber !=0){

    DisplaySales.append(Integer.parseInt(recordNumber));// DISPLAY PART...BUT GOT ERROR..!!
    rs.next();


    }// if


    else
    JOptionPane.showMessageDialog(null,"Record Not Found !!!");


    }//try




    catch (SQLException sqlex){

    sqlex.printStackTrace();
    System.out.println(sqlex.toString());

    }//catch


    }//display

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Please put the code into [code][/code] tags and remove the unnecessary newlines.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    7
    My query to display total according to the type of particular product is as below:

    Code:
    String query = "SELECT COUNT(Type) FROM Sales " +
    "GROUP BY Type DESC" ;
    
    JOptionPane.showMessageDialog(null,"Sending Query....Please wait"); 
    
    ResultSet rs = statement.executeQuery(query);
    display(rs);
    
    JOptionPane.showMessageDialog(null,"Query Succcessful !!!"); 
    statement.close();
    Above codes inside try{}.

    Now how can i display it in a particular textArea(displaySales)..??..My display method is as below..:

    Code:
    public void display(ResultSet rs){
    
    
    try{
    
    rs.next();
    
    int recordNumber = rs.getInt(1);
    
    if (recordNumber !=0){
    
    DisplaySales.append(Integer.parseInt(recordNumber));// DISPLAY PART...BUT GOT ERROR..!!
    rs.next();
    
    
    }// if
    
    
    else
    JOptionPane.showMessageDialog(null,"Record Not Found !!!"); 
    
    
    }//try
    
    
    
    
    catch (SQLException sqlex){
    
    sqlex.printStackTrace();
    System.out.println(sqlex.toString());
    
    }//catch 
    
    
    }//display

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    parseInt creates an integer from a string. You seem to want a string from an integer. Best way is
    int i = 399;
    String s = Integer.toString(i);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    7
    Now my question is how do i can display the query result in particular text Area..??...for an example:the output should b as follows:

    25
    63
    45
    89

    so that user gets particular type tatal..Is that my query statement correct..??...& how to do the diaply part..??

  6. #6

Posting Permissions

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



Click Here to Expand Forum to Full Width