当前位置: 首页>>代码示例>>Java>>正文


Java CallableStatementCallback类代码示例

本文整理汇总了Java中org.springframework.jdbc.core.CallableStatementCallback的典型用法代码示例。如果您正苦于以下问题:Java CallableStatementCallback类的具体用法?Java CallableStatementCallback怎么用?Java CallableStatementCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CallableStatementCallback类属于org.springframework.jdbc.core包,在下文中一共展示了CallableStatementCallback类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collect

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public void collect(String sql) {
	final int yesterday = DateUtil.systemDate(-1);//new RypCommon().getIntDate(-1);
	update("delete from tlog_collect where sys_date=" + yesterday);
	getJdbcTemplate().execute(sql, new CallableStatementCallback() {
		@Override
		public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
			cs.setString(1, yesterday + "");
			cs.execute();
			System.err.println("store procedure is finish");
			return null;
		}
	});
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:14,代码来源:SystemDao.java

示例2: dailyCollect

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public void dailyCollect(String sql) {
	getJdbcTemplate().execute(sql, new CallableStatementCallback() {
		@Override
		public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
			cs.execute();
			System.err.println("store procedure is finish");
			return null;
		}
	});
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:11,代码来源:SystemDao.java

示例3: executeBatch

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
@Override
public int[] executeBatch() throws SQLException {

    if (this.batchItems == null) {
        throw new IllegalArgumentException("Batch must have at least one item");
    }

    final Iterator<Map<String, ?>> params = batchItems.iterator();


    return factory.getJdbcTemplate().execute(new CallableStatementCreator() {
        @Override
        public CallableStatement createCallableStatement(Connection connection) throws SQLException {
            return batchFactory.newCallableStatementCreator(params.next()).createCallableStatement(connection);

        }
    }, new CallableStatementCallback<int[]>() {
        @Override
        public int[] doInCallableStatement(CallableStatement callableStatement) throws SQLException, DataAccessException {
            //add first item to batch
            callableStatement.addBatch();

            while (params.hasNext()) {
                batchFactory.addParameter(callableStatement, params.next());
                callableStatement.addBatch();
            }
            return callableStatement.executeBatch();
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:CallableStatementWrapper.java

示例4: getTofuTranslatedByUser

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public List<Map<String, ?>> getTofuTranslatedByUser(String uuid) {

        String sql = "{? = call core.f_tofu_translated_by_user(?)}";

        CustomCallableStatementCreator sc = new CustomCallableStatementCreator(sql) {
            public CallableStatement createCallableStatement(Connection con) throws SQLException {
                con.setAutoCommit(false);
                CallableStatement s = super.createCallableStatement(con);
                s.registerOutParameter(1, Types.OTHER);//cursor
                s.setString(2, uuid);
                return s;
            }
        };

        CallableStatementCallback<List<Map<String, ?>>> cb = s -> {
            s.execute();
            ResultSet rs = (ResultSet) s.getObject(1);

            List<Map<String, ?>> result = new ArrayList<>();

            while (rs.next()) {
                Map<String, Object> item = new HashMap<>();
                item.put("id", rs.getInt("id"));
                item.put("word", rs.getString("word"));
                item.put("sentence", rs.getString("sentence"));
                item.put("lang", rs.getString("lang"));
                item.put("translation", rs.getString("translation"));

                result.add(item);
            }
            return result;
        };
        return execute(sc, cb);
    }
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:35,代码来源:ReportDB.java

示例5: getTranslatedEntrRatio

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public List<Map<String, ?>> getTranslatedEntrRatio() {

        String sql = "{? = call public.f_jmet_entr_gloss_ratio()}";

        CustomCallableStatementCreator sc = new CustomCallableStatementCreator(sql) {
            public CallableStatement createCallableStatement(Connection con) throws SQLException {
                con.setAutoCommit(false);
                CallableStatement s = super.createCallableStatement(con);
                s.registerOutParameter(1, Types.OTHER);//cursor
                return s;
            }
        };

        CallableStatementCallback<List<Map<String, ?>>> cb = s -> {
            s.execute();
            ResultSet rs = (ResultSet) s.getObject(1);

            List<Map<String, ?>> result = new ArrayList<>();
            Map<String, Object> item;
            while (rs.next()) {
                item = new LinkedHashMap<>();

                item.put("countGloss", rs.getInt(1));
                item.put("sumCount", rs.getInt(2));
                item.put("sumRatio", rs.getFloat(3));

                result.add(item);
            }

            rs.close();
            return result;
        };
        return execute(sc, cb);
    }
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:35,代码来源:ReportDB.java

示例6: execute

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public <T> T execute(CallableStatementCreator csc,
    CallableStatementCallback<T> action) throws DataAccessException {
  return delegate.execute(csc, action);
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:5,代码来源:BatchJdbcTemplate.java

示例7: callProcedure

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public Object callProcedure(final String callStr, final Object[] inValues,
		final int[] outTypes) {
	return getJdbcTemplate().execute(callStr,
			new CallableStatementCallback() {
				@SuppressWarnings("unchecked")
				public Object doInCallableStatement(CallableStatement cs)
						throws SQLException {
					int i = 0;
					if (inValues != null) {
						for (int index = 0; index < inValues.length; index++) {
							i++;

							Object inValue = inValues[index];
							if (inValue instanceof StringBuffer
									|| inValue instanceof StringWriter) {
								cs.setString(i, inValue.toString());
							} else if ((inValue instanceof java.util.Date)
									&& !(inValue instanceof java.sql.Date
											|| inValue instanceof java.sql.Time || inValue instanceof java.sql.Timestamp)) {
								cs.setTimestamp(i, new java.sql.Timestamp(
										((java.util.Date) inValue)
												.getTime()));
							} else if (inValue instanceof Calendar) {
								Calendar cal = (Calendar) inValue;
								cs.setTimestamp(i, new java.sql.Timestamp(
										cal.getTime().getTime()));
							} else {
								// Fall back to generic setObject call
								// without SQL type specified.
								cs.setObject(i, inValue);
							}
						}
					}
					if (outTypes != null) {
						for (int index = 0; index < outTypes.length; index++) {
							i++;
							cs.registerOutParameter(i, outTypes[index]);
						}
					}

					boolean retVal = cs.execute();
					int updateCount = cs.getUpdateCount();

					if (retVal || updateCount != -1) {
						// Map returnedResults = new HashMap();
						// returnedResults.putAll(extractReturnedResultSets(cs,
						// declaredParameters, updateCount));
					}
					if (outTypes == null || outTypes.length <= 0) {
						return null;
					} else if (outTypes.length == 1) {
						return cs.getObject(i);
					} else {
						List results = new ArrayList();
						// 依次返回结果
						for (int index = 0; index < outTypes.length; index++) {
							results.add(cs.getObject(inValues.length
									+ index + 1));

						}
						return results;
					}

				}
			});
}
 
开发者ID:kider,项目名称:jbpm4ssh,代码行数:67,代码来源:AbstractDaoSupport.java

示例8: callFunction

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
public Object callFunction(final String callStr, final Object[] inValues,
		final int[] outTypes) {
	return getJdbcTemplate().execute(callStr,
			new CallableStatementCallback() {
				@SuppressWarnings("unchecked")
				public Object doInCallableStatement(CallableStatement cs)
						throws SQLException {
					int i = 0;
					if (outTypes != null) {
						for (int index = 0; index < outTypes.length; index++) {
							i++;
							cs.registerOutParameter(i, outTypes[index]);
						}
					}

					if (inValues != null) {
						for (int index = 0; index < inValues.length; index++) {
							i++;
							// StatementCreatorUtils.setParameterValue(cs,
							// i,
							// Integer.MIN_VALUE, null,
							// inValues[index]);
							Object inValue = inValues[index];
							if (inValue instanceof StringBuffer
									|| inValue instanceof StringWriter) {
								cs.setString(i, inValue.toString());
							} else if ((inValue instanceof java.util.Date)
									&& !(inValue instanceof java.sql.Date
											|| inValue instanceof java.sql.Time || inValue instanceof java.sql.Timestamp)) {
								cs.setTimestamp(i, new java.sql.Timestamp(
										((java.util.Date) inValue)
												.getTime()));
							} else if (inValue instanceof Calendar) {
								Calendar cal = (Calendar) inValue;
								cs.setTimestamp(i, new java.sql.Timestamp(
										cal.getTime().getTime()));
							} else {
								// Fall back to generic setObject call
								// without SQL type specified.
								cs.setObject(i, inValue);
							}
						}
					}

					boolean retVal = cs.execute();
					int updateCount = cs.getUpdateCount();

					if (retVal || updateCount != -1) {
						// Map returnedResults = new HashMap();
						// returnedResults.putAll(extractReturnedResultSets(cs,
						// declaredParameters, updateCount));
					}
					if (outTypes == null || outTypes.length <= 0) {
						return null;
					} else if (outTypes.length == 1) {
						return cs.getObject(1);
					} else {
						List results = new ArrayList();
						// 依次返回结果
						for (int index = 0; index < outTypes.length; index++) {
							results.add(cs.getObject(index + 1));

						}
						return results;
					}

				}
			});
}
 
开发者ID:kider,项目名称:jbpm4ssh,代码行数:70,代码来源:AbstractDaoSupport.java

示例9: execute

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
@Override
public <T> T execute(CallableStatementCreator csc, CallableStatementCallback<T> action) throws DataAccessException {

	return super.execute(csc, action);
}
 
开发者ID:gxianglong,项目名称:kratos-1,代码行数:6,代码来源:KratosJdbcTemplate.java

示例10: executePRC

import org.springframework.jdbc.core.CallableStatementCallback; //导入依赖的package包/类
/**
 *
 * 调用存储过程统一用这个方法
 */
public Object executePRC(String callString,CallableStatementCallback callback) {
    return getJdbcTemplate().execute(callString, callback);
}
 
开发者ID:jialiuyang,项目名称:appBack,代码行数:8,代码来源:BaseBusinessBO.java


注:本文中的org.springframework.jdbc.core.CallableStatementCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。