本文整理汇总了Java中org.springframework.jdbc.core.StatementCreatorUtils类的典型用法代码示例。如果您正苦于以下问题:Java StatementCreatorUtils类的具体用法?Java StatementCreatorUtils怎么用?Java StatementCreatorUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatementCreatorUtils类属于org.springframework.jdbc.core包,在下文中一共展示了StatementCreatorUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCursorForJoin
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
@Override
public String getCursorForJoin(List<String> tables, List<String> columnNames, String from,
String where, List<String> order, Boolean ascending, int limit) {
List<? super Object> args = new ArrayList<>();
where = convertToPreparedStatement(where, args);
String sql = sqlGenerator.constructSelectJoin(tables, columnNames, from, where, order, ascending, limit);
try {
PreparedStatement pstmt = getPreparedStatementForCursor(sql);
for (int i = 0; i < args.size(); i++) {
StatementCreatorUtils.setParameterValue(pstmt, i + 1, SqlTypeValue.TYPE_UNKNOWN, args.get(i));
}
ResultSet rs = pstmt.executeQuery();
String uuid = IDGenerator.getUUID();
cache.putCursor(uuid, rs);
return uuid;
} catch (SQLException e) {
throw RaptureExceptionFactory.create(String.format("Sql Exception executing cursor for joined query [%s]", e.getMessage()));
}
}
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:20,代码来源:JDBCStructuredStore.java
示例2: saveProcess
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public void saveProcess(final Process process) {
super.saveProcess(process);
if(process.getBytes() != null) {
template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
throws SQLException, DataAccessException {
try {
lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
开发者ID:snakerflow,项目名称:snakerflow,代码行数:18,代码来源:SpringJdbcAccess.java
示例3: updateProcess
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public void updateProcess(final Process process) {
super.updateProcess(process);
if(process.getBytes() != null) {
template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
throws SQLException, DataAccessException {
try {
lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
开发者ID:snakerflow,项目名称:snakerflow,代码行数:18,代码来源:SpringJdbcAccess.java
示例4: update
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public static KeyHolder update(JdbcOperations dbop,final String sql,final Object[] args,final String[] retCols)
{
KeyHolder kh=new GeneratedKeyHolder();
dbop.update(new PreparedStatementCreator()
{
public PreparedStatement createPreparedStatement(Connection con) throws SQLException
{
int i=1;
PreparedStatement ps;
ps=con.prepareStatement(sql,retCols);
for(Object o:args)
{
StatementCreatorUtils.setParameterValue(ps, i++, SqlTypeValue.TYPE_UNKNOWN, o);
}
return ps;
}
}, kh);
return kh;
}
开发者ID:zhanggh,项目名称:mtools,代码行数:20,代码来源:DBUtil.java
示例5: buildInsert
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public String buildInsert(boolean underscore,String tab,List ls)
{
int i,num=0;
StringBuilder sql=new StringBuilder();
sql.append("insert into ").append(tab).append("(");
for(PropertyDescriptor pd:pdas)
{
String colName=pd.getName();
if(pd.getName().equals("class")) continue;
if(underscore) colName=underscoreName(colName);
ls.add(new Integer(StatementCreatorUtils.javaTypeToSqlParameterType(pd.getPropertyType())));
sql.append(colName).append(",");
num++;
}
sql.setCharAt(sql.length()-1,')');
sql.append(" values (");
for(i=0;i<num;++i) sql.append("?,");
sql.setCharAt(sql.length()-1,')');
return sql.toString();
}
开发者ID:zhanggh,项目名称:mtools,代码行数:21,代码来源:DBUtil.java
示例6: getSqlType
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
/**
* Derives a default SQL type from the corresponding property type.
* @see org.springframework.jdbc.core.StatementCreatorUtils#javaTypeToSqlParameterType
*/
@Override
public int getSqlType(String paramName) {
int sqlType = super.getSqlType(paramName);
if (sqlType != TYPE_UNKNOWN) {
return sqlType;
}
Class<?> propType = this.beanWrapper.getPropertyType(paramName);
return StatementCreatorUtils.javaTypeToSqlParameterType(propType);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:BeanPropertySqlParameterSource.java
示例7: setParameterValues
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
/**
* Internal implementation for setting parameter values
* @param preparedStatement the PreparedStatement
* @param values the values to be set
*/
private void setParameterValues(PreparedStatement preparedStatement, List<Object> values, int[] columnTypes)
throws SQLException {
int colIndex = 0;
for (Object value : values) {
colIndex++;
if (columnTypes == null || colIndex > columnTypes.length) {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, SqlTypeValue.TYPE_UNKNOWN, value);
}
else {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, columnTypes[colIndex - 1], value);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AbstractJdbcInsert.java
示例8: doPreparedStatement
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
private void doPreparedStatement(PreparedStatement ps, final DbDialect dbDialect, final Integer[] columnTypes,
final String[] columnValues) throws SQLException {
LobCreator lobCreator = null;
for (int i = 0; i < columnTypes.length; i++) {
int paramIndex = i + 1;
String sqlValue = columnValues[i];
int sqlType = columnTypes[i];
Object param = SqlUtils.stringToSqlValue(sqlValue,
sqlType,
SqlUtils.isTextType(sqlType),
dbDialect.isEmptyStringNulled());
switch (sqlType) {
case Types.CLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setClobAsString(ps, paramIndex, (String) param);
break;
case Types.BLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) param);
break;
case Types.TIME:
case Types.TIMESTAMP:
case Types.DATE:
ps.setObject(paramIndex, sqlValue);
break;
default:
StatementCreatorUtils.setParameterValue(ps, paramIndex, sqlType, null, param);
break;
}
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:39,代码来源:BitTableIntegration.java
示例9: doPreparedStatement
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
private void doPreparedStatement(PreparedStatement ps, final DbDialect dbDialect, final Integer[] columnTypes,
final String[] columnValues) throws SQLException {
LobCreator lobCreator = null;
for (int i = 0; i < columnTypes.length; i++) {
int paramIndex = i + 1;
String sqlValue = columnValues[i];
int sqlType = columnTypes[i];
Object param = SqlUtils.stringToSqlValue(sqlValue,
sqlType,
SqlUtils.isTextType(sqlType),
dbDialect.isEmptyStringNulled());
switch (sqlType) {
case Types.CLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setClobAsString(ps, paramIndex, (String) param);
break;
case Types.BLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) param);
break;
default:
StatementCreatorUtils.setParameterValue(ps, paramIndex, sqlType, null, param);
break;
}
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:35,代码来源:DbDialectTest.java
示例10: doPreparedStatement
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
private void doPreparedStatement(PreparedStatement ps, final DbDialect dbDialect, final Integer[] columnTypes,
final String[] columnValues) throws SQLException {
LobCreator lobCreator = null;
for (int i = 0; i < columnTypes.length; i++) {
int paramIndex = i + 1;
String sqlValue = columnValues[i];
int sqlType = columnTypes[i];
Object param = SqlUtils.stringToSqlValue(sqlValue, sqlType, SqlUtils.isTextType(sqlType),
dbDialect.isEmptyStringNulled());
switch (sqlType) {
case Types.CLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setClobAsString(ps, paramIndex, (String) param);
break;
case Types.BLOB:
if (lobCreator == null) {
lobCreator = dbDialect.getLobHandler().getLobCreator();
}
lobCreator.setBlobAsBytes(ps, paramIndex, (byte[]) param);
break;
default:
StatementCreatorUtils.setParameterValue(ps, paramIndex, sqlType, null, param);
break;
}
}
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:33,代码来源:DbDialectIntegration.java
示例11: setParameterValues
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
/**
* Internal implementation for setting parameter values
* @param preparedStatement the PreparedStatement
* @param values the values to be set
*/
private void setParameterValues(PreparedStatement preparedStatement, List<?> values, int... columnTypes)
throws SQLException {
int colIndex = 0;
for (Object value : values) {
colIndex++;
if (columnTypes == null || colIndex > columnTypes.length) {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, SqlTypeValue.TYPE_UNKNOWN, value);
}
else {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, columnTypes[colIndex - 1], value);
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AbstractJdbcInsert.java
示例12: getSqlType
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
/***
* @param paramName 数据库字段名称
* @return
*/
@Override
public int getSqlType(String paramName) {
String propertyName = dbFieldNameMap.get(paramName).getFieldName();
int sqlType = super.getSqlType(propertyName);
if (sqlType != TYPE_UNKNOWN) {
return sqlType;
}
Class<?> propType = this.beanWrapper.getPropertyType(propertyName);
return StatementCreatorUtils.javaTypeToSqlParameterType(propType);
}
开发者ID:thinking-github,项目名称:nbone,代码行数:15,代码来源:EntityPropertySqlParameterSource.java
示例13: setParameters
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setParameters(PreparedStatement ps) throws SQLException {
try {
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
if (parameterMappings != null) {
int paramMappingSize = parameterMappings.size();
for (int i = 0; i < paramMappingSize; i++) {
ParameterMapping parameterMapping = parameterMappings.get(i);
Object value;
String propertyName = parameterMapping.getProperty();
if (boundSql.hasAdditionalParameter(propertyName)) {
value = boundSql.getAdditionalParameter(propertyName);
} else if (parameterObject == null) {
value = "";
} else {
Class<?> type = parameterObject.getClass();
boolean isPrimitive = isColumnType(type);
if (isPrimitive) {
value = parameterObject;
} else {
MetaObject metaObject = configuration.newMetaObject(parameterObject);
value = metaObject.getValue(propertyName);
}
}
StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, value);
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new SQLException(e.getMessage(), e);
}
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:33,代码来源:DefaultParameterHandler.java
示例14: addParameter
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public void addParameter(CallableStatement callableStatement, Map batchRow) throws SQLException {
int i = 1;
for (SqlParameter parameter : getSqlParameterList()) {
StatementCreatorUtils.setParameterValue(callableStatement, i, parameter, batchRow.get(parameter.getName()));
i++;
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:BatchCallableStatementCreatorFactory.java
示例15: call
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
@Override
public int[] call() throws Exception {
JdbcTemplate jdbcTemplate = createJdbcTemplate(shard.getTargetDataSource(), ShardJdbcTemplate.this);
String interceptedSql = shardDataSource.getSqlInterceptor().intercept(sql, shard.getTableContext());
return jdbcTemplate.batchUpdate(interceptedSql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int statementIndex) throws SQLException {
Object[] args = argsList.get(statementIndex);
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (arg instanceof SqlParameterValue) {
SqlParameterValue paramValue = (SqlParameterValue) arg;
StatementCreatorUtils.setParameterValue(ps, i + 1, paramValue, paramValue.getValue());
}
else {
StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, arg);
}
}
}
@Override
public int getBatchSize() {
return argsList.size();
}
});
}
开发者ID:sogou-biztech,项目名称:compass,代码行数:30,代码来源:ShardJdbcTemplate.java
示例16: setValues
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
@Override
public void setValues(String[] item, PreparedStatement ps) throws SQLException {
Assert.isInstanceOf(String[].class, item, "Input to map PreparedStatement parameters must be of type String[].");
System.out.println(String.join(",", item));
for(int i=0; i<item.length; i++ ){
StatementCreatorUtils.setParameterValue(ps, i+1, SqlTypeValue.TYPE_UNKNOWN, item[i]);
}
}
开发者ID:MIABIS,项目名称:miabis-converter,代码行数:10,代码来源:ArrayItemPreparedStatementSetter.java
示例17: getParameterType
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
private static int getParameterType(PropertyMapping<?, ?, JdbcColumnKey, FieldMapperColumnDefinition<JdbcColumnKey>> pm) {
Class<?> propertyType = TypeHelper.toClass(pm.getPropertyMeta().getPropertyType());
if (pm.getColumnDefinition().has(SqlTypeColumnProperty.class)) {
return pm.getColumnDefinition().lookFor(SqlTypeColumnProperty.class).getSqlType();
}
int t = StatementCreatorUtils.javaTypeToSqlParameterType(propertyType);
if (t == SqlTypeValue.TYPE_UNKNOWN) {
//IFJAVA8_START
if (propertyType.equals(ZonedDateTime.class) || propertyType.equals(OffsetDateTime.class)) {
return Types.TIMESTAMP_WITH_TIMEZONE;
}
if (propertyType.equals(Instant.class) || propertyType.equals(LocalDateTime.class)) {
return Types.TIMESTAMP;
}
if (propertyType.equals(LocalDate.class)) {
return Types.DATE;
}
if (propertyType.equals(LocalTime.class)) {
return Types.TIME;
}
//IFJAVA8_END
return JdbcColumnKey.UNDEFINED_TYPE;
}
return t;
}
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:32,代码来源:SqlParameterSourceBuilder.java
示例18: setValues
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
public static int setValues(PreparedStatement ps, Object[] args, int startIndex) throws SQLException {
int j = startIndex;
if (args != null) {
for (int i = 0; i < args.length; i++, j++) {
Object arg = args[i];
if (arg instanceof SqlParameterValue) {
SqlParameterValue paramValue = (SqlParameterValue) arg;
StatementCreatorUtils.setParameterValue(ps, j, paramValue, paramValue.getValue());
} else {
StatementCreatorUtils.setParameterValue(ps, j, Types.OTHER, arg);
}
}
}
return j;
}
开发者ID:nortal,项目名称:petit,代码行数:16,代码来源:ArgPreparedStatementSetter.java
示例19: getSqlType
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
/**
* Derives a default SQL type from the corresponding property type.
* @see org.springframework.jdbc.core.StatementCreatorUtils#javaTypeToSqlParameterType
*/
@Override
public int getSqlType(String paramName) {
int sqlType = super.getSqlType(paramName);
if (sqlType != TYPE_UNKNOWN) {
return sqlType;
}
Class propType = this.beanWrapper.getPropertyType(paramName);
return StatementCreatorUtils.javaTypeToSqlParameterType(propType);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:BeanPropertySqlParameterSource.java
示例20: setValues
import org.springframework.jdbc.core.StatementCreatorUtils; //导入依赖的package包/类
@Override
public synchronized void setValues(PreparedStatement sPs) throws SQLException {
try {
String aResolvedValue;
for(int i = 0; i < lookupFieldsExpressions.length; i++) {
aResolvedValue = getExpressionResolver().evaluate(lookupFieldsExpressions[i], getEvaluationContext(), String.class);
StatementCreatorUtils.setParameterValue(sPs, i + 1, SqlTypeValue.TYPE_UNKNOWN, aResolvedValue);
}
} catch (Exception e) {
throw new SQLException(new PreparedStatementCreationException(e));
}
}
开发者ID:acxio,项目名称:AGIA,代码行数:13,代码来源:ExpressionsPreparedStatementSetter.java
注:本文中的org.springframework.jdbc.core.StatementCreatorUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论