Search in sources :

Example 46 with SQLFeatureNotSupportedException

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

the class SQLFeatureNotSupportedExceptionTests method test7.

/**
     * Create SQLFeatureNotSupportedException with message, and Throwable
     */
@Test
public void test7() {
    SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException(reason, t);
    assertTrue(ex.getMessage().equals(reason) && 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)

Example 47 with SQLFeatureNotSupportedException

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

the class SQLFeatureNotSupportedExceptionTests method test13.

/**
     * Create SQLFeatureNotSupportedException and validate it is an instance of
     * SQLNonTransientException
     */
@Test
public void test13() {
    Exception ex = new SQLFeatureNotSupportedException();
    assertTrue(ex instanceof SQLNonTransientException);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 48 with SQLFeatureNotSupportedException

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

the class SQLFeatureNotSupportedExceptionTests method test.

/**
     * Create SQLFeatureNotSupportedException and setting all objects to null
     */
@Test
public void test() {
    SQLFeatureNotSupportedException e = new SQLFeatureNotSupportedException(null, null, errorCode, null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null && e.getCause() == null && e.getErrorCode() == errorCode);
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 49 with SQLFeatureNotSupportedException

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

the class SQLFeatureNotSupportedExceptionTests method test3.

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

Example 50 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jena by apache.

the class SelectResultsMetadata method makeColumns.

/**
     * Makes column information for SELECT results
     * 
     * @param results
     *            Result Set
     * @param rset
     *            Underlying SPARQL results
     * @return Column information
     * @throws SQLException
     *             Thrown if the column information cannot be created
     */
private static ColumnInfo[] makeColumns(JenaResultSet results, ResultSetPeekable rset) throws SQLException {
    List<String> vars = rset.getResultVars();
    ColumnInfo[] columns = new ColumnInfo[vars.size()];
    int level = JdbcCompatibility.normalizeLevel(results.getJdbcCompatibilityLevel());
    boolean columnsAsStrings = JdbcCompatibility.shouldTypeColumnsAsString(level);
    boolean columnsDetected = JdbcCompatibility.shouldDetectColumnTypes(level);
    Binding b = null;
    if (columnsDetected) {
        if (rset.hasNext()) {
            b = rset.peekBinding();
        } else {
            // If we were supposed to detect columns but there is no data
            // available then we will just fallback to typing everything as
            // strings
            columnsAsStrings = true;
            columnsDetected = false;
        }
    }
    for (int i = 0; i < columns.length; i++) {
        if (!columnsAsStrings && !columnsDetected) {
            // Low compatibility, report columns as being typed as
            // JAVA_OBJECT with ARQ Node as the column class
            columns[i] = new SparqlColumnInfo(vars.get(i), Types.JAVA_OBJECT, columnNullable);
            LOGGER.info("Low JDBC compatibility, column " + vars.get(i) + " is being typed as Node");
        } else if (columnsAsStrings) {
            // Medium compatibility, report columns as being typed as
            // NVARCHAR with String as the column class
            columns[i] = new StringColumn(vars.get(i), columnNullable);
            LOGGER.info("Medium JDBC compatibility, column " + vars.get(i) + " is being typed as String");
        } else if (columnsDetected) {
            // High compatibility, detect columns types based on first row
            // of results
            columns[i] = JdbcCompatibility.detectColumnType(vars.get(i), b.get(Var.alloc(vars.get(i))), true);
            LOGGER.info("High compatibility, column " + vars.get(i) + " was detected as being of type " + columns[i].getClassName());
        } else {
            throw new SQLFeatureNotSupportedException("Unknown JDBC compatibility level was set");
        }
    }
    return columns;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) StringColumn(org.apache.jena.jdbc.results.metadata.columns.StringColumn) SparqlColumnInfo(org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) ColumnInfo(org.apache.jena.jdbc.results.metadata.columns.ColumnInfo) SparqlColumnInfo(org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo)

Aggregations

SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)58 SQLException (java.sql.SQLException)21 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)7 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 Method (java.lang.reflect.Method)2 Date (java.sql.Date)2 SQLDataException (java.sql.SQLDataException)2 Savepoint (java.sql.Savepoint)2 Vector (java.util.Vector)2 UnitTest (nl.topicus.jdbc.test.category.UnitTest)2