count statement that saves results on a variable in a java bean

count statement that saves results on a variable in a java bean

Hello i want to ask you where is the problem and my programme give me only null returns ---> package javalab;

import java.sql.*;

public class History {





    private int w ;
    private int v ;
    private int c ;

    public History() {}

    public String findPrevious(){
        Connection conn = null;
        Statement statement = null;
        String SQLStr ;
        String retString = "";
        ResultSet nu =  null;


        SQLStr = "SELECT COUNT(*) AS COS  FROM dev.history WHERE previous like 1; ";
        SQLStr = "SELECT COUNT(PREVIOUS) AS VOD FROM dev.history WHERE PREVIOUS like 2; ";
        SQLStr = "SELECT COUNT(PREVIOUS) AS WIN FROM dev.history WHERE PREVIOUS like 3 ;";


        try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();

            conn = DriverManager.getConnection("jdbc:mysql://"+
                    "localhost:3306/dev","root","anime");



            statement = conn.createStatement();
            nu = statement.executeQuery(SQLStr);

            if (nu.next())
                c = nu.getInt("COUNT(previous)");
                v = nu.getInt("VOD"); 
                w = nu.getInt("WIN");

        }catch (SQLException sqlEx){
            System.err.println(sqlEx.getMessage());
        }catch (ClassNotFoundException classNotFound){
            System.err.println(classNotFound.getMessage());
        }catch (Exception ex){
            System.err.println(ex.getMessage());
        }finally {
            try
                {if (statement != null){
                    statement.close();
                }
            }catch(final SQLException sqlEx){
                System.err.println(sqlEx.getMessage());
            }
        }
        return retString;
    }

        public int Wind(){
            return w;
        }

        public int Vodafone(){
            return v;
        }
        public int Cosmote(){
            return c;
        }

} thx a lot in advance !!

View Answers









Related Tutorials/Questions & Answers:
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ...; Statement statement = null; String SQLStr ; String retString = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM
count statement that saves results on a variable in a java bean
count statement that saves results on a variable in a java bean  ...; Statement statement = null; String SQLStr ; String retString = ""; ResultSet nu = null; SQLStr = "SELECT COUNT(*) AS COS FROM
Advertisements
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
How to extract the values of a variable in a href statement. - Java Beginners
How to extract the values of a variable in a href statement.  Hi, Here im trying to send invitations to some selected people.It is working when i...: SENDINVITE Now here i want to put a variable containing multiple e-mail ids
Assigning a value to JSP variable from a bean class. - JSP-Servlet
Assigning a value to JSP variable from a bean class.  Hi, I want to know how we can assign value to a JSP variable from a Java Bean. I am using Struts, JSTL. Which tags should I use to assign the value. e.g Kindly
Java variable
Java variable   To what value is a variable of the String type automatically initialized
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
java if statement
java if statement  If statement in Java
Assign value from a <bean:write> tag to a variable
Assign value from a tag to a variable  I am calling a stored procedure from JSP page which needs an input parameter. This input parameter needs to get the value from bean write tag . How can i do that ?   Please go
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
Hibernate DetachedCriteria mutiple results in java
Hibernate DetachedCriteria mutiple results in java  This is the SQL statement that I have. SELECT FIRSTNAME, LASTNAME, USERTYPE FROM USERPROFILE INNER JOIN USERLOGINSTATUS ON USERPROFILE.USERID=USERLOGINSTATUS.USERID ORDER
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
Java File Handling Test Results
Java File Handling Test Results   Is somebody able to help me with this Write a program to read each name from the file and prompt the user to enter the percentage for that student at the keyboard. I need to input
Java Bean
Java Bean  How to run java bean program in Netbeans
Java Bean
Java Bean  What is a Java Bean?   A Java Bean is a software component that has been designed to be reusable in a variety of different environments
What is instance variable in Java?
What is instance variable in Java?  Hi, What is instance variable in Java? What is the use of instance variable? Thanks   Hi, In Java programming classes are used as base of Object oriented programming. Any variable
Count Records using the Prepared Statement
Count Records using the Prepared Statement  ... C:\vinod\jdbc\jdbc\PreparedStatement>java CountRecords Count... to count all records of the database table by using the PreparedStatement
Java Final Variable
Java Final Variable  I have some confusion --Final variable has single copy for each object so can we access final variable through class name,or it is necessary to create object for accessing final variable
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
if else statement in java
if else statement in java  if else statement in java explain with example
Ask java count
Ask java count  Good morning, I have a case where there are tables... the results: for example: | code book | name of book | sum | | b001 | Java 1 | 10 | | b002 | beginner java | 5
if else statement in java
if else statement in java  explain about simple if else statement and complex if else statement in java with an example
Java Bean
Java Bean  What is Java Bean?   I got my answer already here: http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks a lot
ModuleNotFoundError: No module named 'saves'
ModuleNotFoundError: No module named 'saves'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'saves' How to remove the ModuleNotFoundError: No module named 'saves'
Store Variable in Java
Store Variable in Java  How to store Variables in Java?   public class DoubleTest { public static void main(String[] args) { double...(aDouble); // Outputs 7.21 } }   Variable in Java
array variable in a java program
array variable in a java program  How do i write a program that will prompt the user for a list of 5 prices, that cosist of the sum of all the prices, the average of the prices, and all prices that are higher than the calculated
Java callable statement
Java callable statement  What is callable statement? Tell me the way to get the callable statement
JAVA statement - Java Beginners
JAVA statement  The import statement is always the first noncomment statement in a Java program file.Is it true?  Hi Friend, No,it is not true.If your class belongs to a package, the package statement should
Instance variable in java
Instance variable in java In this section you will learn about Instance variable in java. In java all variable must be declared before they are used... kind of variable in java, they are as follows : Local variable Instance
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
Switch Statement in java 7
Switch Statement in java 7 This tutorial describes the if statement in java 7. This is one kind of decision making statement. Switch Statements... will execute its statement that is it will assign Sunday to String variable 'days
conditional statement in java
conditional statement in java  Write a conditional statement in Java   Logical and comparison statements in OOPs are also know as conditional statements. You can learn "How to write conditional statement in Java " from
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 switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
GOTO Statement in java
GOTO Statement in java  I have tried many time to use java goto statement but it never works i search from youtube google but e the example on net are also give compile error. if possible please give me some code with example
Java error unreachable statement
Java error unreachable statement   ... a code that help you in understanding a unreachable statement. For this we... a for loop that has a variable integer I.;. The System.out.println is used to display
How to define a constant variable in Java?
How to define a constant variable in Java?   Hi, How to define a constant variable in Java? thanks   HI, The Constants variables... once its declared. For more related to constant variable in java Thanks
Referance variable - Java Interview Questions
Referance variable  by using which reference variable we declare instance variable as local variable in java   Hi friend,Local variables... variable and parameter. When the method is called, the parameter slots are initialized
Static variable in java
Static variable in java. Static is a keyword in java used to create static methods, variable inside a class and static class. Static variable is also called class variable which belongs to class not to object. Static
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
java Transient variable - Java Beginners
java Transient variable  Hi, What is the use of transient variables in java?  Hi friend, The transient is a keyword defined in the java programming language. Keywords are basically reserved words which have
Bean
Bean  what is bean? how to use bean   HTML Code...        JDBC code: <%@ page language="java" import ="java.sql.*" %> <...=DriverManager.getConnection(jdbc:odbc:data,"",""); Statement st=con.CreateStatement("SELECT * FROM
Use if statement with LOOP statement
Statement include  a declare keyword that define the variable and its data... Use if statement with LOOP statement   ... if statement with LOOP statement. In this example we create a procedure display
If statement in java 7
If statement in java 7 This tutorial describes the if statement in java 7. This is one kind of decision making statement. There are various way to use if statement with else - If Statement :ADS_TO_REPLACE_1  If statement
Java IF statement problem
Java IF statement problem  Dear Sir/Madam i am using the following code. expected to not have any output but it still showing "welcome".. please help me why it showing "welcome". class c1 { int a=5; while(a>1
Java struts variable valu - Struts
Java struts variable valu  Hii.. can u suggest me how to declare a variable in my jsp page and then fetching its value in the action class.. my requirement is to execute a block of code depending on the value of the variable
ELSE STATEMENT!! - Java Beginners
ELSE STATEMENT!!  Hi! I just want to know why doesn't my else statement works? Else statement is there in the code below which is: else JOptionPane.showMessageDialog(null, n+ " is not in the array!");//doesn't work
Java Bean Properties
Java Bean Properties  What are the properties of a normal java Bean(Not EJB)   HI Friend, Please visit here:ADS_TO_REPLACE_1 http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks
JAVA BEAN WITH ORACLE FORMS
JAVA BEAN WITH ORACLE FORMS  Hi..I am doing my final year Project.. I need the ste-by-step procedure to integrate a bean with oracle forms? Please help me
Use DECLARE Statement in Procedure
Use DECLARE Statement in Procedure       Use DECLARE Statement in Procedure is used to define variable and its data type. Understand with ExampleADS

Ads