Example usage for org.springframework.jdbc.core SqlParameter getTypeName

List of usage examples for org.springframework.jdbc.core SqlParameter getTypeName

Introduction

In this page you can find the example usage for org.springframework.jdbc.core SqlParameter getTypeName.

Prototype

@Nullable
public String getTypeName() 

Source Link

Document

Return the type name of the parameter, if any.

Usage

From source file:org.hxzon.util.db.springjdbc.StatementCreatorUtils.java

/**
 * Set the value for a parameter. The method used is based on the SQL type
 * of the parameter and we can handle complex types like arrays and LOBs.
 * @param ps the prepared statement or callable statement
 * @param paramIndex index of the parameter we are setting
 * @param param the parameter as it is declared including type
 * @param inValue the value to set//  w  ww  .j  a  v a  2s .c  om
 * @throws SQLException if thrown by PreparedStatement methods
 */
public static void setParameterValue(PreparedStatement ps, int paramIndex, SqlParameter param, Object inValue)
        throws SQLException {

    setParameterValueInternal(ps, paramIndex, param.getSqlType(), param.getTypeName(), param.getScale(),
            inValue);
}

From source file:anyframe.core.query.impl.QueryServiceImpl.java

public ArrayList getQueryParams(String queryId) throws QueryServiceException {
    try {//from  w w  w. j av a  2 s .  co m
        IQueryInfo queryInfo = (IQueryInfo) getSqlRepository().getQueryInfos().get(queryId);

        List paramList = queryInfo.getSqlParameterList();

        ArrayList results = new ArrayList();
        for (int i = 0; i < paramList.size(); i++) {
            String[] params = new String[2];
            SqlParameter param = (SqlParameter) paramList.get(i);
            params[0] = param.getName();
            String paramTypeName = param.getTypeName();

            // param type? OTHER ? CURSOR? 
            // SqlOutParameter  param
            // type name?    API ?. ? ?
            // ? ?? ? .
            if (paramTypeName == null) {
                int type = param.getSqlType();
                paramTypeName = SQLTypeTransfer.getSQLTypeName(type);
            }

            params[1] = paramTypeName;
            results.add(params);
        }

        return results;
    } catch (Exception e) {
        throw new QueryServiceException(getMessageSource(), "error.query.common.checkparams",
                new Object[] { queryId }, e);
    }
}

From source file:org.springframework.jdbc.core.simple.AbstractJdbcCall.java

/**
 * Delegate method to perform the actual call processing.
 *///from  w w  w  .  j a  v a2 s  .c om
private Map<String, Object> executeCallInternal(Map<String, ?> args) {
    CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args);
    if (logger.isDebugEnabled()) {
        logger.debug("The following parameters are used for call " + getCallString() + " with " + args);
        int i = 1;
        for (SqlParameter param : getCallParameters()) {
            logger.debug(i + ": " + param.getName() + ", SQL type " + param.getSqlType() + ", type name "
                    + param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]");
            i++;
        }
    }
    return getJdbcTemplate().call(csc, getCallParameters());
}

From source file:org.springframework.jdbc.core.StatementCreatorUtils.java

/**
 * Set the value for a parameter. The method used is based on the SQL type
 * of the parameter and we can handle complex types like arrays and LOBs.
 * @param ps the prepared statement or callable statement
 * @param paramIndex index of the parameter we are setting
 * @param param the parameter as it is declared including type
 * @param inValue the value to set// w ww.  j  a  va2  s .c  om
 * @throws SQLException if thrown by PreparedStatement methods
 */
public static void setParameterValue(PreparedStatement ps, int paramIndex, SqlParameter param,
        @Nullable Object inValue) throws SQLException {

    setParameterValueInternal(ps, paramIndex, param.getSqlType(), param.getTypeName(), param.getScale(),
            inValue);
}