I upload the images like that when i click then input button then i collect the all outputs from inputs? i also submit the code.i have been tired but i cant aolve the problem please if u can send better code or change my code.Help me as soon as possible!

import java.io.*;
import java.sql.*;

public class SumColumn{
  public static void main(String[] args) {
    System.out.println("Sum of the specific column!");
    Connection con = null;
    int sum = 0;
    String col_name;
    try{
      Class.forName("com.mysql.jdbc.Driver");
      con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/jdbctutorial","root","root");
      try{
        Statement st = con.createStatement();
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter table name:");
        String table = bf.readLine();
        System.out.println("Enter column name which have to sum:");
        String col = bf.readLine();
        ResultSet res = st.executeQuery("SELECT SUM"+"("+col+")"+" FROM "+table);
        while (res.next()){
          int c = res.getInt(1);
          sum = sum+c;
        }
        System.out.println("Sum of column = "+sum);
      }
      catch (SQLException s){
        System.out.println("SQL statement is not executed!");
      }
    }
    catch (Exception e){
      e.printStackTrace();
    }
  }
}

Can u tell me the exception of this program.

After than i can help u..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.