|
-
Jul 21st, 2003, 03:53 AM
#1
Thread Starter
New Member
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
-
Jul 21st, 2003, 04:21 AM
#2
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.
-
Jul 21st, 2003, 05:16 AM
#3
Thread Starter
New Member
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
-
Jul 21st, 2003, 05:32 AM
#4
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.
-
Jul 21st, 2003, 06:27 AM
#5
Thread Starter
New Member
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..??
-
Jul 23rd, 2003, 01:34 PM
#6
Dazed Member
Why don't you try using a JTable to present the data? It would look very professional.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|