当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getClob方法代码示例

本文整理汇总了Java中java.sql.ResultSet.getClob方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getClob方法的具体用法?Java ResultSet.getClob怎么用?Java ResultSet.getClob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getClob方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PreparedStmtSetValue

import java.sql.ResultSet; //导入方法依赖的package包/类
public static Object PreparedStmtSetValue(int columnType, ResultSet rs, int index) throws SQLException, IOException{
	StringBuffer sb = new StringBuffer();
	switch(columnType){
	case 2005:  //CLOB
		Clob clob = rs.getClob(index);
		
		if (clob == null){
			return null;
		}
		
		Reader reader = clob.getCharacterStream();
		char[] buffer = new char[(int)clob.length()];
		while(reader.read(buffer) != -1){
			sb.append(buffer);				
		}
		return sb.toString();
	case 2004:  //BLOB			
		Blob blob = rs.getBlob(index);
		
		if (blob == null){
			return null;
		}
		
		InputStream in = blob.getBinaryStream();
		byte[] Bytebuffer = new byte[(int)blob.length()];
		in.read(Bytebuffer);
		return Bytebuffer;
	case -2:
		return rs.getBytes(index);
	default:
		return rs.getObject(index);
	}	
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:34,代码来源:DatabaseUtil.java

示例2: getClobAsCharacterStream

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning CLOB as character stream");
	if (this.wrapAsLob) {
		Clob clob = rs.getClob(columnIndex);
		return clob.getCharacterStream();
	}
	else {
		return rs.getCharacterStream(columnIndex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DefaultLobHandler.java

示例3: getClobAsString

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning Oracle CLOB as string");
	Clob clob = rs.getClob(columnIndex);
	initializeResourcesBeforeRead(rs.getStatement().getConnection(), clob);
	String retVal = (clob != null ? clob.getSubString(1, (int) clob.length()) : null);
	releaseResourcesAfterRead(rs.getStatement().getConnection(), clob);
	return retVal;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:OracleLobHandler.java

示例4: getClobAsAsciiStream

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning Oracle CLOB as ASCII stream");
	Clob clob = rs.getClob(columnIndex);
	initializeResourcesBeforeRead(rs.getStatement().getConnection(), clob);
	InputStream retVal = (clob != null ? clob.getAsciiStream() : null);
	releaseResourcesAfterRead(rs.getStatement().getConnection(), clob);
	return retVal;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:OracleLobHandler.java

示例5: getClobAsCharacterStream

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning Oracle CLOB as character stream");
	Clob clob = rs.getClob(columnIndex);
	initializeResourcesBeforeRead(rs.getStatement().getConnection(), clob);
	Reader retVal = (clob != null ? clob.getCharacterStream() : null);
	releaseResourcesAfterRead(rs.getStatement().getConnection(), clob);
	return retVal;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:OracleLobHandler.java

示例6: getClobAsString

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning CLOB as string");
	if (this.wrapAsLob) {
		Clob clob = rs.getClob(columnIndex);
		return clob.getSubString(1, (int) clob.length());
	}
	else {
		return rs.getString(columnIndex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DefaultLobHandler.java

示例7: getClobAsAsciiStream

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning CLOB as ASCII stream");
	if (this.wrapAsLob) {
		Clob clob = rs.getClob(columnIndex);
		return clob.getAsciiStream();
	}
	else {
		return rs.getAsciiStream(columnIndex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DefaultLobHandler.java

示例8: nullSafeGet

import java.sql.ResultSet; //导入方法依赖的package包/类
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
      Clob clob = rs.getClob(names[0]);
      if (clob==null) return null;
try {
	SAXReader reader = new SAXReader();
	Document document = reader.read(clob.getCharacterStream());
	return document;
} catch (DocumentException e) {
	throw new HibernateException(e.getMessage(),e);
}
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:XmlClobType.java

示例9: getNullableResult

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
	String value = "";
	Clob clob = rs.getClob(columnName);
	if (clob != null) {
		int size = (int) clob.length();
		value = clob.getSubString(1, size);
	}
	return value;
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:11,代码来源:ClobTypeHandler.java

示例10: readClobRef

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Actually read a ClobRef instance from the ResultSet and materialize
 * the data either inline or to a file.
 *
 * @param colNum the column of the ResultSet's current row to read.
 * @param r the ResultSet to read from.
 * @return a ClobRef encapsulating the data in this field.
 * @throws IOException if an error occurs writing to the FileSystem.
 * @throws SQLException if an error occurs reading from the database.
 */
public com.cloudera.sqoop.lib.ClobRef readClobRef(int colNum, ResultSet r)
    throws IOException, InterruptedException, SQLException {

  long maxInlineLobLen = conf.getLong(
      MAX_INLINE_LOB_LEN_KEY,
      DEFAULT_MAX_LOB_LENGTH);

  Clob c = r.getClob(colNum);
  if (null == c) {
    return null;
  } else if (c.length() > maxInlineLobLen) {
    // Deserialize large CLOB into separate file.
    long len = c.length();
    LobFile.Writer lobWriter = getClobWriter();

    long recordOffset = lobWriter.tell();
    Reader reader = null;
    Writer w = lobWriter.writeClobRecord(len);
    try {
      reader = c.getCharacterStream();
      copyAll(reader, w);
    } finally {
      if (null != w) {
        w.close();
      }

      if (null != reader) {
        reader.close();
      }

      // Mark the record as finished.
      lobWriter.finishRecord();
    }

    return new com.cloudera.sqoop.lib.ClobRef(
        getRelativePath(lobWriter), recordOffset, len);
  } else {
    // This is a 1-based array.
    return new com.cloudera.sqoop.lib.ClobRef(
        c.getSubString(1, (int) c.length()));
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:53,代码来源:LargeObjectLoader.java

示例11: getAppObject

import java.sql.ResultSet; //导入方法依赖的package包/类
/** Gets a parameter from the ResultSet.
 * @return the parameter.
 * @param engineType The engine type as defined in init.xml
 * @param rs The ResultSet.
 * @param columnName The name 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(ResultSet rs, String columnName, String engineType) throws SQLException, IOException {
    Clob clob = rs.getClob(columnName);
    if (clob != null)
        return StringHelper.getString(clob.getCharacterStream());
    else
        return null;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:16,代码来源:TypeDefs.java


注:本文中的java.sql.ResultSet.getClob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。