Package org.skife.jdbi.v2

Examples of org.skife.jdbi.v2.VoidTransactionCallback


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


            public void close()
            {
            }
        });
        h.setSQLLog(new Log4JLog());
        Logger.getLogger("org.skife.jdbi").setLevel(Level.DEBUG);

        String sql1 = "insert into something (id, name) values (1, 'Eric')";
        String sql2 = "insert into something (id, name) values (2, 'Keith')";
        h.createBatch().add(sql1).add(sql2).execute();
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

                                        new ClasspathStatementLocator(),
                                        builder,
                                        new ColonPrefixNamedParamStatementRewriter(),
                                        c,
                                        new HashMap<String, Object>(),
                                        new NoOpLog());

        h.createStatement("insert into something (id, name) values (:id, :name)")
                .bindFromProperties(new Something(0, "Keith"))
                .execute();
View Full Code Here

    }

    public void testPrintStream() throws Exception
    {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        h.setSQLLog(new PrintStreamLog(new PrintStream(bout)));
        String sql = "insert into something (id, name) values (?, ?)";
        h.insert(sql, 1, "Brian");

        assertTrue(new String(bout.toByteArray())
                .matches("statement:\\[insert into something \\(id, name\\) values \\(\\?, \\?\\)\\] took \\d+ millis\n"));
View Full Code Here

        }

        public void bind(Binding params, PreparedStatement statement) throws SQLException
        {
            for (int i = 0; ; i++) {
                final Argument s = params.forPosition(i);
                if (s == null) { break; }
                s.apply(i + 1, statement, this.context);
            }
        }
View Full Code Here

        }
        else
        {
            for (LazyArguments arguments : lazyArguments)
            {
                Argument arg = arguments.find(name);
                if (arg != null)
                {
                    return arg;
                }
            }
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

TOP

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

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.