Package org.apache.jena.jdbc.results.metadata.columns

Examples of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo


            throw new SQLException("Result set is closed");
        if (this.currRow < 0 || this.currRow >= this.rows.length)
            throw new SQLException("Not currently at a row");
        if (columnIndex >= 1 && columnIndex <= this.columns.length) {
            // Remember that JDBC uses a 1 based index
            ColumnInfo info = this.columns[columnIndex - 1];

            // Determine whether the column has a null value
            Object obj = this.rows[this.currRow][columnIndex - 1];
            this.wasNull = (obj == null);
            if (this.wasNull)
                return nullValue;

            if (info.getType() == expectedType) {
                // If the column is typed appropriately try and marshal
                // appropriately
                if (targetType.isAssignableFrom(obj.getClass())) {
                    try {
                        Object temp = targetType.cast(obj);
                        return temp;
                    } catch (ClassCastException e) {
                        throw new SQLException("Value for this column (Row " + (currRow+1) + " Column " + columnIndex + ") is not valid for the columns declared type", e);
                    }
                } else {
                    throw new SQLException("Value for this column (Row " + (currRow+1) + " Column " + columnIndex + ") is not valid for the columns declared type");
                }
            } else {
                throw new SQLException("Given column (Row " + (currRow+1) + " Column " + columnIndex + ") does not contain appropriately typed values.  Column type declared as " + info.getType() + " but expected type for this lookup is " + expectedType);
            }
        } else {
            throw new SQLException("Column index is out of bounds");
        }
    }
View Full Code Here


        if (init)
            return;
        try {
            // Define all the columns we are going to use since some of these
            // appear in multiple schema
            ColumnInfo empty = new StringColumn("", columnNullable);
            ColumnInfo typeCat = new StringColumn("TYPE_CATA", columnNullable);
            ColumnInfo typeSchema = new StringColumn("TYPE_SCHEM", columnNullable);
            ColumnInfo typeName = new StringColumn("TYPE_NAME", columnNoNulls);
            ColumnInfo attrName = new StringColumn("ATTR_NAME", columnNoNulls);
            ColumnInfo dataType = new IntegerColumn("DATA_TYPE", columnNoNulls, true);
            ColumnInfo attrTypeName = new StringColumn("ATTR_TYPE_NAME", columnNoNulls);
            ColumnInfo attrSize = new IntegerColumn("ATTR_SIZE", columnNoNulls, true);
            ColumnInfo decimalDigits = new IntegerColumn("DECIMAL_DIGITS", columnNoNulls, true);
            ColumnInfo numPrecRadix = new IntegerColumn("NUM_PREC_RADIX", columnNoNulls, true);
            ColumnInfo nullable = new IntegerColumn("NULLABLE", columnNoNulls, true);
            ColumnInfo shortNullable = new ShortIntegerColumn("NULLABLE", columnNoNulls, true);
            ColumnInfo remarks = new StringColumn("REMARKS", columnNullable);
            ColumnInfo attrDef = new StringColumn("ATTR_DEF", columnNullable);
            ColumnInfo sqlDataType = new IntegerColumn("SQL_DATA_TYPE", columnNoNulls, true);
            ColumnInfo sqlDateTimeSub = new IntegerColumn("SQL_DATETIME_SUB", columnNoNulls, true);
            ColumnInfo charOctetLength = new IntegerColumn("CHAR_OCTET_LENGTH", columnNoNulls, true);
            ColumnInfo ordinalPosition = new IntegerColumn("ORDINAL_POSITION", columnNoNulls, true);
            ColumnInfo isNullable = new StringColumn("IS_NULLABLE", columnNoNulls);
            ColumnInfo scope = new ShortIntegerColumn("SCOPE", columnNoNulls, true);
            ColumnInfo scopeCatalog = new StringColumn("SCOPE_CATALOG", columnNullable);
            ColumnInfo scopeSchema = new StringColumn("SCOPE_SCHEMA", columnNullable);
            ColumnInfo scopeTable = new StringColumn("SCOPE_TABLE", columnNullable);
            ColumnInfo sourceDataType = new ShortIntegerColumn("SOURCE_DATA_TYPE", columnNullable, true);
            ColumnInfo columnName = new StringColumn("COLUMN_NAME", columnNoNulls);
            ColumnInfo columnSize = new IntegerColumn("COLUMN_SIZE", columnNoNulls, true);
            ColumnInfo columnDef = new StringColumn("COLUMN_DEF", columnNullable);
            ColumnInfo bufferLength = new IntegerColumn("BUFFER_LENGTH", columnNoNulls, true);
            ColumnInfo psuedoColumn = new ShortIntegerColumn("PSUEDO_COLUMN", columnNoNulls, true);
            ColumnInfo tableCat = new StringColumn("TABLE_CAT", columnNullable);
            ColumnInfo tableCatalog = new StringColumn("TABLE_CATALOG", columnNullable);
            ColumnInfo tableSchema = new StringColumn("TABLE_SCHEM", columnNullable);
            ColumnInfo tableName = new StringColumn("TABLE_NAME", columnNoNulls);
            ColumnInfo name = new StringColumn("NAME", columnNoNulls);
            ColumnInfo maxLen = new IntegerColumn("MAX_LEN", columnNoNulls, true);
            ColumnInfo defaultValue = new StringColumn("DEFAULT_VALUE", columnNullable);
            ColumnInfo description = new StringColumn("DESCRIPTION", columnNullable);
            ColumnInfo isAutoIncrement = new StringColumn("IS_AUTOINCREMENT", columnNoNulls);
            ColumnInfo className = new StringColumn("CLASS_NAME", columnNoNulls);
            ColumnInfo baseType = new ShortIntegerColumn("BASE_TYPE", columnNullable, true);
            ColumnInfo grantor = new StringColumn("GRANTOR", columnNullable);
            ColumnInfo grantee = new StringColumn("GRANTEE", columnNullable);
            ColumnInfo privilege = new StringColumn("PRIVILEGE", columnNoNulls);
            ColumnInfo isGrantable = new StringColumn("IS_GRANTABLE", columnNoNulls);
            ColumnInfo pkTableCat = new StringColumn("PKTABLE_CAT", columnNullable);
            ColumnInfo pkTableSchema = new StringColumn("PKTABLE_SCHEM", columnNullable);
            ColumnInfo pkTableName = new StringColumn("PKTABLE_NAME", columnNoNulls);
            ColumnInfo pkColumnName = new StringColumn("PKCOLUMN_NAME", columnNoNulls);
            ColumnInfo fkTableCat = new StringColumn("FKTABLE_CAT", columnNullable);
            ColumnInfo fkTableSchema = new StringColumn("FKTABLE_SCHEM", columnNullable);
            ColumnInfo fkTableName = new StringColumn("FKTABLE_NAME", columnNoNulls);
            ColumnInfo fkColumnName = new StringColumn("FKCOLUMN_NAME", columnNoNulls);
            ColumnInfo keySeq = new ShortIntegerColumn("KEY_SEQ", columnNoNulls, true);
            ColumnInfo updateRule = new ShortIntegerColumn("UPDATE_RULE", columnNoNulls, true);
            ColumnInfo deleteRule = new ShortIntegerColumn("DELETE_RULE", columnNoNulls, true);
            ColumnInfo fkName = new StringColumn("FK_NAME", columnNullable);
            ColumnInfo pkName = new StringColumn("PK_NAME", columnNullable);
            ColumnInfo deferrability = new ShortIntegerColumn("DEFERRABILITY", columnNoNulls, true);
            ColumnInfo functionCat = new StringColumn("FUNCTION_CAT", columnNullable);
            ColumnInfo functionSchema = new StringColumn("FUNCTION_SCHEM", columnNullable);
            ColumnInfo functionName = new StringColumn("FUNCTION_NAME", columnNoNulls);
            ColumnInfo columnType = new ShortIntegerColumn("COLUMN_TYPE", columnNoNulls, true);
            ColumnInfo precision = new IntegerColumn("PRECISION", columnNoNulls, true);
            ColumnInfo length = new IntegerColumn("LENGTH", columnNoNulls, true);
            ColumnInfo scale = new ShortIntegerColumn("SCALE", columnNoNulls, true);
            ColumnInfo radix = new ShortIntegerColumn("RADIX", columnNoNulls, true);
            ColumnInfo specificName = new StringColumn("SPECIFIC_NAME", columnNoNulls);
            ColumnInfo functionType = new ShortIntegerColumn("FUNCTION_TYPE", columnNoNulls, true);
            ColumnInfo nonUnique = new BooleanColumn("NON_UNIQUE", columnNoNulls);
            ColumnInfo indexQualifier = new StringColumn("INDEX_QUALIFIER", columnNullable);
            ColumnInfo indexName = new StringColumn("INDEX_NAME", columnNullable);
            ColumnInfo type = new ShortIntegerColumn("TYPE", columnNoNulls, true);
            ColumnInfo ascOrDesc = new StringColumn("ASC_OR_DESC", columnNullable);
            ColumnInfo cardinality = new IntegerColumn("CARDINALITY", columnNoNulls, true);
            ColumnInfo pages = new IntegerColumn("PAGES", columnNoNulls, true);
            ColumnInfo filterCondition = new StringColumn("FILTER_CONDITION", columnNullable);
            ColumnInfo procedureCat = new StringColumn("PROCEDURE_CAT", columnNullable);
            ColumnInfo procedureSchema = new StringColumn("PROCEDURE_SCHEM", columnNullable);
            ColumnInfo procedureName = new StringColumn("PROCEDURE_NAME", columnNoNulls);
            ColumnInfo procedureType = new ShortIntegerColumn("PROCEDURE_TYPE", columnNoNulls, true);
            ColumnInfo superTableName = new StringColumn("SUPERTABLE_NAME", columnNoNulls);
            ColumnInfo superTypeCat = new StringColumn("SUPERTYPE_CAT", columnNullable);
            ColumnInfo superTypeSchema = new StringColumn("SUPERTYPE_SCHEM", columnNullable);
            ColumnInfo superTypeName = new StringColumn("SUPERTYPE_NAME", columnNoNulls);
            ColumnInfo litPrefix = new StringColumn("LITERAL_PREFIX", columnNullable);
            ColumnInfo litSuffix = new StringColumn("LITERAL_SUFFIX", columnNullable);
            ColumnInfo createParams = new StringColumn("CREATE_PARAMS", columnNullable);
            ColumnInfo caseSensitive = new BooleanColumn("CASE_SENSITIVE", columnNoNulls);
            ColumnInfo searchable = new ShortIntegerColumn("SEARCHABLE", columnNoNulls, true);
            ColumnInfo unsignedAttr = new BooleanColumn("UNSIGNED_ATTRIBUTE", columnNoNulls);
            ColumnInfo fixedPrecScale = new BooleanColumn("FIXED_PREC_SCALE", columnNoNulls);
            ColumnInfo autoIncrement = new BooleanColumn("AUTO_INCREMENT", columnNoNulls);
            ColumnInfo localTypeName = new StringColumn("LOCAL_TYPE_NAME", columnNullable);
            ColumnInfo minScale = new ShortIntegerColumn("MINIMUM_SCALE", columnNoNulls, true);
            ColumnInfo maxScale = new ShortIntegerColumn("MAXIMUM_SCALE", columnNullable, true);
            ColumnInfo tableType = new StringColumn("TABLE_TYPE", columnNoNulls);
            ColumnInfo selfRefColName = new StringColumn("SELF_REFERENCING_COL_NAME", columnNullable);
            ColumnInfo refGeneration = new StringColumn("REF_GENERATION", columnNullable);
            ColumnInfo columnUsage = new StringColumn("COLUMN_USAGE", columnNoNulls);

            ATTRIBUTE_COLUMNS = new ColumnInfo[] {
                    // TYPE_CAT String => type catalog (may be null)
                    typeCat,
                    // TYPE_SCHEM String => type schema (may be null)
View Full Code Here

     * @param className Expected detected class name
     * @return Column Information
     * @throws SQLException
     */
    private ColumnInfo testColumnTypeDetection(String var, Node value, boolean allowNulls, int jdbcType, String className) throws SQLException {
        ColumnInfo info = JdbcCompatibility.detectColumnType(var, value, allowNulls);
        Assert.assertEquals(var, info.getLabel());
        if (allowNulls) {
            Assert.assertEquals(ResultSetMetaData.columnNullable, info.getNullability());
        } else {
            Assert.assertEquals(ResultSetMetaData.columnNoNulls, info.getNullability());
        }
        Assert.assertEquals(jdbcType, info.getType());
        Assert.assertEquals(className, info.getClassName());
        Assert.assertEquals(Node.class.getCanonicalName(), info.getTypeName());
        return info;
    }
View Full Code Here

     * Expect xsd:integer to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_01() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactoryExtra.intToNode(1234), true, Types.BIGINT, Long.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertTrue(info.isSigned());
    }
View Full Code Here

     * Expect xsd:int to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_02() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDint), true, Types.BIGINT, Long.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertTrue(info.isSigned());
    }
View Full Code Here

     * Expect xsd:long to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_03() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDlong), true, Types.BIGINT, Long.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertTrue(info.isSigned());
    }
View Full Code Here

     * Expect xsd:unsignedInteger to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_04() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDunsignedInt), true, Types.BIGINT, Long.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertFalse(info.isSigned());
    }
View Full Code Here

     * Expect xsd:unsignedLong to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_05() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDunsignedLong), true, Types.BIGINT, Long.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertFalse(info.isSigned());
    }
View Full Code Here

     * Expect xsd:short to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_06() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDshort), true, Types.INTEGER, Integer.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertTrue(info.isSigned());
    }
View Full Code Here

     * Expect xsd:unsignedShort to be typed as integers
     * @throws SQLException
     */
    @Test
    public void test_column_type_detection_integer_07() throws SQLException {
        ColumnInfo info = testColumnTypeDetection("x", NodeFactory.createLiteral("1234", XSDDatatype.XSDunsignedShort), true, Types.INTEGER, Integer.class.getCanonicalName());
        Assert.assertEquals(0, info.getScale());
        Assert.assertFalse(info.isSigned());
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.jdbc.results.metadata.columns.ColumnInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.