Java Code Examples for java.sql.CallableStatement.getString()

The following are Jave code examples for showing how to use getString() of the java.sql.CallableStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lams   File: OracleTableMetaDataProvider.java   Source Code and License Vote up 6 votes
private void lookupDefaultSchema(DatabaseMetaData databaseMetaData) {
	try {
		CallableStatement cstmt = null;
		try {
			cstmt = databaseMetaData.getConnection().prepareCall("{? = call sys_context('USERENV', 'CURRENT_SCHEMA')}");
			cstmt.registerOutParameter(1, Types.VARCHAR);
			cstmt.execute();
			this.defaultSchema = cstmt.getString(1);
		}
		finally {
			if (cstmt != null) {
				cstmt.close();
			}
		}
	}
	catch (Exception ignore) {
	}
}
 
Example 2
Project: unitimes   File: BlobRoomAvailabilityService.java   Source Code and License Vote up 6 votes
protected Document receiveResponse() throws IOException, DocumentException {
    try {
        SessionImplementor session = (SessionImplementor)new _RootDAO().getSession();
        Connection connection = session.getJdbcConnectionAccess().obtainConnection();
        String response = null;
        try {
            CallableStatement call = connection.prepareCall(iResponseSql);
            call.registerOutParameter(1, java.sql.Types.CLOB);
            call.execute();
            response = call.getString(1);
            call.close();
        } finally {
        	session.getJdbcConnectionAccess().releaseConnection(connection);
        }
        if (response==null || response.length()==0) return null;
        StringReader reader = new StringReader(response);
        Document document = (new SAXReader()).read(reader);
        reader.close();
        return document;
    } catch (Exception e) {
        sLog.error("Unable to receive response: "+e.getMessage(),e);
        return null;
    } finally {
        _RootDAO.closeCurrentThreadSessions();
    }
}
 
Example 3
Project: unitimes   File: ImportXmlFromDB.java   Source Code and License Vote up 5 votes
public static void importXml(String baseFileName){
    	Debug.info("filename = " + baseFileName);
   	try {
   		String fileReceiveSql =
   	        ApplicationProperties.getProperty("tmtbl.data.exchange.receive.file","{?= call timetable.receive_xml_file.receive_file(?, ?)}");
   		String exchangeDir = 
   	    	ApplicationProperties.getProperty("tmtbl.data.exchange.directory", "LOAD_SMASDEV");
           SessionImplementor session = (SessionImplementor)new _RootDAO().getSession();
           Connection connection = session.getJdbcConnectionAccess().obtainConnection();
           CallableStatement call = connection.prepareCall(fileReceiveSql);
           call.registerOutParameter(1, java.sql.Types.CLOB);
	    call.setString(2, exchangeDir);
           call.setString(3, baseFileName);
           call.execute();
           String response = call.getString(1);
           call.close();
           session.getJdbcConnectionAccess().releaseConnection(connection);
           if (response==null || response.length()==0) return;
           StringReader reader = new StringReader(response);
           Document document = (new SAXReader()).read(reader);
           reader.close();
           DataExchangeHelper.importDocument(document, null, null);           
	} catch (Exception e) {
		e.printStackTrace();
	} 
	
}
 
Example 4
Project: tangyuan2   File: CharacterTypeHandler.java   Source Code and License Vote up 5 votes
@Override
public Character getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
	String columnValue = cs.getString(columnIndex);
	if (columnValue != null) {
		return columnValue.charAt(0);
	} else {
		return null;
	}
}
 
Example 5
Project: uavstack   File: DAOFactory.java   Source Code and License Vote up 5 votes
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {

            Object s = cs.getString(columnIndex);
            if (cs.wasNull()) {
                return null;
            }
            else {
                return s;
            }
        }
 
Example 6
Project: jaffa-framework   File: TypeDefs.java   Source Code and License Vote up 5 votes
/** Gets a parameter from the CallableStatement.
 * @return the parameter.
 * @param engineType The engine type as defined in init.xml
 * @param cstmt The CallableStatement.
 * @param parameterIndex The index of the parameter.
 * @throws SQLException if a database access error occurs.
 * @throws IOException if any error occurs in reading the data from the database.
 */
public Object getAppObject(CallableStatement cstmt, int parameterIndex, String engineType) throws SQLException, IOException {
    String str = cstmt.getString(parameterIndex);
    if (str != null) {
        //Trim the String by default. Do not trim if the rule is set to true!
        Boolean doNotTrim = Parser.parseBoolean((String) ContextManagerFactory.instance().getProperty(DO_NOT_TRIM_RULE_NAME));
        if (doNotTrim == null || !doNotTrim.booleanValue())
            str = str.trim();
        if (str.length() == 0)
            str = null;
    }
    return str;
}
 
Example 7
Project: mybatis-plus-mini   File: PhoneTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public PhoneNumber getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    return new PhoneNumber(cs.getString(columnIndex));
}
 
Example 8
Project: typehandlers-threeten-extra   File: YearQuarterTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public YearQuarter getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
  String str = cs.getString(columnIndex);
  return getYearQuarter(str);
}
 
Example 9
Project: typehandlers-threeten-extra   File: YearWeekTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public YearWeek getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
  String str = cs.getString(columnIndex);
  return getYearWeek(str);
}
 
Example 10
Project: MybatisGeneatorUtil   File: StringType2Handler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex)
        throws SQLException {
    return cs.getString(columnIndex);
}
 
Example 11
Project: tk-mybatis   File: StringType2Handler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex)
        throws SQLException {
    return cs.getString(columnIndex);
}
 
Example 12
Project: tangyuan2   File: NStringTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
	return cs.getString(columnIndex);
}
 
Example 13
Project: tangyuan2   File: StringTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
	return cs.getString(columnIndex);
}
 
Example 14
Project: tangyuan2   File: EnumTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
	String s = cs.getString(columnIndex);
	return s == null ? null : Enum.valueOf(type, s);
}
 
Example 15
Project: dropwizard-mybatis   File: AbstractTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    String value = cs.getString(columnIndex);
    return format(value);
}
 
Example 16
Project: java-demo   File: MyStringTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    System.out.println("use MyStingTypeHandler getNullableResult callableStatement");
    return cs.getString(columnIndex);
}
 
Example 17
Project: typehandlers-encrypt   File: EncryptTypeHandler.java   Source Code and License Vote up 4 votes
@Override
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    String r = cs.getString(columnIndex);
    // 兼容待修复的数据
    return r == null ? null : (EncryptUtil.isEncrypted(r) ? EncryptUtil.decrypt(r) : r);
}
 
Example 18
Project: jaffa-framework   File: TypeDefs.java   Source Code and License Vote up 2 votes
/** Gets a parameter from the CallableStatement.
 * @return the parameter.
 * @param engineType The engine type as defined in init.xml
 * @param cstmt The CallableStatement.
 * @param parameterIndex The index of the parameter.
 * @throws SQLException if a database access error occurs.
 * @throws IOException if any error occurs in reading the data from the database.
 */
public Object getAppObject(CallableStatement cstmt, int parameterIndex, String engineType) throws SQLException, IOException {
    return cstmt.getString(parameterIndex);
}