Search in sources :

Example 76 with Prepared

use of org.h2.test.db.Db.Prepared in project h2database by h2database.

the class H2Database method rawQuery.

/**
 * Execute the query.
 *
 * @param sql the SQL statement
 * @param selectionArgs the parameter values
 * @return the cursor
 */
public Cursor rawQuery(String sql, String[] selectionArgs) {
    Prepared prep = prepare(sql, selectionArgs);
    ResultInterface result = prep.query(0);
    return new H2Cursor(result);
}
Also used : ResultInterface(org.h2.result.ResultInterface) Prepared(org.h2.command.Prepared)

Example 77 with Prepared

use of org.h2.test.db.Db.Prepared in project h2database by h2database.

the class H2Database method prepare.

private Prepared prepare(String sql, Object[] args) {
    Prepared prep = session.prepare(sql);
    int len = args.length;
    if (len > 0) {
        ArrayList<Parameter> params = prep.getParameters();
        for (int i = 0; i < len; i++) {
            Parameter p = params.get(i);
            p.setValue(getValue(args[i]));
        }
    }
    return prep;
}
Also used : Prepared(org.h2.command.Prepared) Parameter(org.h2.expression.Parameter)

Aggregations

Prepared (org.h2.command.Prepared)32 ValueString (org.h2.value.ValueString)16 SQLException (java.sql.SQLException)11 ArrayList (java.util.ArrayList)11 AlterTableDropConstraint (org.h2.command.ddl.AlterTableDropConstraint)11 AlterTableRenameConstraint (org.h2.command.ddl.AlterTableRenameConstraint)11 AlterTableAddConstraint (org.h2.command.ddl.AlterTableAddConstraint)10 Parameter (org.h2.expression.Parameter)10 DbException (org.h2.message.DbException)10 PreparedStatement (java.sql.PreparedStatement)9 Value (org.h2.value.Value)8 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)7 Query (org.h2.command.dml.Query)7 Expression (org.h2.expression.Expression)7 Column (org.h2.table.Column)7 Connection (java.sql.Connection)6 IndexColumn (org.h2.table.IndexColumn)6 ResultSet (java.sql.ResultSet)5 SQLClientInfoException (java.sql.SQLClientInfoException)5 Savepoint (java.sql.Savepoint)5