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




Have Programming Question? Ask it here!
 
 
 


Emmanuel Aigbovbiosa
Sum
1 Answer(s)      6 years and 5 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

May 1, 2008 at 7:04 PM


Hi friend,

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

public class SumRowExample 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 amount= 0;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT SUM(amount) FROM information");
while(res.next()){
amount = res.getInt(1);
}
out.println("Total amount:" + amount);
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
}
}


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


<servlet>
<servlet-name>sumrow</servlet-name>
<servlet-class>SumRowExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sumrow</servlet-name>
<url-pattern>/SumRowExample</url-pattern>
</servlet-mapping>

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

read for more information,

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


Related Tutorials/Questions & Answers:
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
sum
; sum=sum+s; if(i==n){ System.out.print(s...+"+"); } System.out.print("\nSum of the series : "+sum
Advertisements
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
sum of the series
sum of the series  Program to sum the series 1+1/1!+1/2!+1/3!+....n
Sum of seris
Sum of seris  Program to find the sum of the following series using a function declaration. sum=x-(xxx)/3!+(xxxxx)/5!-(xxxxxxx)/7!+.....(xx....x)/n!. Where n and x are entered from the keyboard
Sum of integers
Sum of integers  A Java program that reads an integer value from the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input
sum
sum
sum
sum
sum
sum
sum
sum
sum and average of grades
sum and average of grades  how to print a program which is sum and average of Korean (90), English(85), Mathematics(78), Biology(65), Chemistry(83
Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class...=input.nextInt(); long sum=0; for(int i=1;i<=n;i++){ sum+=i
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average...(); int num = Integer.parseInt(data); int sum = 0; float avg = 0.0f; for (int i = 1; i <= num; i++) { sum = sum + i
calculate sum of individual digit
calculate sum of individual digit   How calculate product of first and last digit of indiviual numbers Like a=43278 4*8=32
Sum - JSP-Servlet
the total sum of items from database using Java servlet or Jsp and html form. It should display the affected rows and the total sum of all in a seperate column..., Sum Into Database Salary
sum of fibonacci series
sum of fibonacci series  Write a Java program to print Fibonacci series upto n and find their sum also. 0+1+1+2+3+5+8+13+21â?¦â?¦â?¦â?¦=sum   Hi, Please see the thread Fibonacci program. Thanks
Sum of positive and negative numbers
Sum of positive and negative numbers  Hi if someone could help... the sum of all the positive integers and the sum of all the negative integers.  ...]; } } System.out.println("Sum of positive numbers: "+sum2); System.out.println
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any...(employee); } } } Output: Hibernate: select sum
sum database column
sum database column  please i have two columns-col1 and col2, col1... 3 Soap 4 how will i query the database to sum the Items... for you. select item, sum(quqantity) from `order` group by item
Hibernate criteria sum.
Hibernate criteria  sum. Here, we will introduce you to about the sum() function . It returns the sum of total value of column. Syntax : Criteria... message as shown below: Hibernate: select sum(this_.fee
calculate sum of individual digit
calculate sum of individual digit  Hi How to calculate product of first snd last digit of indiviual digit Like Num=23456 S=2*6
Sum database colum in java
Sum database colum in java  please i have two columns-col1 and col2... the database to sum the Items and display output so that it will be like... question what you have asked. select item, sum(quqantity) from `order` group
Sum - JSP-Servlet
Sum  Hi Guys, thank you all for support for us all. Please I want to sum up from a particular row from the database, get all the rows affected... = con.createStatement(); ResultSet res = st.executeQuery("SELECT SUM(amount) FROM
SQL Aggregate Sum
SQL Aggregate Sum       The SQL Aggregate Sum Function is a part of Aggregate Function that is used to compute sum of the numeric field in a table. Understand with Example
sum and avg function using HQL.
sum and avg function using HQL.  How to use sum and avg function in HQL?   HQL supports many aggregate functions. Sum and avg are some of them. sum() function returns summation of specified field in the table
Java Sum of Digits
Java Sum of Digits In this Java Tutorial section, you will learn how to find the sum of multidigit number. For this purpose, we have allowed the user to enter.... Following code calculates the sum of digits: while (n > 0) { int p
sum of all values in a column of jtable
sum of all values in a column of jtable  hey everyone, is there a code to display the sum of all values in a column of a jtable namely CARTtbl in a jabel without using a button,and the sum will change when an item is added
SQL Aggregate Sum
SQL Aggregate Sum       The SQL Aggregate Sum Function is a part of Aggregate Function that is used to compute sum of the numeric field in a table. Understand
How to calculate sum of HH:MM:SS Format?
How to calculate sum of HH:MM:SS Format?  how to calculate sum of HH:MM:SS? for example: 10:25:36+26:50:56 calculate sum of these values
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Find Sum of Diagonals of Matrix
Find Sum of Diagonals of Matrix You all know that a matrix is a rectangular... elements. Here we are going to find the sum of Primary diagonal (From left top... diagonal. Here is the code: import java.io.*; public class Sum_Diagonal
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26
Sum of diagonal of Matrix in C
C Sum of diagonal of Matrix In this section, you will learn how to determine the sum of both the diagonal of 3X3 matrix. For this, we have declared an array of integers and using the for loops, we have determined the sum of both
pie chart flex and sum from hql request
pie chart flex and sum from hql request  hi, i work with flex... d.intituleDeleg,SUM(s.usagePedag ),ROUND((((SUM(s.usagePedag ))/(SUM(s.ordidispo)))*100),0), SUM(s.ordidispo) from Statistiqueordinateur s,Delegation d,Etablissement e
Find sum of series
Find sum of series This section illustrates you how to find the sum of n terms... function that takes the parameter 'n' up to which the sum of the series... sum(int n) { if (n == 1) return 1.0; return sum(n - 1) + 1.0 / n
Find sum of the squares of Array elements
Find sum of the squares of Array elements In this section, you will learn how to compute the sum of the squares of the array elements. For this, we have.... The elements of this array is then added and stored into the variable 'sum
Calculating Sum of two Multidim
Sum of Multidimensional Arrays   ... that will calculate the sum of the matrix. To make this program run we need.... After getting both the matrix with us we need to sum both the matrix. The both
JPA Sum Function
JPA Sum Function       In this section, you will learn about sum function of aggregate function of JPQL (Java Persistence Query Language). The sum function to calculate the sum
Sum of Column in a Database Table
Sum of Column in a Database Table       This section describes how we can calculate the sum... university where we need to calculate the sum of  numbers achieved
how to print all possible combination that sum to zero??
how to print all possible combination that sum to zero??  ?...? (for subtraction) between each of the digits so that the resultant sum is zero. Print all possible combinations that sum to zero Example Enter a num : 7 1
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java... the console. Now here is the simple example which will help you to find the sum of odd
Sum of array element in C
() { void read(int *,int); void display(int *,int); int a[5],i,sum=0; clrscr...;5;i++) { sum+=a[i]; } printf("The sum of the elements of the array is %d\n",sum); getch(); } void read(int c[],int i
Hibernate Projection Example (Sum)
Hibernate Projection Example (Sum)     ... function like: sum() using hibernate projection.  The following example to calculate the sum of invested_amount to the Insurance table  Table Name
Sum of a Number using Swing
Sum of a Number using Swing       In this section, you will learn how to sum of a number using swing...;); Step: Create a file "Calculate.java" to sum of a number using
Sum of two Matrix
Sum of  two Matrix       In this section, we are going to calculate the sum of two matrix... to this. In this program we are going to calculate the sum of two matrix. To make this program
Calculate the Sum of three Numbers
Calculate the Sum of Three Numbers       This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three
 

 

 

DMCA.com