Search in sources :

Example 1 with OQuery

use of com.orientechnologies.orient.core.query.OQuery in project orientdb by orientechnologies.

the class OrientJdbcPreparedStatement method executeQuery.

@SuppressWarnings("unchecked")
public ResultSet executeQuery() throws SQLException {
    //    return super.executeQuery(sql);
    sql = mayCleanForSpark(sql);
    if (sql.equalsIgnoreCase("select 1")) {
        // OPTIMIZATION
        documents = new ArrayList<ODocument>();
        documents.add(new ODocument().field("1", 1));
    } else {
        try {
            query = new OSQLSynchQuery<ODocument>(mayCleanForSpark(sql));
            documents = database.query((OQuery<? extends Object>) query, params.values().toArray());
        } catch (OQueryParsingException e) {
            throw new SQLSyntaxErrorException("Error while parsing query", e);
        } catch (OException e) {
            throw new SQLException("Error while executing query", e);
        }
    }
    // return super.executeQuery(sql);
    resultSet = new OrientJdbcResultSet(this, documents, resultSetType, resultSetConcurrency, resultSetHoldability);
    return resultSet;
}
Also used : OQuery(com.orientechnologies.orient.core.query.OQuery) SQLException(java.sql.SQLException) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) OQueryParsingException(com.orientechnologies.orient.core.exception.OQueryParsingException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OException (com.orientechnologies.common.exception.OException)1 OQueryParsingException (com.orientechnologies.orient.core.exception.OQueryParsingException)1 OQuery (com.orientechnologies.orient.core.query.OQuery)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 SQLSyntaxErrorException (java.sql.SQLSyntaxErrorException)1