Writing user defined SQL functions for SQLite using Java or Groovy?

前端 未结 4 1773
轮回少年
轮回少年 2020-12-10 19:44

With SQLite, user defined SQL functions can easily be added using the C api or PHP. But is it also possible using Java or Groovy?

4条回答
  •  情深已故
    2020-12-10 20:25

    I think, this is a simple way to create custom function,

    Class.forName("org.sqlite.JDBC");
    Connection conn = DriverManager.getConnection("jdbc:sqlite:");
    Function.create(conn, "myFunc", new Function() {
               protected void xFunc() {
                   System.out.println("myFunc called!");
               }
           });        
    conn.createStatement().execute("select myFunc();");
    

提交回复
热议问题