i have try to develop one java app.here am getting information from mysql database.
my code is:
public class RetailerWs {
public int data(){
int count=0;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
PreparedStatement statement = con.prepareStatement("select * from orders where status='Q' AND MONTH(date) = MONTH(CURDATE()) AND YEAR(date) = YEAR(CURDATE())");
ResultSet result = statement.executeQuery();
while(result.next()) {
// Do something with the row returned.
count++; //if the first col is a count.
}
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return count;
}
}
the other class is :
public class Demo {
public static void main(String[] args){
RetailerWs obj = new RetailerWs();
System.out.println(obj.data());
}
}
Here i have to check the query and display count value is successfully.but my doubt is the query matched item is zero means the output is displayed blankly.but i wish to need it is display 0.not display blank screen..so please help me how is to do.
Create the object of class RetailerWs.