Package org.sql2o.data

Examples of org.sql2o.data.Row


            .addParameter("val", "hello").addToBatch()
            .executeBatch();
       
        Table table = sql2o.createQuery("select * from issue4table").executeAndFetchTable();

        Row row0 = table.rows().get(0);
        String row0Val = row0.getString("vAl");
       
        assertEquals("something", row0Val);
       
        Row row1 = table.rows().get(1);
        boolean failed = false;
       
        try{
            String row1Value = row1.getString("ahsHashah"); // Should fail with an sql2o exception
        }
        catch(Sql2oException ex){
            failed = true;

            assertTrue(ex.getMessage().startsWith("Column with name 'ahsHashah' does not exist"));
View Full Code Here


        assertEquals("VALUE", table.columns().get(1).getName());
        assertEquals("VALUE2", table.columns().get(2).getName());

        assertEquals(2, table.rows().size());

        Row row0 = table.rows().get(0);
        Row row1 = table.rows().get(1);

        assertTrue(0 <= row0.getInteger("ID"));
        assertEquals("something", row0.getString(1));
        assertEquals(new BigDecimal("3.4"), row0.getBigDecimal("VALUE2"));

        assertTrue(1 <= row1.getInteger(0));
        assertEquals("bla", row1.getString("VALUE"));
        assertEquals(5.5D, row1.getDouble(2), 0.00001);
    }
View Full Code Here

    @Test
    public void testRowGetObjectWithConverters() {
        String sql = "select 1 col1, '23' col2 from (values(0))";
        Table t = sql2o.createQuery(sql).executeAndFetchTable();
        Row r = t.rows().get(0);

        String col1AsString = r.getObject("col1", String.class);
        Integer col1AsInteger = r.getObject("col1", Integer.class);
        Long col1AsLong = r.getObject("col1", Long.class);

        assertThat(col1AsString, is(equalTo("1")));
        assertThat(col1AsInteger, is(equalTo(1)));
        assertThat(col1AsLong, is(equalTo(1L)));

        String col2AsString = r.getObject("col2", String.class);
        Integer col2AsInteger = r.getObject("col2", Integer.class);
        Long col2AsLong = r.getObject("col2", Long.class);

        assertThat(col2AsString, is(equalTo("23")));
        assertThat(col2AsInteger, is(equalTo(23)));
        assertThat(col2AsLong, is(equalTo(23L)));
    }
View Full Code Here

            String selectSql = "select id, val from test_table";
            Table resultTable = sql2o.createQuery(selectSql).executeAndFetchTable();

            assertThat(resultTable.rows().size(), is(1));
            Row resultRow = resultTable.rows().get(0);
            assertThat(resultRow.getLong("id"), equalTo(key));
            assertThat(resultRow.getString("val"), is("something"));

        } finally {
            String dropTableSql = "drop table if exists test_table";
            sql2o.createQuery(dropTableSql).executeUpdate();
        }
View Full Code Here

            String selectSql = "select id, val from test_table";
            Table resultTable = connection.createQuery(selectSql).executeAndFetchTable();

            assertThat(resultTable.rows().size(), is(1));
            Row resultRow = resultTable.rows().get(0);
            assertThat(resultRow.getLong("id"), equalTo(key));
            assertThat(resultRow.getString("val"), is("something"));

        } finally {

            // always rollback, as this is only for tesing purposes.
            if (connection != null) {
View Full Code Here

TOP

Related Classes of org.sql2o.data.Row

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.