0

I am new to H2 database, I ran into a particular problem where I was running a function named format.

public static String format(Double sumValue,Integer decimalValue){
 if(sumValue==null)
   return null;
 else{
      //format in particular order.
      }
}

There are chances of sumValue getting null value.

when I am running a query it is throwing a following exception

SELECT format(commamount,2) as formatted FROM pshipcommdetail [90105-153] 
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:327) 
    at org.h2.message.DbException.get(DbException.java:156) 
    at org.h2.message.DbException.convertInvocation(DbException.java:295) 
    at org.h2.engine.FunctionAlias$JavaMethod.getValue(FunctionAlias.java:405) 
    at org.h2.expression.JavaFunction.getValue(JavaFunction.java:38) 
    at org.h2.expression.Alias.getValue(Alias.java:35) 
    at org.h2.command.dml.Select.queryFlat(Select.java:519) 
    at org.h2.command.dml.Select.queryWithoutCache(Select.java:614) 
    at org.h2.command.dml.Query.query(Query.java:269) 
    at org.h2.command.dml.Query.query(Query.java:239) 
    at org.h2.command.dml.Query.query(Query.java:37) 
    at org.h2.command.CommandContainer.query(CommandContainer.java:78) 
    at org.h2.command.Command.executeQuery(Command.java:181) 
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:278) 
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:137) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NullPointerException 
    at reports.functions.Format.format(Format.java:15) 
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.h2.engine.FunctionAlias$JavaMethod.getValue(FunctionAlias.java:393) 

I went through the documentation and was able to figure out that the aruguments should be of wrapper class hence I changed to double!

Can anyone of you please help me to figure out where the actual problem is?

Thanking you

With Regards Phani Kumar

1 Answer 1

1

This question was answered on the H2 mailing list: http://groups.google.com/group/h2-database/browse_thread/thread/a4105b923d79bf28# It was a bug in Phani's code.

Sign up to request clarification or add additional context in comments.

1 Comment

Has it been fixed though?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.