Thanx for the answer Thomas, but I have already used Exceptions in H2
and as you said It worked.
The problem is: if I use just exceptions with one of my java
functions:

For example:
select st_Geomfromtext ('POINTT (10 20)');

This function throws an exception with this messages: "Unknown
geometry type: POINTT"

The problem is that for the user is really difficult to find the
message "Unknown geometry type: POINTT" among all the exception
messages, as you can see in the code below. Thats because H2 writes
his exception messages before mine. I though about sending a message
to the user without using exceptions (as postgres can do with raise
notice). If there is any other way I can write my exception message at
the top of the messages please let me know.

Thanx a lot,
Jose


select st_Geomfromtext ('POINTT (10 20)');
Exception calling user-defined function; SQL statement:
select st_Geomfromtext ('POINTT (10 20)') [90105-118] 90105/90105
(Help)
org.h2.jdbc.JdbcSQLException: Exception calling user-defined function;
SQL statement:
select st_Geomfromtext ('POINTT (10 20)') [90105-118]
    at org.h2.message.Message.getSQLException(Message.java:105)
    at org.h2.message.Message.convert(Message.java:270)
    at org.h2.engine.FunctionAlias$JavaMethod.getValue
(FunctionAlias.java:306)
    at org.h2.expression.JavaFunction.getValue(JavaFunction.java:38)
    at org.h2.expression.JavaFunction.optimize(JavaFunction.java:59)
    at org.h2.command.dml.Select.prepare(Select.java:716)
    at org.h2.command.Parser.prepareCommand(Parser.java:235)
    at org.h2.engine.Session.prepareLocal(Session.java:415)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:227)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:138)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.h2.engine.FunctionAlias$JavaMethod.getValue
(FunctionAlias.java:299)
    ... 8 more
Caused by: org.cartosig.jaspa.io.ParseException: Unknown geometry
type: POINTT
    at org.cartosig.jaspa.io.WKTReader.readGeometryTaggedText
(WKTReader.java:648)
    at org.cartosig.jaspa.io.WKTReader.read(WKTReader.java:284)
    at org.cartosig.jaspa.io.WKTReader.read(WKTReader.java:248)
    at org.cartosig.jaspa.Core.getJTSGeometryFromEWKTorWKT(Core.java:
301)
    at org.cartosig.jaspa.JP.ST_GeomFromText(JP.java:243)
    at org.cartosig.jaspa.SQL.ST_GeomFromText(SQL.java:393)
    ... 13 more

    at org.h2.engine.SessionRemote.done(SessionRemote.java:520)
    at org.h2.command.CommandRemote.prepare(CommandRemote.java:70)
    at org.h2.command.CommandRemote.<init>(CommandRemote.java:48)
    at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:
416)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:
1049)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:149)
    at org.h2.server.web.WebThread.getResult(WebThread.java:1691)
    at org.h2.server.web.WebThread.query(WebThread.java:1274)
    at org.h2.server.web.WebThread.process(WebThread.java:430)
    at org.h2.server.web.WebThread.processRequest(WebThread.java:183)
    at org.h2.server.web.WebThread.process(WebThread.java:236)
    at org.h2.server.web.WebThread.run(WebThread.java:193)


On Jan 27, 8:43 pm, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> H2 supports only Java procedures and functions. In Java, you could use:
>
> throw new SQLException("no connection");
>
> Regards,
> Thomas
>
> On Tue, Jan 26, 2010 at 3:32 PM, jomarlla <[email protected]> wrote:
> > Hi everyone,
> > This is my first post in this list and first of all I want to express
> > my gratitude about this fantastic project.  I want to say Hi to all
> > the people in this list too.
>
> > I do not know how to send a message to the client from a java store
> > procedure, for example: in PostgreSQL (in plpgsql) I can use RAISE
> > NOTICE 'message'. Does H2 have something similar?. I want to send this
> > message from a java store procedure that does not have a reference to
> > the object connection.
>
> > Thaxs,
> > Best,
> > Jose
>
> > --
> > 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 
> > athttp://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.

Reply via email to