Search in sources :

Example 11 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project robovm by robovm.

the class OldStatementTest method testExecuteUpdate_String_StringArray.

// TODO executeUpdate(String sql, String[] columnNames) is not supported
public void testExecuteUpdate_String_StringArray() throws SQLException {
    Statement st = null;
    try {
        String[] queries = { "update zoo set name='Masha', family='cat' where id=2;", "drop table if exists hutch", "create table hutch (id integer not null, animal_id integer, address char(20), primary key (id));", "insert into hutch (id, animal_id, address) values (1, 2, 'Birds-house, 1');", "insert into hutch (id, animal_id, address) values (2, 1, 'Horse-house, 5');", "create view address as select address from hutch where animal_id=2", "drop view address;", "drop table hutch;" };
        Vector<String[]> array = new Vector<String[]>();
        array.addElement(null);
        array.addElement(new String[] { "", "", "", "", "", "", "", "" });
        array.addElement(new String[] { "field 1", "", "field2" });
        array.addElement(new String[] { "id", "family", "name" });
        array.addElement(new String[] { "id", null, "family", null, "name" });
        array.addElement(new String[] { "id", " ", "name" });
        array.addElement(new String[] { null, null, null, null });
        array.addElement(new String[] { " ", "123 21", "~!@#$%^&*()_+ ", null });
        st = conn.createStatement();
        for (int i = 0; i < queries.length; i++) {
            st.executeUpdate(queries[i], (String[]) array.elementAt(i));
            fail("Revise test implemenation for feature impl. has changed");
        }
    } catch (SQLFeatureNotSupportedException e) {
    // expected
    } finally {
        try {
            st.close();
        } catch (SQLException ee) {
        }
    }
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) Vector(java.util.Vector)

Example 12 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project robovm by robovm.

the class OldStatementTest method testSetCursorName.

// TODO setCursorName() is not supported
public void testSetCursorName() throws SQLException {
    Statement st = null;
    try {
        String select = "select * from zoo";
        st = conn.createStatement();
        st.setCursorName("test");
        fail("Fail: statement does not fail");
    } catch (SQLFeatureNotSupportedException e) {
    // expected
    }
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement)

Example 13 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project robovm by robovm.

the class OldStatementTest method testGeneratedKeys.

public void testGeneratedKeys() throws SQLException {
    Statement st = null;
    try {
        String insert = "insert into zoo (id, name, family) values (8, 'Tuzik', 'dog');";
        st = conn.createStatement();
        assertNull(st.getGeneratedKeys());
        fail("Fail: statement does not fail");
    } catch (SQLFeatureNotSupportedException e) {
    // expected
    }
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement)

Example 14 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jdk8u_jdk by JetBrains.

the class SQLFeatureNotSupportedExceptionTests method test5.

/**
     * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
     */
@Test
public void test5() {
    SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode);
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 15 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jdk8u_jdk by JetBrains.

the class SQLFeatureNotSupportedExceptionTests method test9.

/**
     * Create SQLFeatureNotSupportedException with Throwable
     */
@Test
public void test9() {
    SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException(t);
    assertTrue(ex.getMessage().equals(cause) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)55 SQLException (java.sql.SQLException)20 Connection (java.sql.Connection)14 Test (org.testng.annotations.Test)14 BaseTest (util.BaseTest)14 PreparedStatement (java.sql.PreparedStatement)13 Statement (java.sql.Statement)11 ResultSet (java.sql.ResultSet)10 Test (org.junit.Test)5 Properties (java.util.Properties)4 CallableStatement (java.sql.CallableStatement)3 DruidPooledCallableStatement (com.alibaba.druid.pool.DruidPooledCallableStatement)2 DruidPooledResultSet (com.alibaba.druid.pool.DruidPooledResultSet)2 DruidPooledStatement (com.alibaba.druid.pool.DruidPooledStatement)2 Date (java.sql.Date)2 SQLDataException (java.sql.SQLDataException)2 Savepoint (java.sql.Savepoint)2 Vector (java.util.Vector)2 ColumnInfo (org.apache.jena.jdbc.results.metadata.columns.ColumnInfo)2 SparqlColumnInfo (org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo)2