當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.getCharacterStream方法代碼示例

本文整理匯總了Java中java.sql.ResultSet.getCharacterStream方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.getCharacterStream方法的具體用法?Java ResultSet.getCharacterStream怎麽用?Java ResultSet.getCharacterStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getCharacterStream方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: nullSafeGet

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException
{
	Reader reader = rs.getCharacterStream(names[0]);
	if( reader == null )
	{
		return null;
	}
	StringBuilder result = new StringBuilder(4096);
	try
	{
		char[] charbuf = new char[4096];
		for( int i = reader.read(charbuf); i > 0; i = reader.read(charbuf) )
		{
			result.append(charbuf, 0, i);
		}
	}
	catch( IOException e )
	{
		throw new SQLException(e.getMessage());
	}
	// wtf??
	String xml = result.toString();
	if( xml.trim().length() == 0 )
	{
		return null;
	}
	return xstream.deserialiseFromXml(getClass().getClassLoader(), xml);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:30,代碼來源:ImmutableHibernateXStreamType.java

示例3: get

import java.sql.ResultSet; //導入方法依賴的package包/類
public Object get(ResultSet rs, String name) throws HibernateException, SQLException {

			// Retrieve the value of the designated column in the current row of this
			// ResultSet object as a java.io.Reader object
			Reader charReader = rs.getCharacterStream(name);

			// if the corresponding SQL value is NULL, the reader we got is NULL as well
			if (charReader==null) return null;

			// Fetch Reader content up to the end - and put characters in a StringBuilder
			StringBuilder sb = new StringBuilder();
			try {
				char[] buffer = new char[2048];
				while (true) {
					int amountRead = charReader.read(buffer, 0, buffer.length);
					if ( amountRead == -1 ) break;
					sb.append(buffer, 0, amountRead);
				}
			}
			catch (IOException ioe) {
				throw new HibernateException( "IOException occurred reading text", ioe );
			}
			finally {
				try {
					charReader.close();
				}
				catch (IOException e) {
					throw new HibernateException( "IOException occurred closing stream", e );
				}
			}

			// Return StringBuilder content as a large String
			return sb.toString();
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:AbstractLongStringType.java

示例4: get

import java.sql.ResultSet; //導入方法依賴的package包/類
public Object get(ResultSet rs, String name) throws SQLException {
	Reader stream = rs.getCharacterStream(name);
	if ( stream == null ) return toExternalFormat( null );
	CharArrayWriter writer = new CharArrayWriter();
	for(;;) {
		try {
			int c = stream.read();
			if ( c == -1) return toExternalFormat( writer.toCharArray() );
			writer.write( c );
		}
		catch (IOException e) {
			throw new HibernateException("Unable to read character stream from rs");
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:AbstractCharArrayType.java

示例5: nullSafeGet

import java.sql.ResultSet; //導入方法依賴的package包/類
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
	Reader reader = rs.getCharacterStream( names[0] );
	if ( reader == null ) return null;
	StringBuilder result = new StringBuilder( 4096 );
	try {
		char[] charbuf = new char[4096];
		for ( int i = reader.read( charbuf ); i > 0 ; i = reader.read( charbuf ) ) {
			result.append( charbuf, 0, i );
		}
	}
	catch (IOException e) {
		throw new SQLException( e.getMessage() );
	}
	return result.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:StringClobType.java

示例6: testGetCharacterStream

import java.sql.ResultSet; //導入方法依賴的package包/類
public void testGetCharacterStream(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getCharacterStream(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:9,代碼來源:AvaticaResultSetConversionsTest.java

示例7: formatClobColumn

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
    * the CLOB content is dumped in a server file that will be available for
    * the client the name of the file will be stored in the output stream ;
    * 
    * @param resultSet
    *            the result set in progress to send back to the client side
    * @param columnIndex
    *            the column index
    * 
    * @return the formated binary column
    * 
    * @throws SQLException
    */
   private String formatClobColumn(ResultSet resultSet, int columnIndex)
    throws SQLException, IOException {
String columnValueStr;

String fileName = FrameworkFileUtil.getUniqueId() + ".clob.txt";

// Maybe null, we want to keep the info
Reader reader = resultSet.getCharacterStream(columnIndex);
BufferedReader br = new BufferedReader(reader);

String hostFileName = null;

// hostFileName = HttpConfigurationUtil.addRootPath(fileConfigurator,
// username, fileName);

String database = request.getParameter(HttpParameter.DATABASE);
DatabaseConfigurator databaseConfigurator = ServerSqlManager
	.getDatabaseConfigurator(database);

hostFileName = databaseConfigurator.getBlobsDirectory(username)
	+ File.separator + fileName;

debug("formatClobColumn:writer: " + hostFileName);

if (reader == null) {

    try (Writer writer = new BufferedWriter(
	    new FileWriter(hostFileName));) {
	debug("formatClobColumn.reader == null");
	writer.write(NULL_STREAM + CR_LF);
    }
} else {

    writeClobFile(br, hostFileName);

}

// The column value is a file name with a tag for identification
columnValueStr = fileName;
return columnValueStr;
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:55,代碼來源:ResultSetWriter.java


注:本文中的java.sql.ResultSet.getCharacterStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。