Java 类org.springframework.jdbc.core.StatementCreatorUtils 实例源码

项目:Rapture    文件:JDBCStructuredStore.java   
@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()));
    }
}
项目:snakerflow    文件:SpringJdbcAccess.java   
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();
                }
            }
        });
    }
}
项目:snakerflow    文件:SpringJdbcAccess.java   
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();
                }
            }
        });
    }
}
项目:mtools    文件:DBUtil.java   
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;
}
项目:mtools    文件:DBUtil.java   
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();
}
项目:lams    文件:BeanPropertySqlParameterSource.java   
/**
 * 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);
}
项目:lams    文件:AbstractJdbcInsert.java   
/**
 * 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);
        }
    }
}
项目:otter-G    文件:BitTableIntegration.java   
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;
        }
    }
}
项目:otter-G    文件:TimeTableIntegration.java   
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;
        }
    }
}
项目:otter-G    文件:DbDialectTest.java   
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;
        }
    }
}
项目:otter-G    文件:DbDialectIntegration.java   
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;
        }
    }
}
项目:spring4-understanding    文件:BeanPropertySqlParameterSource.java   
/**
 * 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);
}
项目:spring4-understanding    文件:AbstractJdbcInsert.java   
/**
 * 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);
        }
    }
}
项目:nbone    文件:AbstractJdbcInsert.java   
/**
 * 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);
        }
    }
}
项目:nbone    文件:EntityPropertySqlParameterSource.java   
/***
    * @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);
}
项目:rabbitframework    文件:DefaultParameterHandler.java   
@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);
    }
}
项目:Camel    文件:BatchCallableStatementCreatorFactory.java   
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++;
    }
}
项目:compass    文件:ShardJdbcTemplate.java   
@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();
    }
});
     }
项目:miabis-converter    文件:ArrayItemPreparedStatementSetter.java   
@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]);
    }
}
项目:SimpleFlatMapper    文件:SqlParameterSourceBuilder.java   
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;
}
项目:petit    文件:ArgPreparedStatementSetter.java   
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;
}
项目:class-guard    文件:BeanPropertySqlParameterSource.java   
/**
 * 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);
}
项目:class-guard    文件:AbstractJdbcInsert.java   
/**
 * 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);
        }
    }
}
项目:AGIA    文件:ExpressionsPreparedStatementSetter.java   
@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));
    }
}
项目:mtools    文件:DBUtil.java   
public String buildUpdate(boolean underscore,String tab,List ls)
{
    List kvl=null;
    StringBuilder where=null;       
    StringBuilder sql=new StringBuilder();
    sql.append("update ").append(tab).append(" set ");
    if(keys!=null)
    {
        where=new StringBuilder();
        where.append("where ");
        kvl=new Vector();
    }
    for(PropertyDescriptor pd:pdas)
    {
        String colName=pd.getName();
        if(pd.getName().equals("class")) continue;
        if(underscore) colName=underscoreName(colName);
        if(keys!=null)
        {
            for(String kname:keys)
            {
                if(kname.equalsIgnoreCase(colName))
                {
                    kvl.add(StatementCreatorUtils.javaTypeToSqlParameterType(pd.getPropertyType()));
                    where.append(kname).append("=? and ");
                }
            }
        }
        ls.add(StatementCreatorUtils.javaTypeToSqlParameterType(pd.getPropertyType()));
        sql.append(colName).append("=?,");
    }
    sql.setCharAt(sql.length()-1,' ');
    if(where!=null&&where.length()>5)
    {
        where.delete(where.length()-3, where.length());
        sql.append(where);
    }
    if(kvl!=null) ls.addAll(kvl);
    return sql.toString();
}
项目:sqltemplate    文件:BatchArgsParameter.java   
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
    Object[] params = batchParams[i];

    int colIndex = 0;
    for (Object param : params) {
        colIndex++;
        StatementCreatorUtils.setParameterValue(ps, colIndex, SqlTypeValue.TYPE_UNKNOWN,
                Jsr310JdbcUtils.convertIfNecessary(param, zoneId));
    }
}
项目:sqltemplate    文件:SingleColumnBatchArgsParameter.java   
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
    Object param = batchParams[i];

    StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN,
            Jsr310JdbcUtils.convertIfNecessary(param, zoneId));
}
项目:sqltemplate    文件:Jsr310JdbcUtils.java   
public static int getSqlType(Class<?> type) {
    int sqlType = StatementCreatorUtils.javaTypeToSqlParameterType(type);
    if (sqlType != SqlTypeValue.TYPE_UNKNOWN) {
        return sqlType;
    }

    if (LocalDate.class.isAssignableFrom(type)) {
        return Types.DATE;
    }
    if (LocalDateTime.class.isAssignableFrom(type)) {
        return Types.TIMESTAMP;
    }
    if (LocalTime.class.isAssignableFrom(type)) {
        return Types.TIME;
    }
    if (ZonedDateTime.class.isAssignableFrom(type)) {
        return Types.TIMESTAMP;
    }
    if (OffsetDateTime.class.isAssignableFrom(type)) {
        return Types.TIMESTAMP;
    }
    if (OffsetTime.class.isAssignableFrom(type)) {
        return Types.TIME;
    }

    return SqlTypeValue.TYPE_UNKNOWN;

}
项目:qb-core    文件:RmJdbcTemplate.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                if(this.argTypes[i] == Types.BLOB) {
                    byte[] bytes = (byte[])this.args[i];
                    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                    ps.setBinaryStream(argIndx++, bais, bytes.length);
                } else {
                    StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
                }
            }
        }
    }
}
项目:qb-core    文件:ArgTypePreparedStatementSetter.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
            }
        }
    }
}
项目:otter    文件:BitTableIntegration.java   
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;
        }
    }
}
项目:otter    文件:TimeTableIntegration.java   
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;
        }
    }
}
项目:otter    文件:DbDialectTest.java   
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;
        }
    }
}
项目:otter    文件:DbDialectIntegration.java   
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;
        }
    }
}
项目:javasec    文件:RmJdbcTemplate.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                if(this.argTypes[i] == Types.BLOB) {
                    byte[] bytes = (byte[])this.args[i];
                    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                    ps.setBinaryStream(argIndx++, bais, bytes.length);
                } else {
                    StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
                }
            }
        }
    }
}
项目:javasec    文件:ArgTypePreparedStatementSetter.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
            }
        }
    }
}
项目:java-lib    文件:RmJdbcTemplate.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                if(this.argTypes[i] == Types.BLOB) {
                    ByteArrayInputStream bais = new ByteArrayInputStream((byte[])this.args[i]);
                    ps.setBinaryStream(argIndx++, bais);
                } else {
                    StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
                }
            }
        }
    }
}
项目:java-lib    文件:ArgTypePreparedStatementSetter.java   
public void setValues(PreparedStatement ps) throws SQLException {
    int argIndx = 1;
    if (this.args != null) {
        for (int i = 0; i < this.args.length; i++) {
            Object arg = this.args[i];
            if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
                Collection entries = (Collection) arg;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    Object entry = it.next();
                    if (entry instanceof Object[]) {
                        Object[] valueArray = ((Object[])entry);
                        for (int k = 0; k < valueArray.length; k++) {
                            Object argValue = valueArray[k];
                            StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue);
                        }
                    }
                    else {
                        StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry);
                    }
                }
            }
            else {
                StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg);
            }
        }
    }
}
项目:spring-jdbc-oracle    文件:AbstractComparisonIntegrationTest.java   
@Override
protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLException {
  if (i >= this.values.length) {
    return false;
  }

  StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN, "INSERT");
  StatementCreatorUtils.setParameterValue(ps, 2, SqlTypeValue.TYPE_UNKNOWN, this.values[i]);

  return true;
}
项目:spring-jdbc-oracle    文件:TestInterruptiblePreparedStatementSetter.java   
@Override
protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLException {
  if (i >= this.parameters.length) {
    return false;
  }

  StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN, Integer.MAX_VALUE);
  StatementCreatorUtils.setParameterValue(ps, 2, SqlTypeValue.TYPE_UNKNOWN, this.parameters[i]);

  return true;
}