Package org.h2.samples
Class Function
- java.lang.Object
-
- org.h2.samples.Function
-
public class Function extends java.lang.ObjectThis sample application shows how to define and use custom (user defined) functions in this database.
-
-
Constructor Summary
Constructors Constructor Description Function()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.sql.ResultSetgetMatrix(java.sql.Connection conn, java.lang.Integer size)Creates a simple result set with two columns.static booleanisPrime(int value)Check if a value is a prime number.static voidmain(java.lang.String... args)This method is called when executing this sample application from the command line.static java.sql.ResultSetquery(java.sql.Connection conn, java.lang.String sql)Execute a query.static java.sql.ResultSetsimpleResultSet()Creates a simple result set with one row.
-
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.lang.ExceptionThis method is called when executing this sample application from the command line.- Parameters:
args- the command line parameters- Throws:
java.lang.Exception- on failure
-
isPrime
public static boolean isPrime(int value)
Check if a value is a prime number.- Parameters:
value- the value- Returns:
- true if it is a prime number
-
query
public static java.sql.ResultSet query(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLExceptionExecute a query.- Parameters:
conn- the connectionsql- the SQL statement- Returns:
- the result set
- Throws:
java.sql.SQLException- on failure
-
simpleResultSet
public static java.sql.ResultSet simpleResultSet()
Creates a simple result set with one row.- Returns:
- the result set
-
getMatrix
public static java.sql.ResultSet getMatrix(java.sql.Connection conn, java.lang.Integer size) throws java.sql.SQLExceptionCreates a simple result set with two columns.- Parameters:
conn- the connectionsize- the number of x and y values- Returns:
- the result set with two columns
- Throws:
java.sql.SQLException- on failure
-
-