Search in sources :

Example 16 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_double_02.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_double_02() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new ByteColumn("Test", ResultSetMetaData.columnNullable, true) }, new Object[][] { { null } });
    Assert.assertTrue(results.next());
    double value = results.getDouble(1);
    Assert.assertEquals(0d, value, 0d);
    Assert.assertTrue(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) ByteColumn(org.apache.jena.jdbc.results.metadata.columns.ByteColumn) Test(org.junit.Test)

Example 17 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_long_integer_01.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_long_integer_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new LongIntegerColumn("Test", ResultSetMetaData.columnNullable, true) }, new Object[][] { { 1234l } });
    Assert.assertTrue(results.next());
    long value = results.getLong(1);
    Assert.assertEquals(1234, value);
    Assert.assertFalse(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) LongIntegerColumn(org.apache.jena.jdbc.results.metadata.columns.LongIntegerColumn) Test(org.junit.Test)

Example 18 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method empty_meta_result_set_01.

/**
     * Check empty meta result set
     * 
     * @throws SQLException
     */
@Test
public void empty_meta_result_set_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[0]);
    // Check results metadata
    ResultSetMetaData metadata = results.getMetaData();
    Assert.assertEquals(0, metadata.getColumnCount());
    // Check results
    Assert.assertTrue(results.isBeforeFirst());
    Assert.assertFalse(results.next());
    Assert.assertTrue(results.isAfterLast());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) Test(org.junit.Test)

Example 19 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_movement_04.

/**
     * Test movement within meta results
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_movement_04() throws SQLException {
    MetaResultSet results = createMetaResultSet(1);
    Assert.assertTrue(results.isBeforeFirst());
    // Move to absolute row
    Assert.assertTrue(results.absolute(1));
    Assert.assertTrue(results.isFirst());
    Assert.assertFalse(results.isBeforeFirst());
    Assert.assertTrue(results.isLast());
    Assert.assertFalse(results.isAfterLast());
    // Move to end
    Assert.assertFalse(results.next());
    Assert.assertTrue(results.isAfterLast());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) Test(org.junit.Test)

Example 20 with MetaResultSet

use of org.apache.jena.jdbc.metadata.results.MetaResultSet in project jena by apache.

the class TestMetaResultSet method meta_result_set_time_01.

/**
     * Test retrieving meta column values
     * 
     * @throws SQLException
     */
@Test
public void meta_result_set_time_01() throws SQLException {
    MetaResultSet results = new MetaResultSet(new ColumnInfo[] { new TimeColumn("Test", ResultSetMetaData.columnNullable) }, new Object[][] { { new Time(0) } });
    Assert.assertTrue(results.next());
    Time value = results.getTime(1);
    Assert.assertEquals(new Time(0), value);
    Assert.assertFalse(results.wasNull());
    Assert.assertFalse(results.next());
    results.close();
    Assert.assertTrue(results.isClosed());
}
Also used : TimeColumn(org.apache.jena.jdbc.results.metadata.columns.TimeColumn) MetaResultSet(org.apache.jena.jdbc.metadata.results.MetaResultSet) Time(java.sql.Time) Test(org.junit.Test)

Aggregations

MetaResultSet (org.apache.jena.jdbc.metadata.results.MetaResultSet)28 Test (org.junit.Test)28 LongIntegerColumn (org.apache.jena.jdbc.results.metadata.columns.LongIntegerColumn)4 ShortIntegerColumn (org.apache.jena.jdbc.results.metadata.columns.ShortIntegerColumn)4 ByteColumn (org.apache.jena.jdbc.results.metadata.columns.ByteColumn)3 StringColumn (org.apache.jena.jdbc.results.metadata.columns.StringColumn)3 BigDecimal (java.math.BigDecimal)2 Date (java.sql.Date)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 Time (java.sql.Time)2 BooleanColumn (org.apache.jena.jdbc.results.metadata.columns.BooleanColumn)2 DateColumn (org.apache.jena.jdbc.results.metadata.columns.DateColumn)2 DecimalColumn (org.apache.jena.jdbc.results.metadata.columns.DecimalColumn)2 FloatColumn (org.apache.jena.jdbc.results.metadata.columns.FloatColumn)2 IntegerColumn (org.apache.jena.jdbc.results.metadata.columns.IntegerColumn)2 TimeColumn (org.apache.jena.jdbc.results.metadata.columns.TimeColumn)2 DoubleColumn (org.apache.jena.jdbc.results.metadata.columns.DoubleColumn)1