Package org.skife.jdbi.v2.tweak

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


        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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


        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        Map<String, String> primaryKeys = table.getColumns();
        StringBuilder builder = new StringBuilder(" SET ");

        for (Map.Entry<String, String> entry : primaryKeys.entrySet()) {
            String input = entry.getKey();
            Argument argument = params.forName(input);
            if (argument != null && !"null".equals(argument.toString())) {
                builder.append(entry.getValue()).append(" = :").append(input).append(" , ");
            }
        }
        String set = builder.substring(0, builder.length() - 2);
        return clause.concat(set);
View Full Code Here

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

        public void bind(Binding params, PreparedStatement statement) throws SQLException {
            if (stmt.positionalOnly) {
                // no named params, is easy
                boolean finished = false;
                for (int i = 0; !finished; ++i) {
                    final Argument a = params.forPosition(i);
                    if (a != null) {
                        try {
                            a.apply(i + 1, statement, this.context);
                        } catch(SQLException e) {
                            throw new UnableToExecuteStatementException(String.format("Exception while binding positional param at (0 based) position %d", i), e, context);
                        }
                    } 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, context);
                    }

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

TOP

Related Classes of org.skife.jdbi.v2.tweak.Argument

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.