Package org.skife.jdbi.v2.exceptions

Examples of org.skife.jdbi.v2.exceptions.CallbackFailedException


     *
     * @return modified query
     */
    public Query<ResultType> setMaxFieldSize(final int i)
    {
        this.addStatementCustomizer(new StatementCustomizer()
        {
            public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException
            {
                stmt.setMaxFieldSize(i);
            }
View Full Code Here


     *
     * @return the modified query
     */
    public Query<ResultType> fetchReverse()
    {
        this.addStatementCustomizer(new StatementCustomizer()
        {
            public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException
            {
                stmt.setFetchDirection(ResultSet.FETCH_REVERSE);
            }
View Full Code Here

     *
     * @return the modified query
     */
    public Query<ResultType> fetchForward()
    {
        this.addStatementCustomizer(new StatementCustomizer()
        {
            public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException
            {
                stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
            }
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

                return super.prepareStatement(s);
            }
        };
        CachingStatementBuilder builder = new CachingStatementBuilder(new DefaultStatementBuilder());

        BasicHandle h = new BasicHandle(new LocalTransactionHandler(),
                                        new ClasspathStatementLocator(),
                                        builder,
                                        new ColonPrefixNamedParamStatementRewriter(),
                                        c,
                                        new HashMap<String, Object>(),
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

            fail("unexpected exception");
        }

        final Handle h = DBI.open(derby);

        int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();

        assertEquals(0, count);
        h.close();
    }
View Full Code Here

                            public void call(IDBI inner)
                            {
                                final Handle h = DBIUtil.getHandle(inner);
                                h.insert("insert into something (id, name) values (8, 'ignored again')");

                                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                                assertEquals(2, count);
                                throw new ForceRollback();
                            }
                        });
                        fail("should have thrown an exception");
                    }
                    catch (ForceRollback e) {
                        assertTrue(true);
                    }
                    int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                    assertEquals(1, count);
                    throw new ForceRollback();
                }
            });
            fail("should have thrown an exception");
        }
        catch (ForceRollback e) {
            assertTrue(true);
        }

        service.inPropagationRequired(new Callback()
        {
            public void call(IDBI dbi)
            {
                final Handle h = DBIUtil.getHandle(dbi);
                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                assertEquals(0, count);
            }
        });
    }
View Full Code Here

                    service.inRequiresNewReadUncommitted(new Callback()
                    {
                        public void call(IDBI inner)
                        {
                            final Handle h = DBIUtil.getHandle(inner);
                            int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                            assertEquals(1, count);
                            h.insert("insert into something (id, name) values (8, 'ignored again')");
                            throw new ForceRollback();
                        }
                    });
                }
                catch (ForceRollback e) {
                    assertTrue(true);
                }

                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                assertEquals(1, count);
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.skife.jdbi.v2.exceptions.CallbackFailedException

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.