code: public static void registerFunction(Statement st,Function function,String packagePrepend,boolean dropAlias) throws SQLException {
          String functionClass = function.getClass().getName();
          String functionAlias = getAlias(function);
  
          if(function instanceof ScalarFunction) {
              ScalarFunction scalarFunction = (ScalarFunction)function;
              String functionName = scalarFunction.getJavaStaticMethod();
              if(dropAlias) {
                  try {
                      st.execute("DROP ALIAS IF EXISTS " + functionAlias);
                  } catch (SQLException ex) {
                      // Ignore, some tables constraints may depend on this function
                      LOGGER.debug(ex.getLocalizedMessage(), ex);
                  }
              }
              String deterministic = "";
              if(getBooleanProperty(function,ScalarFunction.PROP_DETERMINISTIC,false)) {
                  deterministic = " DETERMINISTIC";
              }
              String nobuffer = "";
              if(getBooleanProperty(function, ScalarFunction.PROP_NOBUFFER, false)) {
                  nobuffer = " NOBUFFER";
              }
              // Create alias, H2 does not support prepare statement on create alias
              // "FORCE ALIAS means that the class not existing will not prevent the database from being opened."
              st.execute("CREATE FORCE ALIAS IF NOT EXISTS " + functionAlias + deterministic + nobuffer + " FOR \"" + packagePrepend + functionClass + "." + functionName + "\"");
              // Set comment
              String functionRemarks = getStringProperty(function, Function.PROP_REMARKS);
              if(!functionRemarks.isEmpty()) {
                  PreparedStatement ps = st.getConnection().prepareStatement("COMMENT ON ALIAS "+functionAlias+" IS ?");
                  ps.setString(1, functionRemarks);
                  ps.execute();
              }
          } else if(function instanceof Aggregate) {
                  if(dropAlias) {
                      st.execute("DROP AGGREGATE IF EXISTS " + functionAlias);
                  }
                  st.execute("CREATE FORCE AGGREGATE IF NOT EXISTS " + functionAlias + " FOR \"" + packagePrepend + functionClass + "\"");
          } else {
                  throw new SQLException("Unsupported function "+functionClass);
          }
      }
docs: Register a H2GIS java code function
  
  @param st SQL Statement
  @param function Function instance
  @param packagePrepend For OSGi environment only, use Bundle-SymbolicName:Bundle-Version:
  @param dropAlias Drop alias if exists before define it.
  @throws java.sql.SQLException