Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.PreparedStatementSetter


                           
                            //No row exists for the counter, insert it
                            if (!selected) {
                                value.initialize(initialValue);
                               
                                jdbcOperations.update(INSERT_QUERY, new PreparedStatementSetter() {
                                    @Override
                                    public void setValues(PreparedStatement ps) throws SQLException {
                                        ps.setString(1, counterName);
                                        value.bind(ps, 2);
                                    }
                                });
                            }
                           
                            //Increment the counter row value
                            final IntegralDataTypeHolder updateValue = value.copy();
                            if (optimizer.applyIncrementSizeToSourceValues()) {
                                updateValue.add(incrementSize);
                            }
                            else {
                                updateValue.increment();
                            }
                           
                            //Update the counter row, if rows returns 0 the update failed due to a race condition, it will be retried
                            rows = jdbcOperations.update(UPDATE_QUERY, new PreparedStatementSetter() {
                                @Override
                                public void setValues(PreparedStatement ps) throws SQLException {
                                    updateValue.bind(ps, 1);
                                    ps.setString(2, counterName);
                                    value.bind(ps, 3);
View Full Code Here


        new SqlParameter[] {
          new SqlParameter("from_id", Types.NUMERIC),
          new SqlParameter("to_id", Types.NUMERIC
        });
    reader.setPreparedStatementSetter(
        new PreparedStatementSetter() {
                    @Override
          public void setValues(PreparedStatement ps)
              throws SQLException {
            ps.setInt(1, 1000);
            ps.setInt(2, 1001);
View Full Code Here

    else {
      shortContext = serializedContext;
      longContext = null;
    }

    getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() {
      @Override
      public void setValues(PreparedStatement ps) throws SQLException {
        ps.setString(1, shortContext);
        if (longContext != null) {
          lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
View Full Code Here

    reader.setProcedureName("foo_bar");
    reader.setParameters(new SqlParameter[] {
        new SqlParameter("foo", Types.VARCHAR),
        new SqlParameter("bar", Types.OTHER)});
    reader.setPreparedStatementSetter(
        new PreparedStatementSetter() {
                    @Override
          public void setValues(PreparedStatement ps)
              throws SQLException {
          }
        });
View Full Code Here

                                    try {
                                        failedDatas.clear(); // 先清理
                                        processedDatas.clear();
                                        interceptor.transactionBegin(context, Arrays.asList(data), dbDialect);
                                        JdbcTemplate template = dbDialect.getJdbcTemplate();
                                        int affect = template.update(data.getSql(), new PreparedStatementSetter() {

                                            public void setValues(PreparedStatement ps) throws SQLException {
                                                doPreparedStatement(ps, dbDialect, lobCreator, data);
                                            }
                                        });
View Full Code Here

                                    try {
                                        failedDatas.clear(); // 先清理
                                        processedDatas.clear();
                                        interceptor.transactionBegin(context, Arrays.asList(data), dbDialect);
                                        JdbcTemplate template = dbDialect.getJdbcTemplate();
                                        int affect = template.update(data.getSql(), new PreparedStatementSetter() {

                                            public void setValues(PreparedStatement ps) throws SQLException {
                                                doPreparedStatement(ps, dbDialect, lobCreator, data);
                                            }
                                        });
View Full Code Here

                                    try {
                                        failedDatas.clear(); // 先清理
                                        processedDatas.clear();
                                        interceptor.transactionBegin(context, Arrays.asList(data), dbDialect);
                                        JdbcTemplate template = dbDialect.getJdbcTemplate();
                                        int affect = template.update(data.getSql(), new PreparedStatementSetter() {

                                            public void setValues(PreparedStatement ps) throws SQLException {
                                                doPreparedStatement(ps, dbDialect, lobCreator, data);
                                            }
                                        });
View Full Code Here

      log.debug("sql = [" + sqlInfo.sql + "], args = " + Arrays.asList(sqlInfo.args));
    }
    long beforeUpdateSlaveDBTime = System.currentTimeMillis();

    if(DBType.ORACLE.equals(slave.getDbType())){ //TODO �����и��ٶ������ⶼ��Oracle
    PreparedStatementSetter pss = getPss(context.getMasterLogicTableName(), sqlInfo.args, sqlInfo.argNames);
    if (slave.getJdbcTemplate().update(sqlInfo.sql, pss) != 0) {
      Monitor.add(Monitor.KEY1, Monitor.KEY2_SYNC, Monitor.KEY3_UpdateSlaveRow_dup_all, 0, 1); //�ظ�ͬ������
      return System.currentTimeMillis() - beforeUpdateSlaveDBTime;
    }
    }else{//MYSQL���������ݿ⡣��������Oracle�ֿ���Mysqlʱ����Oracle��meta���÷ֿ��setObject3��������
View Full Code Here

                return new Movie(resultSet.getInt(1), resultSet.getString(2), resultSet.getString(3));
            }
        });

        for (final Movie movie : movieList) {
            List<Actor> actorList = jdbcTemplate.query(moviesSql, new PreparedStatementSetter() {
                        @Override
                        public void setValues(PreparedStatement preparedStatement) throws SQLException {
                            preparedStatement.setString(1, String.valueOf(movie.getId()));
                        }
                    }, new RowMapper<Actor>() {
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.PreparedStatementSetter

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.