October 22, 2024
Chicago 12, Melborne City, USA
java

Not able to run very simple method


I am trying to set SQLQuery and trying to get its result via bean but unable to fix it. Here is my code:

public static int countTotalNumberOfRecords(String countQuery) throws SQLException {
        CountQueryDAO db = new CountQueryDAO();
        PagingBeanProcessor bean = new PagingBeanProcessor();
        bean.setCountQuery(countQuery);
        bean = db.selectAll();
        int totalRecords = bean.getTotalRecords();
    return totalRecords;
    }

This is how I am calling this method Paging.countTotalNumberOfRecords(countQuery); and here is my DAO class code that always get query from this method as null:

public PagingBeanProcessor selectAll() throws SQLException {
PagingBeanProcessor bean = new PagingBeanProcessor();
String countQuery = bean.getCountQuery();
            System.out.println("country dao-->"+countQuery);

Here is what I am seeing on console:

country dao-->null
commons.utils.paging.CountQueryDAO

java.sql.SQLException: SQL statement to execute cannot be empty or null

Why I am getting null? why my countTotalNumberOfRecords method is passing to DAO as null? or why my PagingBeanProcessor is not setting or getting parameters

Thanks in anticipation



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video