Java Code Examples for java.sql.ParameterMetaData#parameterModeOut()

The following examples show how to use java.sql.ParameterMetaData#parameterModeOut() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utility.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * give the stored procedure's column type name from the type.
 * @param type
 * @return
 */
public static String toModeType( int type )
{
	switch ( type )
	{
		case ParameterMetaData.parameterModeUnknown:
			return "Unknown";
		case ParameterMetaData.parameterModeIn:
			return "Input";
		case ParameterMetaData.parameterModeInOut:
			return "Input/Output";
		case ParameterMetaData.parameterModeOut:
			return "Output";
		case 5:
			return "Return Value";
		default:
			return "Unknown";
	}
}
 
Example 2
Source File: ParameterMetaDataJdbc30Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
        * print the parameter mode in human readable form
        *
        * @param mode identifies parameter's mode (IN, OUT, or IN_OUT)
 * @return     the parameter mode in readable form
        *             
        */
static String parameterModeInStringForm(int mode){
	if (mode ==  ParameterMetaData.parameterModeIn)
			  return("PARAMETER_MODE_IN");
	else if (mode ==  ParameterMetaData.parameterModeInOut )
			  return("PARAMETER_MODE_IN_OUT");
	else if (mode ==  ParameterMetaData.parameterModeOut)
			  return("PARAMETER_MODE_OUT");
	else if (mode ==  ParameterMetaData.parameterModeUnknown)
			  return("PARAMETER_MODE_UNKNOWN");
	else
			  return("ERROR: donot recognize this parameter mode");
 	}
 
Example 3
Source File: ParameterMetaDataJdbc30Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
        * print the parameter mode in human readable form
        *
        * @param mode identifies parameter's mode (IN, OUT, or IN_OUT)
 * @return     the parameter mode in readable form
        *             
        */
static String parameterModeInStringForm(int mode){
	if (mode ==  ParameterMetaData.parameterModeIn)
			  return("PARAMETER_MODE_IN");
	else if (mode ==  ParameterMetaData.parameterModeInOut )
			  return("PARAMETER_MODE_IN_OUT");
	else if (mode ==  ParameterMetaData.parameterModeOut)
			  return("PARAMETER_MODE_OUT");
	else if (mode ==  ParameterMetaData.parameterModeUnknown)
			  return("PARAMETER_MODE_UNKNOWN");
	else
			  return("ERROR: donot recognize this parameter mode");
 	}
 
Example 4
Source File: SQLTools.java    From jsqsh with Apache License 2.0 5 votes vote down vote up
/**
 * Decodes a parameter mode number into a readable string
 * @param mode The mode
 * @return The string
 */
public static String getParameterMode(int mode) {
    
    switch (mode) {
    case ParameterMetaData.parameterModeIn: return "IN";
    case ParameterMetaData.parameterModeInOut: return "INOUT";
    case ParameterMetaData.parameterModeOut: return "OUT";
    case ParameterMetaData.parameterModeUnknown: return "UNKNOWN";
    default:
        return "UNRECOGNIZED";
    }
}
 
Example 5
Source File: ParameterMetaDataJdbc30Test.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
        * print the parameter mode in human readable form
        *
        * @param mode identifies parameter's mode (IN, OUT, or IN_OUT)
 * @return     the parameter mode in readable form
        *             
        */
static String parameterModeInStringForm(int mode){
	if (mode ==  ParameterMetaData.parameterModeIn)
			  return("PARAMETER_MODE_IN");
	else if (mode ==  ParameterMetaData.parameterModeInOut )
			  return("PARAMETER_MODE_IN_OUT");
	else if (mode ==  ParameterMetaData.parameterModeOut)
			  return("PARAMETER_MODE_OUT");
	else if (mode ==  ParameterMetaData.parameterModeUnknown)
			  return("PARAMETER_MODE_UNKNOWN");
	else
			  return("ERROR: donot recognize this parameter mode");
 	}
 
Example 6
Source File: CallableStatement.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void addParametersFromDBMD(java.sql.ResultSet paramTypesRs) throws SQLException {
    int i = 0;

    while (paramTypesRs.next()) {
        String paramName = paramTypesRs.getString(4);
        int inOutModifier;
        switch (paramTypesRs.getInt(5)) {
            case DatabaseMetaData.procedureColumnIn:
                inOutModifier = ParameterMetaData.parameterModeIn;
                break;
            case DatabaseMetaData.procedureColumnInOut:
                inOutModifier = ParameterMetaData.parameterModeInOut;
                break;
            case DatabaseMetaData.procedureColumnOut:
            case DatabaseMetaData.procedureColumnReturn:
                inOutModifier = ParameterMetaData.parameterModeOut;
                break;
            default:
                inOutModifier = ParameterMetaData.parameterModeUnknown;
        }

        boolean isOutParameter = false;
        boolean isInParameter = false;

        if (i == 0 && this.isFunctionCall) {
            isOutParameter = true;
            isInParameter = false;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnInOut) {
            isOutParameter = true;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnIn) {
            isOutParameter = false;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnOut) {
            isOutParameter = true;
            isInParameter = false;
        }

        int jdbcType = paramTypesRs.getInt(6);
        String typeName = paramTypesRs.getString(7);
        int precision = paramTypesRs.getInt(8);
        int scale = paramTypesRs.getInt(10);
        short nullability = paramTypesRs.getShort(12);

        CallableStatementParam paramInfoToAdd = new CallableStatementParam(paramName, i++, isInParameter, isOutParameter, jdbcType, typeName, precision,
                scale, nullability, inOutModifier);

        this.parameterList.add(paramInfoToAdd);
        this.parameterMap.put(paramName, paramInfoToAdd);
    }
}
 
Example 7
Source File: CallableStatement.java    From r-course with MIT License 4 votes vote down vote up
private void addParametersFromDBMD(java.sql.ResultSet paramTypesRs) throws SQLException {
    int i = 0;

    while (paramTypesRs.next()) {
        String paramName = paramTypesRs.getString(4);
        int inOutModifier;
        switch (paramTypesRs.getInt(5)) {
            case DatabaseMetaData.procedureColumnIn:
                inOutModifier = ParameterMetaData.parameterModeIn;
                break;
            case DatabaseMetaData.procedureColumnInOut:
                inOutModifier = ParameterMetaData.parameterModeInOut;
                break;
            case DatabaseMetaData.procedureColumnOut:
            case DatabaseMetaData.procedureColumnReturn:
                inOutModifier = ParameterMetaData.parameterModeOut;
                break;
            default:
                inOutModifier = ParameterMetaData.parameterModeUnknown;
        }

        boolean isOutParameter = false;
        boolean isInParameter = false;

        if (i == 0 && this.isFunctionCall) {
            isOutParameter = true;
            isInParameter = false;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnInOut) {
            isOutParameter = true;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnIn) {
            isOutParameter = false;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnOut) {
            isOutParameter = true;
            isInParameter = false;
        }

        int jdbcType = paramTypesRs.getInt(6);
        String typeName = paramTypesRs.getString(7);
        int precision = paramTypesRs.getInt(8);
        int scale = paramTypesRs.getInt(10);
        short nullability = paramTypesRs.getShort(12);

        CallableStatementParam paramInfoToAdd = new CallableStatementParam(paramName, i++, isInParameter, isOutParameter, jdbcType, typeName, precision,
                scale, nullability, inOutModifier);

        this.parameterList.add(paramInfoToAdd);
        this.parameterMap.put(paramName, paramInfoToAdd);
    }
}
 
Example 8
Source File: CallableStatement.java    From Komondor with GNU General Public License v3.0 4 votes vote down vote up
private void addParametersFromDBMD(java.sql.ResultSet paramTypesRs) throws SQLException {
    int i = 0;

    while (paramTypesRs.next()) {
        String paramName = paramTypesRs.getString(4);
        int inOutModifier;
        switch (paramTypesRs.getInt(5)) {
            case DatabaseMetaData.procedureColumnIn:
                inOutModifier = ParameterMetaData.parameterModeIn;
                break;
            case DatabaseMetaData.procedureColumnInOut:
                inOutModifier = ParameterMetaData.parameterModeInOut;
                break;
            case DatabaseMetaData.procedureColumnOut:
            case DatabaseMetaData.procedureColumnReturn:
                inOutModifier = ParameterMetaData.parameterModeOut;
                break;
            default:
                inOutModifier = ParameterMetaData.parameterModeUnknown;
        }

        boolean isOutParameter = false;
        boolean isInParameter = false;

        if (i == 0 && this.isFunctionCall) {
            isOutParameter = true;
            isInParameter = false;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnInOut) {
            isOutParameter = true;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnIn) {
            isOutParameter = false;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnOut) {
            isOutParameter = true;
            isInParameter = false;
        }

        int jdbcType = paramTypesRs.getInt(6);
        String typeName = paramTypesRs.getString(7);
        int precision = paramTypesRs.getInt(8);
        int scale = paramTypesRs.getInt(10);
        short nullability = paramTypesRs.getShort(12);

        CallableStatementParam paramInfoToAdd = new CallableStatementParam(paramName, i++, isInParameter, isOutParameter, jdbcType, typeName, precision,
                scale, nullability, inOutModifier);

        this.parameterList.add(paramInfoToAdd);
        this.parameterMap.put(paramName, paramInfoToAdd);
    }
}
 
Example 9
Source File: CallableStatement.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
private void addParametersFromDBMD(java.sql.ResultSet paramTypesRs) throws SQLException {
    int i = 0;

    while (paramTypesRs.next()) {
        String paramName = paramTypesRs.getString(4);
        int inOutModifier;
        switch (paramTypesRs.getInt(5)) {
            case DatabaseMetaData.procedureColumnIn:
                inOutModifier = ParameterMetaData.parameterModeIn;
                break;
            case DatabaseMetaData.procedureColumnInOut:
                inOutModifier = ParameterMetaData.parameterModeInOut;
                break;
            case DatabaseMetaData.procedureColumnOut:
            case DatabaseMetaData.procedureColumnReturn:
                inOutModifier = ParameterMetaData.parameterModeOut;
                break;
            default:
                inOutModifier = ParameterMetaData.parameterModeUnknown;
        }

        boolean isOutParameter = false;
        boolean isInParameter = false;

        if (i == 0 && this.isFunctionCall) {
            isOutParameter = true;
            isInParameter = false;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnInOut) {
            isOutParameter = true;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnIn) {
            isOutParameter = false;
            isInParameter = true;
        } else if (inOutModifier == java.sql.DatabaseMetaData.procedureColumnOut) {
            isOutParameter = true;
            isInParameter = false;
        }

        int jdbcType = paramTypesRs.getInt(6);
        String typeName = paramTypesRs.getString(7);
        int precision = paramTypesRs.getInt(8);
        int scale = paramTypesRs.getInt(10);
        short nullability = paramTypesRs.getShort(12);

        CallableStatementParam paramInfoToAdd = new CallableStatementParam(paramName, i++, isInParameter, isOutParameter, jdbcType, typeName, precision,
                scale, nullability, inOutModifier);

        this.parameterList.add(paramInfoToAdd);
        this.parameterMap.put(paramName, paramInfoToAdd);
    }
}
 
Example 10
Source File: RestDMLServiceImpl.java    From sql-layer with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void callDefaultProcedure(PrintWriter writer, HttpServletRequest request, String jsonpArgName,
                                    JDBCCallableStatement call, Map<String,List<String>> queryParams, String jsonParams) throws SQLException {
    if (queryParams != null) {
        for (Map.Entry<String,List<String>> entry : queryParams.entrySet()) {
            if (jsonpArgName.equals(entry.getKey()))
                continue;
            if (entry.getValue().size() != 1)
                throw new WrongExpressionArityException(1, entry.getValue().size());
            call.setString(entry.getKey(), entry.getValue().get(0));
        }
    }
    if (jsonParams != null) {
        JsonNode parsed;
        try {
            parsed = jsonParser(jsonParams).readValueAsTree();
        }
        catch (IOException ex) {
            throw new AkibanInternalException("Error reading from string", ex);
        }
        if (parsed.isObject()) {
            Iterator<String> iter = parsed.fieldNames();
            while (iter.hasNext()) {
                String field = iter.next();
                JsonNode value = parsed.get(field);
                if (value.isBigDecimal()) {
                    call.setBigDecimal(field, value.decimalValue());
                }
                else if (value.isBoolean()) {
                    call.setBoolean(field, value.asBoolean());
                }
                else if (value.isDouble()) {
                    call.setDouble(field, value.asDouble());
                }
                else if (value.isInt()) {
                    call.setInt(field, value.asInt());
                }
                else if (value.isLong()) {
                    call.setLong(field, value.asLong());
                }
                else {
                    call.setString(field, value.textValue());
                }
            }
        }
        else {
            throw new InvalidArgumentTypeException("JSON must be object or array");
        }
    }
    boolean results = call.execute();
    AkibanAppender appender = AkibanAppender.of(writer);
    appender.append('{');
    boolean first = true;
    JDBCParameterMetaData md = (JDBCParameterMetaData)call.getParameterMetaData();
    for (int i = 1; i <= md.getParameterCount(); i++) {
        String name;
        switch (md.getParameterMode(i)) {
        case ParameterMetaData.parameterModeOut:
        case ParameterMetaData.parameterModeInOut:
            name = md.getParameterName(i);
            if (name == null)
                name = String.format("arg%d", i);
            if (first)
                first = false;
            else
                appender.append(',');
            appender.append('"');
            Quote.DOUBLE_QUOTE.append(appender, name);
            appender.append("\":");
            call.formatAsJson(i, appender, options);
            break;
        }
    }
    int nresults = 0;
    while(results) {
        beginResultSetArray(appender, first, nresults++);
        first = false;
        collectResults((JDBCResultSet) call.getResultSet(), appender, options);
        endResultSetArray(appender);
        results = call.getMoreResults();
    }
    appender.append('}');
}