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]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
