Examples of RewrittenStatement


Examples of org.skife.jdbi.v2.tweak.RewrittenStatement

    }


    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

Examples of org.skife.jdbi.v2.tweak.RewrittenStatement

        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

Examples of org.skife.jdbi.v2.tweak.RewrittenStatement

        assertEquals("? ':nope' _%&^& *@ ?", rws.getSql());
    }

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

Examples of org.skife.jdbi.v2.tweak.RewrittenStatement

        }
        catch (Exception e) {
            throw new UnableToCreateStatementException(String.format("Exception while locating statement for [%s]",
                                                                     sql), e);
        }
        final RewrittenStatement rewritten = rewriter.rewrite(my_sql, current.getParameters(), context);
        PreparedStatement stmt = null;
        try {
            try {
                stmt = connection.prepareStatement(rewritten.getSql());
            }
            catch (SQLException e) {
                throw new UnableToCreateStatementException(e);
            }

            try {
                for (PreparedBatchPart part : parts) {
                    rewritten.bind(part.getParameters(), stmt);
                    stmt.addBatch();
                }
            }
            catch (SQLException e) {
                throw new UnableToExecuteStatementException("Exception while binding parameters", e);
            }

            try {
                final long start = System.currentTimeMillis();
                final int[] rs =  stmt.executeBatch();
                log.logPreparedBatch(System.currentTimeMillis() - start,  rewritten.getSql(), parts.size());
                return rs;
            }
            catch (SQLException e) {
                throw new UnableToExecuteStatementException(e);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.