Package org.skife.jdbi.v2

Examples of org.skife.jdbi.v2.DBI


        assertFalse(q.ittyAll().hasNext());
    }

    public void testBeanBinding() throws Exception
    {
        Something s = new Something(1, "Keith");
        q.insert(s);

        s = q.findById(1);
        assertNotNull(s);
        assertEquals("Keith", s.getName());

    }
View Full Code Here


                {
                    return Tools.getConnection();
                }
                catch (SQLException e)
                {
                    throw new UnableToObtainConnectionException(e);
                }
            }
        });
        Handle h = dbi.open();
        assertNotNull(h);
View Full Code Here

                                        getStatementLocator(),
                                        new CachingStatementBuilder(new DefaultStatementBuilder()),
                                        new ColonPrefixNamedParamStatementRewriter(),
                                        conn,
                                        new HashMap<String, Object>(),
                                        new NoOpLog());
        handles.add(h);
        return h;
    }
View Full Code Here

        h.close();
    }

    public void testConnectionFactoryCtor() throws Exception
    {
        DBI dbi = new DBI(new ConnectionFactory()
        {
            public Connection openConnection()
            {
                try
                {
View Full Code Here

        h.close();
    }

    public void testCorrectExceptionOnSQLException() throws Exception
    {
        DBI dbi = new DBI(new ConnectionFactory()
        {
            public Connection openConnection() throws SQLException
            {
                throw new SQLException();
            }
View Full Code Here

    }


    public void testNewlinesOkay() throws Exception
    {
        RewrittenStatement rws = rw.rewrite("select * from something\n where id = :id", new Binding(),
                                            new StatementContext(new HashMap<String, Object>()));
        assertEquals("select * from something\n where id = ?", rws.getSql());
    }
View Full Code Here

        assertEquals("select * from something\n where id = ?", rws.getSql());
    }

    public void testOddCharacters() throws Exception
    {
        RewrittenStatement rws = rw.rewrite(":boo ':nope' _%&^& *@ :id", new Binding(),
                                            new StatementContext(new HashMap<String, Object>()));
        assertEquals("? ':nope' _%&^& *@ ?", rws.getSql());
    }
View Full Code Here

    }

    public void testFoo() throws Exception
    {
        Handle h = openHandle();
        h.setStatementLocator(new StatementLocator() {

            public String locate(String name, StatementContext ctx) throws Exception
            {
                return name.replaceAll("<table>", String.valueOf(ctx.getAttribute("table")));
            }
View Full Code Here

        return h;
    }

    protected TransactionHandler getTransactionHandler()
    {
        return new LocalTransactionHandler();
    }
View Full Code Here

        h.begin();

        h.insert("insert into something (id, name) values (:id, :name)", 1, "Tom");
        h.checkpoint("first");
        h.insert("insert into something (id, name) values (:id, :name)", 1, "Martin");
        assertEquals(Integer.valueOf(2), h.createQuery("select count(*) from something").map(new IntegerMapper()).first());
        h.rollback("first");
        assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").map(new IntegerMapper()).first());
        h.commit();
        assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").map(new IntegerMapper()).first());
    }
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.