On Mon, Sep 27, 2010 at 10:01 AM, Sergi Vladykin <[email protected]>wrote:
> It seems that CallableStatements are not supported. Do you really need > them? > It looks to me like he's trying to find a way to call arbitrary bits of code from a trigger. Currently the easiest way is to put the arbitrary bit of code on the server's classpath, and create the object inside the trigger. This is one of the things I'd like to make easier with the "MODULE" functionality that allows an end user to put bits of code into H2 without having to build a jar file and get it onto the server. I spent most of the weekend reworking the code. Hopefully I'll have something to show fairly soon -- including support for the Bean Scripting Framework.... (Thomas please don't hit me!) Cheers, Kerry (who accidentally unsubscribed from the mailing list a while ago, and didn't notice!) > > On 26 сен, 20:23, Lee Kian Giap <[email protected]> wrote: > > Thanks for your reply ! > > > > I wish to know whether it is possible to use CallableStatement in java to > > get the result ? any solution ? > > > > 2010/9/26 Sergi Vladykin <[email protected]> > > > > > Try "select adduser(?,?,?,?)" without any out parameters > > > > > On 26 сен, 15:45, leekiangiap <[email protected]> wrote: > > > > I am trying the Stored Procedure of H2 Database, as follows: > > > > > > DROP ALIAS IF EXISTS ADDUSER; > > > > CREATE ALIAS ADDUSER AS $$ > > > > import java.util.Date; > > > > @CODE > > > > int addUser(String pname, Date birthday, float money, int id) { > > > > id=15; > > > > return id;} > > > > > > $$; > > > > > > my Java code is as follows, a method using CallableStatement to get > > > > value return from Stored Procedure: > > > > > > static void sp() throws SQLException { > > > > Connection conn = null; > > > > CallableStatement cs = null; > > > > ResultSet rs = null; > > > > try { > > > > conn = JdbcUtils.getConnection(); > > > > String sql = "{CALL ADDUSER(?,?,?,?)}"; > > > > cs = conn.prepareCall(sql); > > > > cs.setString(1, "ps name"); > > > > cs.setDate(2, new > > > java.sql.Date(System.currentTimeMillis())); > > > > cs.setFloat(3, 100f); > > > > cs.registerOutParameter(4, Types.INTEGER); > > > > > > cs.executeUpdate(); > > > > > > int id = cs.getInt(1); > > > > > > System.out.println("id=" + id); > > > > } finally { > > > > JdbcUtils.free(rs, cs, conn); > > > > } > > > > } > > > > > > However, I got the following exception: > > > > > > Exception in thread "main" org.h2.jdbc.JdbcSQLException: Feature not > > > > supported: "registerOutParameter" > > > > > > Notice that the source code of org.h2.jdbc.JdbcCallableStatement is > > > > implemented by throwing Exception. > > > > > > May I know anyway I can get the return value from the PROCEDURE ? > > > > > -- > > > 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]<h2-database%[email protected]> > <h2-database%[email protected]<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]<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.
