Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

You create a new instance of PagingBeanProcessor in your selectAll-Method. That’s why the countQuery is null and no data is selected.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading