Package org.skife.jdbi.v2

Examples of org.skife.jdbi.v2.DBI


        assertEquals(1, count);
    }

    public void testParameterizedInsert() throws Exception
    {
        final Handle h = openHandle();
        final int count = h.createStatement("tests:parameterized_insert")
                .define("table", "something")
                .define("column_one", "id")
                .define("column_two", "name")
                .bind("column_one", 7)
                .bind("column_two", "Rebecca")
                .execute();
        assertEquals(1, count);

        final String name = h.createQuery("select name from something where id = 7")
                .map(StringMapper.FIRST)
                .first();
        assertEquals(name, "Rebecca");
    }
View Full Code Here


        assertEquals(name, "Rebecca");
    }

    public void testExtraDefinesDontBreakThings() throws Exception
    {
        final Handle h = openHandle();
        final int count = h.createStatement("tests:insert_one")
                .define("name", "Nicole")
                .execute();
        assertEquals(1, count);
    }
View Full Code Here

*/
public class TestQueryObjectGenerator extends DBITestCase
{
    public void testApiWhichTakesConnection() throws Exception
    {
        Handle h = openHandle();
        MyQueries qo = QueryObjectFactory.createQueryObject(MyQueries.class, h.getConnection());
        assertNotNull(qo);
    }
View Full Code Here

        assertNotNull(qo);
    }

    public void testApiWhichTakesDatasource() throws Exception
    {
        final Handle h = openHandle();
        MyQueries qo = QueryObjectFactory.createQueryObject(MyQueries.class, Tools.getDataSource());
        assertNotNull(qo);
    }
View Full Code Here

        List<Something> ds = q.getAllSomethings();

        assertNotNull(ds);
        Iterator<Something> i = ds.iterator();
        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
    }
View Full Code Here

        List<Something> ds = q.findByName("Keith");

        assertNotNull(ds);
        Iterator<Something> i = ds.iterator();
        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
    }
View Full Code Here

    {
        handle.insert("insert into something (id, name) values (?, ?)", 1, "Keith");
        Iterator<Something> i = q.ittyAll();

        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
        assertFalse(i.hasNext());
    }
View Full Code Here

    }

    public void testSingle() throws Exception
    {
        handle.insert("insert into something (id, name) values (?, ?)", 1, "Keith");
        Something s = q.findById(1);
        assertEquals("Keith", s.getName());
    }
View Full Code Here

    public void testInsert() throws Exception
    {
        assertEquals(true, q.insert(1, "Keith"));
        Iterator<Something> as = q.ittyAll();
        assertTrue(as.hasNext());
        Something s = as.next();
        assertEquals("Keith", s.getName());
        assertFalse(as.hasNext());
    }
View Full Code Here

    public void testUpdate() throws Exception
    {
        q.insert(1, "Keith");
        q.updateNameById("Eric", 1);
        Something s = q.findById(1);
        assertNotNull(s);
        assertEquals("Eric", s.getName());
    }
View Full Code Here

TOP

Related Classes of org.skife.jdbi.v2.DBI

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.