Package org.skife.jdbi.v2.sqlobject

Examples of org.skife.jdbi.v2.sqlobject.SqlStatementCustomizer


                {
                    return new ObjectArgument(descriptor.getReadMethod().invoke(bean));
                }
                catch (IllegalAccessException e)
                {
                    throw new UnableToCreateStatementException(String.format("Access excpetion invoking getter for " +
                                                                             "bean property [%s] on [%s]",
                                                                             name, bean), e);
                }
                catch (InvocationTargetException e)
                {
                    throw new UnableToCreateStatementException(String.format("Invocation target exception invoking " +
                                                                             "getter for bean property [%s] on [%s]",
                                                                             name, bean), e);
                }
            }
        }
View Full Code Here


    {
        try {
            return locator.locate(sql, this.getContext());
        }
        catch (Exception e) {
            throw new UnableToCreateStatementException("Exception thrown while looking for statement", e);
        }
    }
View Full Code Here

        try {
            try {
                stmt = statementBuilder.create(this.getConnection(), rewritten.getSql(), context);
            }
            catch (SQLException e) {
                throw new UnableToCreateStatementException(e);
            }

            try {
                rewritten.bind(getParameters(), stmt);
            }
View Full Code Here

                }
                t = lexer.nextToken();
            }
        }
        catch (TokenStreamException e) {
            throw new UnableToCreateStatementException("Exception parsing for named parameter replacement", e);
        }

        return new MyRewrittenStatement(b.toString(), stmt, ctx);
    }
View Full Code Here

                    try {
                        a.apply(i + 1, statement, this.context);
                    }
                    catch (SQLException e) {
                        throw new UnableToCreateStatementException(String.format("Exception while binding '%s'",
                                                                                 named_param), e);
                    }
                    i++;
                }
            }
View Full Code Here

        final String my_sql ;
        try {
            my_sql = locator.locate(sql, context);
        }
        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);
View Full Code Here

            try {
                rewritten.bind(getParameters(), stmt);
            }
            catch (SQLException e) {
                throw new UnableToExecuteStatementException("Unable to bind parameters to query", e);
            }

            try {
                prep.prepare(stmt);
            }
            catch (SQLException e) {
                throw new UnableToExecuteStatementException("Unable to prepare JDBC statement", e);
            }

            for (StatementCustomizer customizer : customizers) {
                try {
                    customizer.beforeExecution(stmt, context);
                }
                catch (SQLException e) {
                    throw new UnableToExecuteStatementException("Exception thrown in statement customization", e);
                }
            }

            try {
                final long start = System.currentTimeMillis();
                stmt.execute();
                log.logSQL(System.currentTimeMillis() - start,  rewritten.getSql());
            }
            catch (SQLException e) {
                throw new UnableToExecuteStatementException(e);
            }

            for (StatementCustomizer customizer : customizers) {
                try {
                    customizer.afterExecution(stmt, context);
                }
                catch (SQLException e) {
                    throw new UnableToExecuteStatementException("Exception thrown in statement customization", e);
                }
            }

            try {
                rs = stmt.getResultSet();
View Full Code Here

                    if (a != null) {
                        try {
                        a.apply(i + 1, statement, this.context);
                        }
                        catch (SQLException e) {
                            throw new UnableToExecuteStatementException(
                                    String.format("Excpetion while binding positional param at (0 based) position %d",
                                                  i), e);
                        }
                    }
                    else {
                        finished = true;
                    }
                }
            }
            else {
                //List<String> named_params = stmt.params;
                int i = 0;
                for (String named_param : stmt.params) {
                    if ("*".equals(named_param)) continue;
                    Argument a = params.forName(named_param);
                    if (a == null) {
                        a = params.forPosition(i);
                    }

                    if (a == null) {
                        String msg = String.format("Unable to execute, no named parameter matches " +
                                                   "\"%s\" and no positional param for place %d (which is %d in " +
                                                   "the JDBC 'start at 1' scheme) has been set.",
                                                   named_param, i, i + 1);
                        throw new UnableToExecuteStatementException(msg);
                    }

                    try {
                        a.apply(i + 1, statement, this.context);
                    }
View Full Code Here

                    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);
            }
        }
        finally {
            QueryPostMungeCleanup.CLOSE_RESOURCES_QUIETLY.cleanup(null, stmt, null);
            this.parts.clear();
View Full Code Here

        {
            script = locator.locate(name, ctx);
        }
        catch (Exception e)
        {
            throw new UnableToExecuteStatementException(String.format("Error while loading script [%s]", name), e);
        }

        final String[] statements = script.replaceAll("\n", " ").replaceAll("\r", "").split(";");
        Batch b = handle.createBatch();
        for (String s : statements)
View Full Code Here

TOP

Related Classes of org.skife.jdbi.v2.sqlobject.SqlStatementCustomizer

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.