Search in sources :

Example 21 with SimpleResultSet

use of org.h2.tools.SimpleResultSet in project h2database by h2database.

the class TestFunctions method varArgsFunctionTable.

/**
 * This method is called via reflection from the database.
 *
 * @param values the value array
 * @return a result set
 */
public static ResultSet varArgsFunctionTable(int... values) throws SQLException {
    if (values.length != 6) {
        throw new SQLException("Unexpected argument count");
    }
    SimpleResultSet result = new SimpleResultSet();
    result.addColumn("A", Types.INTEGER, 0, 0);
    for (int value : values) {
        result.addRow(value);
    }
    return result;
}
Also used : SimpleResultSet(org.h2.tools.SimpleResultSet) SQLException(java.sql.SQLException) JdbcSQLException(org.h2.jdbc.JdbcSQLException)

Example 22 with SimpleResultSet

use of org.h2.tools.SimpleResultSet in project h2database by h2database.

the class TestFunctions method simpleFunctionTable.

/**
 * This method is called via reflection from the database.
 *
 * @param conn the connection
 * @return a result set
 */
public static ResultSet simpleFunctionTable(@SuppressWarnings("unused") Connection conn) {
    SimpleResultSet result = new SimpleResultSet();
    result.addColumn("A", Types.INTEGER, 0, 0);
    result.addColumn("B", Types.CHAR, 0, 0);
    result.addRow(42, 'X');
    return result;
}
Also used : SimpleResultSet(org.h2.tools.SimpleResultSet)

Example 23 with SimpleResultSet

use of org.h2.tools.SimpleResultSet in project h2database by h2database.

the class TestSpatial method pointTable.

/**
 * This method is called via reflection from the database.
 *
 * @param x the x position of the point
 * @param y the y position of the point
 * @return a result set with this point
 */
public static ResultSet pointTable(double x, double y) {
    GeometryFactory factory = new GeometryFactory();
    SimpleResultSet rs = new SimpleResultSet();
    rs.addColumn("THE_GEOM", Types.JAVA_OBJECT, "GEOMETRY", 0, 0);
    rs.addRow(factory.createPoint(new Coordinate(x, y)));
    return rs;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SimpleResultSet(org.h2.tools.SimpleResultSet) Coordinate(org.locationtech.jts.geom.Coordinate)

Example 24 with SimpleResultSet

use of org.h2.tools.SimpleResultSet in project spring-integration by spring-projects.

the class H2StoredProcedures method getPrimes.

public static ResultSet getPrimes(int beginRange, int endRange) throws SQLException {
    SimpleResultSet rs = new SimpleResultSet();
    rs.addColumn("PRIME", Types.INTEGER, 10, 0);
    for (int i = beginRange; i <= endRange; i++) {
        if (new BigInteger(String.valueOf(i)).isProbablePrime(100)) {
            rs.addRow(i);
        }
    }
    return rs;
}
Also used : SimpleResultSet(org.h2.tools.SimpleResultSet) BigInteger(java.math.BigInteger)

Example 25 with SimpleResultSet

use of org.h2.tools.SimpleResultSet in project siena by mandubian.

the class FullText method createResultSet.

/**
 * Create an empty search result and initialize the columns.
 *
 * @param data true if the result set should contain the primary key data as
 *            an array.
 * @return the empty result set
 */
protected static SimpleResultSet createResultSet(boolean data) {
    SimpleResultSet result = new SimpleResultSet();
    if (data) {
        result.addColumn(FullText.FIELD_SCHEMA, Types.VARCHAR, 0, 0);
        result.addColumn(FullText.FIELD_TABLE, Types.VARCHAR, 0, 0);
        result.addColumn(FullText.FIELD_COLUMNS, Types.ARRAY, 0, 0);
        result.addColumn(FullText.FIELD_KEYS, Types.ARRAY, 0, 0);
    } else {
        result.addColumn(FullText.FIELD_QUERY, Types.VARCHAR, 0, 0);
    }
    result.addColumn(FullText.FIELD_SCORE, Types.FLOAT, 0, 0);
    return result;
}
Also used : SimpleResultSet(org.h2.tools.SimpleResultSet)

Aggregations

SimpleResultSet (org.h2.tools.SimpleResultSet)46 ResultSet (java.sql.ResultSet)11 SQLException (java.sql.SQLException)10 BigDecimal (java.math.BigDecimal)9 BigInteger (java.math.BigInteger)5 Value (org.h2.value.Value)5 Date (java.sql.Date)4 ResultSetMetaData (java.sql.ResultSetMetaData)4 Time (java.sql.Time)4 Timestamp (java.sql.Timestamp)4 ValueString (org.h2.value.ValueString)4 IOException (java.io.IOException)3 PreparedStatement (java.sql.PreparedStatement)3 Document (org.apache.lucene.document.Document)3 JdbcSQLException (org.h2.jdbc.JdbcSQLException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Array (java.sql.Array)2 Blob (java.sql.Blob)2 Clob (java.sql.Clob)2