Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Emmanuel Aigbovbiosa
Count Row
1 Answer(s)      6 years and 9 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

April 28, 2008 at 6:49 PM


Hi friend,

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class CountRowExample extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
int count= 0;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT COUNT(*) FROM regiform");
while (res.next()){
count = res.getInt(1);
}
out.println("Number of column:" +count);

}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

}
}

-----------------------------------------

<servlet>
<servlet-name>countrow</servlet-name>
<servlet-class>CountRowExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>countrow</servlet-name>
<url-pattern>/CountRowExample</url-pattern>
</servlet-mapping

---------------------------------------

read for more information

http://www.roseindia.net/servlets/



Related Tutorials/Questions & Answers:
Count Row - JSP-Servlet
Count Row  Hello all, Please I need your help on how to desplay the number of row(s) affected along with the affected row(s) in mssql database 2000... db = "register"; String driver = "com.mysql.jdbc.Driver"; int count= 0
Table maximum Row count - JDBC
Table maximum Row count  Dear friends I want to select maximum time entry Status from db. for example : Status : 3 4 6 8 3 5 7 5 5 7 5 3 4 5 2 5 1 my output will be 5 means 5 is maximum time
Advertisements
Column count doesn't match value count at row 1
Column count doesn't match value count at row 1  Column count doesn't match value count at row 1 UPDATE user_profile SET id=[value-1],user_id=[value-2],full_name=[value-3],mobile_phone=[value-4],hide_email_id=[value-5],hide
JDBC Get Row Count
JDBC Get Row Count       The JDBC Get Row Count enables you to return the row count of a query. JDBC Get Row... in JDBC Get Row Count. The code help you to understand how to count the number
java.sql.SQLException: Column count doesn't match value count at row 1 - JSP-Servlet
java.sql.SQLException: Column count doesn't match value count at row 1 ... of : java.sql.SQLException: Column count doesn't match value count at row 1 I checked the No. of column in table and values in row are same. I don't know whats
how to make seperate view count for each row while clicking view button
how to make seperate view count for each row while clicking view button  I am getting problem with view count when i click view button the seperate count should be happen for each row here is my code ** Tabledata.jsp <
Hibernate Criteria Count Distinct
Hibernate Criteria Count Distinct The Hibernate Criteria count distinct is used to count the number of distinct records in a table. Following a way to use... this application it will display message as shown below: select count(distinct
count in hibernate .
count in hibernate .  How to implements count in hibernate
count the users?
count the users?  how to get the number of users logged in any application
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
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
delete row
delete row  how to delete row using checkbox and button in php...("sourabh", $link); $rows=mysql_query("select * from sonu"); $row=mysql...;/tr> <?php while($row=mysql_fetch_array($rows)) { ?> <tr>
Count Rows - JSP-Servlet
Count Rows  How to count rows in Java. Thanks
count objects php
count objects php  How to Count and show objects in PHP
uitableview manually delete row
uitableview manually delete row  uitableview manually delete row   NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; [array removeObjectAtIndex:indexPath.row]; if(![array count]) [indexes addIndex
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
MySQL Count
MySQL Count       This example illustrates how to use count() in MySQL database. Count(): The Count.... It returns a numeric value. If you use COUNT(*) that counts the number of rows.  
retain count in Objective C
retain count in Objective C  what is the retain count in Objective C?   retainCount in Objective c retainCount: retain count method is used to show the internal count of the given object so that programmer can easily
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 distinct value in HQL.
Count distinct value in HQL.  How do you count distinct value in HQL?   count(distinct fieldName) returns number of distinct value... = sessionFactory.openSession(); String countHql = "Select count(distinct salary
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
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
didSelectRowAtIndexPath deselect row
didSelectRowAtIndexPath deselect row  Hi, In my UITableView application when user taps a row, how to deselect row? Thanks
insert and delete a row programmatically
insert and delete a row programmatically  How to insert and delete a row programmatically ? (new feature in JDBC 2.0
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria in hibernate?   We can get the rows count using the Projections. My code is like this: Criteria criteria = session.createCriteria(getReferenceClass
Sql row retrieve - SQL
Sql row retrieve  Sir What are the sql statements so that I can retrieve rows from a table by specifying the row numbers such as row no.5 to 10, row no.13 to 20 like that. thanks Pabitra kr debanth. Guwahati. 
Advertisements
 

 

 

DMCA.com