-
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
-
Please put the code into [code][/code] tags and remove the unnecessary newlines.
-
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
-
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);
-
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..??
-
Why don't you try using a JTable to present the data? It would look very professional.