Search in sources :

Example 81 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class JdbcThinStatementSelfTest method testFetchDirection.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testFetchDirection() throws Exception {
    assertEquals(ResultSet.FETCH_FORWARD, stmt.getFetchDirection());
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            stmt.setFetchDirection(ResultSet.FETCH_REVERSE);
            return null;
        }
    }, SQLFeatureNotSupportedException.class, "Only forward direction is supported.");
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.setFetchDirection(-1);
        }
    });
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.getFetchDirection();
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 82 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class JdbcThinStatementSelfTest method testWarningsOnClosedStatement.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testWarningsOnClosedStatement() throws Exception {
    stmt.clearWarnings();
    assertNull(null, stmt.getWarnings());
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.getWarnings();
        }
    });
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.clearWarnings();
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 83 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class JdbcThinStatementSelfTest method testGetMoreResults.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testGetMoreResults() throws Exception {
    assertFalse(stmt.getMoreResults());
    stmt.execute("select 1; ");
    ResultSet rs = stmt.getResultSet();
    assertFalse(stmt.getMoreResults());
    assertNull(stmt.getResultSet());
    assertTrue(rs.isClosed());
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.getMoreResults();
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) ResultSet(java.sql.ResultSet) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 84 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class JdbcThinStatementSelfTest method testAutogenerated.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testAutogenerated() throws Exception {
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            stmt.executeUpdate("select 1", -1);
            return null;
        }
    }, SQLException.class, "Invalid autoGeneratedKeys value");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            stmt.execute("select 1", -1);
            return null;
        }
    }, SQLException.class, "Invalid autoGeneratedKeys value");
    assertFalse(conn.getMetaData().supportsGetGeneratedKeys());
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.getGeneratedKeys();
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.executeUpdate("select 1", Statement.RETURN_GENERATED_KEYS);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.executeUpdate("select 1", new int[] { 1, 2 });
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.executeUpdate("select 1", new String[] { "a", "b" });
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.execute("select 1", Statement.RETURN_GENERATED_KEYS);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.execute("select 1", new int[] { 1, 2 });
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.execute("select 1", new String[] { "a", "b" });
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 85 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class JdbcThinStatementSelfTest method testSetEscapeProcessing.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
@Ignore("https://issues.apache.org/jira/browse/IGNITE-5440")
public void testSetEscapeProcessing() throws Exception {
    stmt.setEscapeProcessing(false);
    final String sqlText = "select {fn CONVERT(1, SQL_BOOLEAN)}";
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return stmt.executeQuery(sqlText);
        }
    }, SQLException.class, "Failed to parse");
    ResultSet rs = stmt.executeQuery(sqlText);
    assertTrue(rs.next());
    assertEquals(true, rs.getBoolean(1));
    stmt.setEscapeProcessing(true);
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.setEscapeProcessing(true);
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) ResultSet(java.sql.ResultSet) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException) Ignore(org.junit.Ignore)

Aggregations

RunnableX (org.apache.ignite.testframework.GridTestUtils.RunnableX)126 SQLException (java.sql.SQLException)104 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)80 Test (org.junit.Test)78 Connection (java.sql.Connection)64 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)54 SQLClientInfoException (java.sql.SQLClientInfoException)50 JdbcThinConnection (org.apache.ignite.internal.jdbc.thin.JdbcThinConnection)50 IgniteException (org.apache.ignite.IgniteException)22 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)20 ResultSet (java.sql.ResultSet)18 Savepoint (java.sql.Savepoint)18 CacheException (javax.cache.CacheException)16 QueryIndex (org.apache.ignite.cache.QueryIndex)16 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)16 DatabaseMetaData (java.sql.DatabaseMetaData)10 PreparedStatement (java.sql.PreparedStatement)10 MalformedURLException (java.net.MalformedURLException)6 Statement (java.sql.Statement)6 Ignite (org.apache.ignite.Ignite)6