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

4

1 回答 1

1

这个问题在 H2 邮件列表中得到了回答: http ://groups.google.com/group/h2-database/browse_thread/thread/a4105b923d79bf28# 这是 Phani 代码中的一个错误。

于 2011-04-13T08:50:59.023 回答