count in java

count in java

View Answers

May 27, 2009 at 3:35 PM

Hi Friend,

Try the following code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame
{
JButton ADD;
JPanel panel;
JLabel label1;
final JTextField text1;
Form()
{
label1 = new JLabel();
label1.setText("Gender:");
text1 = new JTextField(20);

ADD=new JButton("Count");
panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);

panel.add(ADD);

add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();

Connection con = null;
String url = "jdbc:mysql://192.168.10.112:3306/";;
String db = "mydata";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
try{
String i="";

Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("SELECT count(id_sales) from userlist where gender='"+value1+"'");
while(rs.next()){
i=rs.getString("count(id_sales)");
System.out.println(i);
JOptionPane.showMessageDialog(null,"Count is: "+i);
}

st.close();

con.close();
}
catch(Exception e){
System.out.println(e);
}
}
});
}
}
class RetrieveCount
{
public static void main(String arg[])
{
try
{
Form frame=new Form();
frame.setSize(300,100);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}
Thanks









Related Tutorials/Questions & Answers:
Count the character in java
Count the character in java  Write a java program to count....   Count characters by implementing thread import java.util.*; class CountCharacters { public static void count(final String str){ Runnable
count in java - Java Beginners
, count of frmale is 20. what's code in java to select count from database where...count in java  Hello javamania.... i want to ask something like... is 20. i have JFrame Form(jTextField,jLabel,jButton), i want to get count
Advertisements
Ask java count
Ask java count  Good morning, I have a case where there are tables... | Java 1 | 10 | | b002 | beginner java | 5 | | b003 | advanced java book | 26 | | b004 | MySQL 1
letter count problem - Java Beginners
letter count problem  i have a problem in my java coding to count two characters of a string. eg to count the letter "ou" in the string "How do you feel today?". The answer should be 5. but i still have error compiling
count asterisk in a grid - Java Beginners
count asterisk in a grid  I need to write a program that uses a recursive method to count the number of asterisk in a square grid
Java program to generate the total count
Java program to generate the total count  I need a java program which would take a text file as an input and scans through it to generate the output. For Ex. : If the text file contains the following information: There is/are 3
Count characters from text file in Java
is a java code that count the occurrence of each character from text file. import...Count characters from text file in Java  At the "Count chracters fro mtext file in Java". I tried to run the code, but the error at the line have
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ... = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM dev.history WHERE previous like 1; "; SQLStr = "SELECT COUNT(PREVIOUS
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ... = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM dev.history WHERE previous like 1; "; SQLStr = "SELECT COUNT(PREVIOUS
Jsp count and java bean - JSP-Servlet
Jsp count and java bean  Please am on a project and i want to create a countdown timer that will have this format HH:MM:SS. Am working with jsp and java beans please somebody help.  Hi Friend, Try the following
Java count vowels
Java count vowels In this section you will learn how to count the number... and then you will get the number of vowels count. Description of code : In this code... will read the string once you enter the string. Then we have taken a count
how to count words in string using java
how to count words in string using java  how to count words in string...: "); String st=input.nextLine(); int count=0...()){ String token=stk.nextToken(); count
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I... for the printCount() method for the code to count the number of occurences of each...]+" "; } str = str.toLowerCase(); int count = -1
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
Java count files in a directory
Java count files in a directory In this section, you will learn how to count... directory. But we have to count the number of files so we have initialized... count = 0; for (File file : f.listFiles()) { if (file.isFile
Java Count Vowels
Java Count Vowels       In this program you will learn how to count vowels in a String. Here you.... Then we have taken a variable- count = 0. Now, we have applied a loop here which
Count Rows - JSP-Servlet
Count Rows  How to count rows in Java. Thanks
Java file line count
Java file line count In the section, you will learn how to count the number of lines from the given file. Description of code: Java has provide various... count = 0; File f = new File("C:/data.txt"); Scanner input = new Scanner(f
count in hibernate .
count in hibernate .  How to implements count in hibernate
Count Active Thread in JAVA
Count Active Thread in JAVA In this tutorial, we are using activeCount() method of thread to count the current active threads. Thread activeCount() : Thread class provides you to check the current active thread by providing
count occourance no of time no between 0 to 9 given by user in java
count occourance no of time no between 0 to 9 given by user in java  import java.io.*; class count_no { public static void main(String args...); }catch(Exception e){} } }   Here is a java
Java Word Count - Word Count Example in Java
Java Word Count - Word Count Example in Java  ... to count the number of lines, number of words and number of characters... some strings and program will count the number of characters and number of words
Java count frequency of words in the string
Java count frequency of words in the string. In this tutorial, you will learn how to count the occurrence of each word in the given string. String...]+" "; } str = str.toLowerCase(); int count = -1; for (int i = 0; i
Count characters from text file in Java
Count characters from text file Using Java Here we are going to count... it into character array in order to count the occurrence of each character...; char ch= third[counter];   int count=0;  
count the users?
count the users?  how to get the number of users logged in any application
Maven dependency for be.bagofwords - count-db version 1.1.11 is released. Learn to use count-db version 1.1.11 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.1.11 ) in their Java project... and includes  be.bagofwords - count-db version 1.1.11 java library in your project...Maven dependency for  be.bagofwords  - Version 1.1.11 of count-db
Maven dependency for be.bagofwords - count-db version 1.1.10 is released. Learn to use count-db version 1.1.10 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.1.10 ) in their Java project... and includes  be.bagofwords - count-db version 1.1.10 java library in your project...Maven dependency for  be.bagofwords  - Version 1.1.10 of count-db
Maven dependency for be.bagofwords - count-db version 1.1.2 is released. Learn to use count-db version 1.1.2 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.1.2 ) in their Java project... in project? Steps to use  be.bagofwords - count-db version 1.1.2 in Java...; be.bagofwords - count-db version 1.1.2 java library in your project. ADS
Maven dependency for be.bagofwords - count-db version 1.1.0 is released. Learn to use count-db version 1.1.0 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.1.0 ) in their Java project... in project? Steps to use  be.bagofwords - count-db version 1.1.0 in Java...; be.bagofwords - count-db version 1.1.0 java library in your project. ADS
Maven dependency for be.bagofwords - count-db version 1.0.2 is released. Learn to use count-db version 1.0.2 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.0.2 ) in their Java project... in project? Steps to use  be.bagofwords - count-db version 1.0.2 in Java...; be.bagofwords - count-db version 1.0.2 java library in your project. ADS
Maven dependency for be.bagofwords - count-db version 1.0.1 is released. Learn to use count-db version 1.0.1 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.0.1 ) in their Java project... in project? Steps to use  be.bagofwords - count-db version 1.0.1 in Java...; be.bagofwords - count-db version 1.0.1 java library in your project. ADS
Maven dependency for be.bagofwords - count-db version 1.0.0 is released. Learn to use count-db version 1.0.0 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.0.0 ) in their Java project... in project? Steps to use  be.bagofwords - count-db version 1.0.0 in Java...; be.bagofwords - count-db version 1.0.0 java library in your project. ADS
Maven dependency for be.bagofwords - count-db version 1.1.12 is released. Learn to use count-db version 1.1.12 in Maven based Java projects
this version ( be.bagofwords - count-db version 1.1.12 ) in their Java project... and includes  be.bagofwords - count-db version 1.1.12 java library in your project...Maven dependency for  be.bagofwords  - Version 1.1.12 of count-db
Java xml count occurrence of elements
Java xml count occurrence of elements Java provides xml parsers to read... parsers for different purposes. Here we will count the number of occurrences...) { tags.put(key, new Integer(1)); } else { int count = ((Integer) value
Count number of "*"
Count number of "*"  I have this code to count the number of * from...:"); String text = bf.readLine(); int count = 0; for (int i = 0; i...); if (c=='*' ) { count
count characters
count characters  i have to print the total number of char 'A' in all... sabah sarawak terengganu the output must be count the total number of char... main(String[] args) { int count=0; Scanner input=new Scanner
Count Vowels
Count Vowels   Read a string from the user, your program counts the number of vowels in the text and have it report a sum of each vowel found as well as the number of spaces. Make it in two classes
Java count characters from file
Java count characters from file In this section, you will learn how to count... into character array in order to count the occurrence of each character...; third.length; counter++) { char ch = third[counter]; int count = 0
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I... No. of found I get XTSM/XTS/TRX/XHAN and now i want count total of this ZHTYPE...); } if (xtsMap.containsKey(rec.getXts())) { Integer count = xtsMap.get
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I... No. of found I get XTSM/XTS/TRX/XHAN and now i want count total of this ZHTYPE...); } if (xtsMap.containsKey(rec.getXts())) { Integer count = xtsMap.get(rec.getXts
Character count by while loop
Character count by while loop  Write the program to count the number...]; int count=0; for ( int i=0; i<third.length; i++){ if (ch==third[i]) count++; } boolean flag=false; for(int j=counter-1;j>=0;j--){ if(ch==third[j
Count Characters from the input string Java
Count Characters from the input string of Java In this section, you will learn how to count the occurrence of each character in the string. For this, we have... to count the occurrence of each character of the array.  Here is the code
count objects php
count objects php  How to Count and show objects in PHP
Java Count word occurrence and export it to excel file
Java Count word occurrence and export it to excel file Here is an example of scanning a text file in a local drive, and count the frequency of each word in the text file or you can say count the number or occurrence of each word
how to count no.of sheets in excel through POI jar as well as through Java?
how to count no.of sheets in excel through POI jar as well as through Java... know the method to count the no.of sheets in excel through POI jar or else java... will be dynamic ) .I want to read all sheets one by one in java by using POI jar. I
Count Row - JSP-Servlet
Count Row  Hello all, Please I need your help on how to desplay... using java servlet and html form. Thanks for your good job!   Hi friend... db = "register"; String driver = "com.mysql.jdbc.Driver"; int count= 0
ModuleNotFoundError: No module named 'the_count'
ModuleNotFoundError: No module named 'the_count'  Hi, My Python... 'the_count' How to remove the ModuleNotFoundError: No module named 'the_count' error? Thanks   Hi, In your python environment you
SQLl query count and group by
SQLl query count and group by  How to write a sql query to count and group by the data?   Sql query to count the data and group the data using group by function... Select Name, Count(Name) As Count From Table Group
Hibernate Criteria Count Example
Hibernate Criteria Count Example  Example of Hibernate Criteria Count. Check the tutorial Hibernate Criteria Count. Check the Latest tutorials, articles and examples of Hibernate Framework. Thanks
php array loop count
php array loop count  Count the array using loop in php

Ads