Hi,
I'm not sure, but I guess it's a JVM / classpath problem. Which JVM do you
use?
The database tries to compile the class using the class
"com.sun.tools.javac.Main" if available (which means the H2 jar file is
most likely in the classpath). If it is not available, then it will try
using a new process, "javac -sourcepath ... ", in which case the H2 jar
file most likely isn't available. I guess it should use
javax.tools.JavaCompiler if available...
Of could you could use the "old style" user defined function, in which case
the user defined function needs to be in the classpath of the database
engine:
create alias findUser for "com.acme.udf.FindUser"
Regards,
Thomas
On Monday, June 25, 2012, steve.ebersole wrote:
> Thanks for the reply Noel. That's too bad. Oh well I'll figure something
> out.
>
> Relatedly, I am running into a problem trying to get this working. I have
> the following:
>
> return "CREATE ALIAS findUser AS $$\n" +
> "ResultSet findUser() {\n" +
> " org.h2.tools.SimpleResultSet rs = new
> org.h2.tools.SimpleResultSet();\n" +
> " rs.addColumn(\"ID\", Types.INTEGER,
> 10, 0);\n" +
> " rs.addColumn(\"NAME\", Types.VARCHAR,
> 255, 0);\n" +
> " rs.addRow(1, \"Steve\");\n" +
> " return rs;\n" +
> "} $$";
>
> But this keeps giving me the error:
>
> 08:57:37,103 ERROR SchemaExport:425 - HHH000389: Unsuccessful: CREATE
> ALIAS findUser AS $$
> ResultSet findUser() {
> org.h2.tools.SimpleResultSet rs = new org.h2.tools.SimpleResultSet();
> rs.addColumn("ID", Types.INTEGER, 10, 0);
> rs.addColumn("NAME", Types.VARCHAR, 255, 0);
> rs.addRow(1, "Steve");
> return rs;
> } $$
> 08:57:37,105 ERROR SchemaExport:426 - Syntax error in SQL statement
> "/org/h2/dynamic/FINDUSER.java:9: package org.h2.tools does not exist
> org.h2.tools.SimpleResultSet rs = new org.h2.tools.SimpleResultSet();
> ^
> /org/h2/dynamic/FINDUSER.java:9: package org.h2.tools does not exist
> org.h2.tools.SimpleResultSet rs = new org.h2.tools.SimpleResultSet();
>
> I verified that the version of H2 I am using (1.2.145) does in fact have
> this class. Any idea what is going on there? That snippet is taken almost
> verbatim from the user guide. I tried both with the import and then FQN
> references.
>
> On Monday, June 25, 2012 8:48:26 AM UTC-5, Noel Grandin wrote:
>>
>> H2 does not implement in/out parameters, you'd either need to
>> (a) pass some kind of carrier object into the method that could be
>> updated,
>> (b) return your data in a carrier object
>> (c) return your data in a result set
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/H5srCLpDQFYJ.
> To post to this group, send email to
> [email protected]<javascript:_e({}, 'cvml',
> '[email protected]');>
> .
> To unsubscribe from this group, send email to
> [email protected] <javascript:_e({}, 'cvml',
> 'h2-database%[email protected]');>.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.