Example usage for java.sql SQLSyntaxErrorException SQLSyntaxErrorException

List of usage examples for java.sql SQLSyntaxErrorException SQLSyntaxErrorException

Introduction

In this page you can find the example usage for java.sql SQLSyntaxErrorException SQLSyntaxErrorException.

Prototype

public SQLSyntaxErrorException(Throwable cause) 

Source Link

Document

Constructs a SQLSyntaxErrorException object with a given cause.

Usage

From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java

CassandraStatement(CassandraConnection con, String cql, int resultSetType, int resultSetConcurrency,
        int resultSetHoldability) throws SQLException {
    this.connection = con;
    this.cql = cql;
    this.batchQueries = Lists.newArrayList();

    this.consistencyLevel = con.defaultConsistencyLevel;

    if (!(resultSetType == ResultSet.TYPE_FORWARD_ONLY || resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE
            || resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE))
        throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
    this.resultSetType = resultSetType;

    if (!(resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
            || resultSetConcurrency == ResultSet.CONCUR_UPDATABLE))
        throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
    this.resultSetConcurrency = resultSetConcurrency;

    if (!(resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT
            || resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT))
        throw new SQLSyntaxErrorException(BAD_HOLD_RSET);
    this.resultSetHoldability = resultSetHoldability;
}

From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java

public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
    checkNotClosed();// w w  w.  j av  a  2s. c  om

    if (!(autoGeneratedKeys == RETURN_GENERATED_KEYS || autoGeneratedKeys == NO_GENERATED_KEYS))
        throw new SQLSyntaxErrorException(BAD_AUTO_GEN);

    if (autoGeneratedKeys == RETURN_GENERATED_KEYS)
        throw new SQLFeatureNotSupportedException(NO_GEN_KEYS);

    return execute(sql);
}

From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java

@SuppressWarnings("boxing")
public boolean getMoreResults(int current) throws SQLException {
    checkNotClosed();//w w w .ja  v a 2  s.co m

    switch (current) {
    case CLOSE_CURRENT_RESULT:
        resetResults();
        break;

    case CLOSE_ALL_RESULTS:
    case KEEP_CURRENT_RESULT:
        throw new SQLFeatureNotSupportedException(NO_MULTIPLE);

    default:
        throw new SQLSyntaxErrorException(String.format(BAD_KEEP_RSET, current));
    }
    // in the current Cassandra implementation there are never MORE results
    return false;
}

From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java

@SuppressWarnings("boxing")
public void setFetchDirection(int direction) throws SQLException {
    checkNotClosed();/*w w  w  .  j  av  a  2s  .  c o m*/

    if (direction == ResultSet.FETCH_FORWARD || direction == ResultSet.FETCH_REVERSE
            || direction == ResultSet.FETCH_UNKNOWN) {
        if ((getResultSetType() == ResultSet.TYPE_FORWARD_ONLY) && (direction != ResultSet.FETCH_FORWARD))
            throw new SQLSyntaxErrorException(String.format(BAD_FETCH_DIR, direction));
        fetchDirection = direction;
    } else
        throw new SQLSyntaxErrorException(String.format(BAD_FETCH_DIR, direction));
}

From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java

@SuppressWarnings("boxing")
public void setFetchSize(int size) throws SQLException {
    checkNotClosed();/*  w w  w  . j  a  v  a2  s.co m*/
    if (size < 0)
        throw new SQLSyntaxErrorException(String.format(BAD_FETCH_SIZE, size));
    fetchSize = size;
}