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