Skip to content

Instantly share code, notes, and snippets.

@MMcM
Last active October 29, 2018 03:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MMcM/f2592ec387130430c4e5 to your computer and use it in GitHub Desktop.
Save MMcM/f2592ec387130430c4e5 to your computer and use it in GitHub Desktop.
FoundationDB SQL Layer Java Routine Example
SQLActions[] = {
"BEGIN INSTALL
CREATE OR REPLACE PROCEDURE test.add_sub(IN x INT, IN y INT, OUT "sum" INT, out diff INT)
LANGUAGE java PARAMETER STYLE java
EXTERNAL NAME 'thisjar:com.foundationdb.example.TestJavaBasic.addSub';
END INSTALL",
"BEGIN REMOVE
DROP PROCEDURE test.add_sub;
END REMOVE"
}
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.foundationdb</groupId>
<artifactId>sql-layer-java-routine-example</artifactId>
<packaging>jar</packaging>
<version>0.1.0-SNAPSHOT</version>
<name>FoundationDB SQL Layer Java Routine Example</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://gist.github.com/MMcM/f2592ec387130430c4e5</url>
</scm>
<dependencies>
<dependency>
<groupId>com.foundationdb</groupId>
<artifactId>fdb-sql-layer</artifactId>
<version>1.9.6-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestSections>
<manifestSection>
<name>install.ddr</name>
<manifestEntries>
<SQLJDeploymentDescriptor>TRUE</SQLJDeploymentDescriptor>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
CALL sqlj.install_jar('/path/to/sql-layer-java-routine-example/target/sql-layer-java-example-0.1.0-SNAPSHOT.jar', 'examplejar', 1);
CALL test.add_sub(100,59);
package com.foundationdb.example;
public class TestJavaBasic
{
public static void addSub(int x, int y, int[] sum, int[] diff) {
sum[0] = x + y;
diff[0] = x - y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment