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

 
 


thanos
count statement that saves results on a variable in a java bean
0 Answer(s)      a year and 11 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 !!

View Answers









Related Pages:
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
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
bean object
bean object  i have to retrieve data from the database and want to store in a variable using rs.getString and that variable i have to use in dropdown... java.util.*; public class Bean { public List dataList(){ ArrayList list=new
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
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
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
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
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
Use if statement with LOOP statement
Use if statement with LOOP statement   ... with Example The Tutorial illustrate a example from if statement with LOOP statement. In this example we create a procedure display that accept
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
Bean
/UseBean.shtml http://www.roseindia.net/tutorial/java/jsp/usebean-setproperty.html
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
Count Row - JSP-Servlet
Count Row  Hello all, Please I need your help on how to desplay... using java servlet and html form. Thanks for your good job!   Hi friend... db = "register"; String driver = "com.mysql.jdbc.Driver"; int count= 0
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria... create Persistent class ?Hibernate uses the Plain Old Java Object (POJO) classes... correctly the max results and such run the alias criteria on its own in the same
The Switch statement
of a variable or expression. The switch statement in Java is the best way to test.... To avoid this we can use Switch statements in Java. The switch statement is used.... Here is the general form of switch statement: switch (expression){ case 1
Using Bean Counter in JSP
;b> The current count for the counter bean is: </b> <... Using Bean Counter in JSP       In this section you will learn how the counter bean can be used
Java Count Vowels
Java Count Vowels       In this program you will learn how to count vowels in a String. Here you... a variable- count = 0. Now, we have applied a loop here which will go up
if Statement - Overview
Java Notesif Statement - Overview Purpose The purpose of the if statement... is a statement? A statement is a part of a Java program. We have already... directly after the condition in an if statement, Java thinks it's finished
JDBC Select Count example
: F:\jdbc>javac SelectCount.java F:\jdbc>java SelectCount COUNT...JDBC Select Count example In this tutorial  we will learn how work COUNT()  in query with mysql JDBC driver. This tutorial  COUNT(*) 
'while' Statement
Java Notes'while' Statement Purpose - to repeat statements The purpose of the while statement is to repeat a group of Java statements many times. It's written just like an if statement, except that it uses
jsp and bean problem
jsp and bean problem  Hi i have the following jsp code... Can you plz help me in separating the code to bean? I'm new to bean and need it for my...; ResultSet rs1=null; Statement statement=null; // Load JBBC driver
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
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
Java variable
Java variable   To what value is a variable of the String type automatically initialized
Local Variable and Instant Variable
they compile fine. But in the case of local variable in Java, local variable in Java do...Local Variable and Instant Variable  difference between Local Variable and Instant Variable   Difference between local variable
Java Word Count - Word Count Example in Java
Java Word Count - Word Count Example in Java  ... to count the number of lines, number of words and number of characters... some strings and program will count the number of characters and number of words
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
Continue and break statement
statement in java program?   The continue statement restart the current loop whereas the break statement causes the control outside the loop. Here is an example of break and continue statement. Example - public class ContinueBreak
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
java if statement
java if statement  If statement in Java
Local Variable ,Package & import
Local Variable ,Package & import A local variable has a local scope.Such a variable is accessible only from the function or block in which it is declared. Example of Local variable : The class variable are declared in the class
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
JSP bean get property
; is used to instantiates a java bean component.  An attempt is made... JSP bean get property   ... bean get property. In this example we define a package bean include a class
Java Import Statement Cleanup - Java Tutorials
Java Import Statement Cleanup 2002-06-18 The Java Specialists' Newsletter [Issue 051] - Java Import Statement Cleanup Author: Dr. Cay S. Horstmann... to receive training in Design Patterns. Java Import Statement Cleanup
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 Rows - JSP-Servlet
Count Rows  How to count rows in Java. Thanks
Java Switch Statement
Java Switch Statement       In java, switch is one of the control statement which turns the normal flow.... break The break statement results in, passes the control to the statement after
environment variable
environment variable  what is environment variable in java?   Environment variables are used by the Operating System to pass configuration information to applications
Static Variable
Static Variable  What is the basic use of introducing static variable type in java?Please explain clearly....   The Static means that a certain object/variable is resident in memory and accessed each time an instance
Use if statement with LOOP statement
Use if statement with LOOP statement   ... with Example The Tutorial illustrate a example from if statement with LOOP statement. In this example we create a procedure display that accept
For Loop Statement in java 7
For Loop Statement in java 7 In this section, we will discuss about for loop in java 7. This is one type of  loop statement. For Loop Statements... to the variable. It is done at the beginning of your for loop. We take
How to get the output of JSP program using Bean
count for the counter bean is: </b> <%=counter.getCoun() %></td>... created in Java and compiled <%@ page language="java" import="beans" %>...;HTML> <HEAD><TITLE>Use Bean Counter Example</TITLE> <
JDBC Prepared Statement Insert
JDBC Prepared Statement Insert   ... Statement Insert. In this Tutorial  the code describe the include a class... that enables you to communicate between front end application in java and database
How to get the output of jsp program using Bean
i created in Java and compiled <%@ page language="java" import="beans" %> <HTML> <HEAD> <TITLE>Use Bean Counter Example <BODY> The current count for the counter bean is: <%=counter.getCoun() %>
Stateful Session Bean Example
Java interface that defines all the business methods implemented in the bean... removes the bean from the environment and saves it to secondary storage... Stateful Session Bean Example   
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 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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.