Use Java functions with Apache Derby -
i've encountered problems using functions in apache derby, in can't derby find self-defined functions. typical error message looks this:
the class 'de.uniba.kinf.projm.hylleblomst.database.sql.utils.groupconcat' not exist or inaccessible. can happen if class not public.
the documentation states method must public , static. want use:
package de.uniba.kinf.projm.hylleblomst.database.sql.utils; public final class groupconcat { public static string groupconcat(string separator, string... arguments) { stringbuilder result = new stringbuilder(""); (string arg : arguments) { result.append(arg + separator + " "); } result.delete(result.length() - 2, result.length()); return result.tostring(); } }
basically want add groupconcat functionality database not provided in derby standard. statement use add function db this:
create function sql_util.group_concat ( separator char, args varchar(255) ... ) returns varchar(2000) parameter style derby no sql language java external name 'de.uniba.kinf.projm.hylleblomst.database.sql.utils.groupconcat.groupconcat'
i've packed groupconcat class in jar , added classpath derby should able find , added database directly. here's did: .jar lies in lib-folder of project, part of build path (i'm using eclipse). entry in classpath-file of project looks this:
<classpathentry kind="lib" path="lib/groupconcat.jar"/>
and measure , desperation i've added system's classpath:
. ; ..;%derby_home%\lib\derby.jar;%derby_home%\lib\derbytools.jar;c:\users\workspace\kinf-workspace\general\lib
my error trivial, i'm quite new derby , databases in general, i'd appreciate help.
thanks in advance!
the problem turned out more specific eclipse , in nature trivial. although jar containing java-class in classpath, eclipse did not add jar run configurations. apparently, classpath passed on derby there , of course can't find class. there packing class containing method in question jar, adding project's library, add run configuration's classpath , run it.
lessons learned: never trust ide (all of) work.
Comments
Post a Comment