本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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()));
}
}
示例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;
}