0

I am using below code,i have checked pathname and sheet name is all fine. I am using fillo version fillo-1.15.

public class T_Test {
    public static void main(String[] args) throws Exception{
        try {
            com.codoid.products.fillo.Fillo fil_res = new com.codoid.products.fillo.Fillo();
            com.codoid.products.fillo.Connection con_res = fil_res
                    .getConnection("C:\\Users\\admin\\workspace\\Good Connect\\Test_Data/Result\\LifePlanner_Result.xlsx");
            String sql_res = "update Result_Data SET Product_ID = 'Sampoorna Raksha' Where TestCase_ID = 'TC1_SIS' ";
            System.out.println(sql_res);
            com.codoid.products.fillo.Recordset recordset_rec = con_res.executeQuery(sql_res);
            con_res.close();
        } catch (Exception e) {
            System.out.println("Exception result set:" + e.toString());
        }
    }
}

Error is below:

java.lang.NullPointerException Exception result set:java.lang.NullPointerException at com.codoid.products.parser.SelectQueryParser.isWherePresent(SelectQueryParser.java:66) at com.codoid.products.fillo.Select.getRecordset(Select.java:47) at com.codoid.products.fillo.Connection.executeQuery(Connection.java:56) at GoodSolutionAgence.T_Test.main(T_Test.java:89)

James Z
  • 12,209
  • 10
  • 24
  • 44
Varun.S
  • 39
  • 2
  • 11
  • The exception is occurring in code that you haven't shown us. So we can't help you. But that's OK because the linked Q&A has **comprehensive** help on how to diagnose and fix NPEs for yourself. – Stephen C Mar 30 '18 at 08:13
  • @StephenC: Sorry, but the exception is occurring in a third-party library for which I don't believe the source code is unavailable. Closing this question as a dupe of the canonical NPE question is therefore unhelpful as the asker is unable to debug this library. As far as I can see, the problem regards deficient error handling in this library and I have an answer for it, therefore I have reopened this question. – Luke Woodward Mar 30 '18 at 08:47

2 Answers2

0

I believe the error is here:

       com.codoid.products.fillo.Recordset recordset_rec = con_res.executeQuery(sql_res);

You are executing an UPDATE statement, not a SELECT query. An UPDATE statement won't return a record set, just the number of rows it updated. You therefore want to use executeUpdate in place of executeQuery:

       int numberOfRowsUpdated = con_res.executeUpdate(sql_res);

However, the Fillo library could at least have warned you that you were using the wrong method. The fact that it threw a NullPointerException is in my opinion a bug in this library: it should handle this error condition better.

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
-1

Null Pointer Exception occurs when you try to reference a variable that has not been initialized

 com.codoid.products.fillo.Connection con_res = fil_res
                    .getConnection("C:\\Users\\admin\\workspace\\Good Connect\\Test_Data/Result\\LifePlanner_Result.xlsx");

In this case the con_res might be null since getConnection method is not functioning properly.

Now when you try to execute

con_res.executeQuery(sql_res);

It results in Null Pointer Exception.

Check whether con_res gets initialized properly and check the path specified in getConnection method

Anoop saju
  • 480
  • 3
  • 17