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



Home Answers Viewqa Java-Beginners count statement that saves results on a variable in a java bean

Have Programming Question? Ask it here!
 
 
 


thanos
count statement that saves results on a variable in a java bean
0 Answer(s)      3 years and 2 months ago
Posted in : Java Beginners


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 !!


Advertisement
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
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
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
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
Java Bean
Java Bean  What is Java Bean?   I got my answer already here: http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks a lot
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
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
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
java if statement
java if statement  If statement in Java
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
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
Java Bean Properties
Java Bean Properties  What are the properties of a normal java Bean(Not EJB)   HI Friend, Please visit here: http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks
Java Bean - Java Beginners
Java Bean  Sir, How can i add a java bean into a target GUI.... Thanking you Pabitra Kr Debanth.   Hi friend, Java Bean classes must..., it will be a visible Java Bean. Java Beans may also be invisible
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
java bean - EJB
java bean  difference between java bean and enterprice java bean  first of all dont compare java bean with enterprise java bean because enterprise java bean is a techonology where we can develope business logic
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
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
java bean code - EJB
java bean code  simple code for java beans  Hi Friend, Java Beans are reusable components. They are used to separate Business logic from.... Java Bean Code: public class EmployeeBean{ public int id; public
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 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
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
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
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
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
Count Records using the Prepared Statement
Count Records using the Prepared Statement  ...\PreparedStatement>java CountRecords Count records example using prepared... to count all records of the database table by using the PreparedStatement
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
Java callable statement
Java callable statement  What is callable statement? Tell me the way to get the callable statement
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... is one of the data type in java ,identifier is one of the name of the variable
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
Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
database connection by using java bean
database connection by using java bean  i need a code for bean class to connect to mysql database. subsequently to use dis bean class whereever i need 2 connect 2 database
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 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
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
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
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 : The switch statement is used when you want to test many statements based on some
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
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 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
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
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 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
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
Advertisements
 

 

 

DMCA.com