本文整理汇总了Java中java.sql.ResultSet.getBinaryStream方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getBinaryStream方法的具体用法?Java ResultSet.getBinaryStream怎么用?Java ResultSet.getBinaryStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getBinaryStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fieldToFile
import java.sql.ResultSet; //导入方法依赖的package包/类
public void fieldToFile(ResultSet resultset, String s, String s1)
throws ServletException, IOException, SmartUploadException, SQLException
{
try
{
if(m_application.getRealPath(s1) != null)
s1 = m_application.getRealPath(s1);
InputStream inputstream = resultset.getBinaryStream(s);
FileOutputStream fileoutputstream = new FileOutputStream(s1);
int i;
while((i = inputstream.read()) != -1)
fileoutputstream.write(i);
fileoutputstream.close();
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to save file from the DataBase (1020).");
}
}
示例2: getObjectFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* <p>
* This method should be overridden by any delegate subclasses that need
* special handling for BLOBs. The default implementation uses standard
* JDBC <code>java.sql.Blob</code> operations.
* </p>
*
* @param rs
* the result set, already queued to the correct row
* @param colName
* the column name for the BLOB
* @return the deserialized Object from the ResultSet BLOB
* @throws ClassNotFoundException
* if a class found during deserialization cannot be found
* @throws IOException
* if deserialization causes an error
*/
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
InputStream binaryInput = rs.getBinaryStream(colName);
if(binaryInput == null || binaryInput.available() == 0) {
return null;
}
Object obj = null;
ObjectInputStream in = new ObjectInputStream(binaryInput);
try {
obj = in.readObject();
} finally {
in.close();
}
return obj;
}
示例3: getObjectFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
Object obj = null;
InputStream binaryInput = rs.getBinaryStream(colName);
if (binaryInput != null) {
ObjectInputStream in = new ObjectInputStream(binaryInput);
try {
obj = in.readObject();
} finally {
in.close();
}
}
return obj;
}
示例4: readBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* Přešte blob dat ze zadaného sloupečku
*
* @param resultSet {@link ResultSet}
* @param column Sloupeček, který obsahuje blob
* @return Pole bytu
* @throws SQLException
* @throws IOException
*/
public static byte[] readBlob(ResultSet resultSet, String column) {
final ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
try {
final InputStream binaryStream = resultSet.getBinaryStream(column);
final byte[] buffer = new byte[1024];
while (binaryStream.read(buffer) > 0) {
arrayOutputStream.write(buffer);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return arrayOutputStream.toByteArray();
}
示例5: getObjectFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* <p>
* This method should be overridden by any delegate subclasses that need
* special handling for BLOBs. The default implementation uses standard
* JDBC <code>java.sql.Blob</code> operations.
* </p>
*
* @param rs
* the result set, already queued to the correct row
* @param colName
* the column name for the BLOB
* @return the deserialized Object from the ResultSet BLOB
* @throws ClassNotFoundException
* if a class found during deserialization cannot be found
* @throws IOException
* if deserialization causes an error
*/
protected Object getObjectFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
InputStream binaryInput = rs.getBinaryStream(colName);
if(binaryInput == null || binaryInput.available() == 0) {
return null;
}
Object obj = null;
ObjectInputStream in = new ObjectInputStream(binaryInput);
try {
obj = in.readObject();
} finally {
in.close();
}
return obj;
}
示例6: getVersionedList
import java.sql.ResultSet; //导入方法依赖的package包/类
private static List<Versioned<byte[]>> getVersionedList(ResultSet rs)
throws SQLException, JsonParseException,
JsonMappingException, IOException {
InputStream is = rs.getBinaryStream("datavalue");
return mapper.readValue(is,
new TypeReference<List<VCVersioned<byte[]>>>() {});
}
示例7: readBundle
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* Reads and parses a bundle from the BLOB in the given column of the
* current row of the given result set. This is a helper method to
* circumvent issues JCR-1039 and JCR-1474.
*
* @param id bundle identifier
* @param rs result set
* @param column BLOB column
* @return parsed bundle
* @throws SQLException if the bundle can not be read or parsed
*/
private NodePropBundle readBundle(NodeId id, ResultSet rs, int column)
throws SQLException {
try {
InputStream in;
if (rs.getMetaData().getColumnType(column) == Types.BLOB) {
in = rs.getBlob(column).getBinaryStream();
} else {
in = rs.getBinaryStream(column);
}
try {
return binding.readBundle(in, id);
} finally {
in.close();
}
} catch (IOException e) {
SQLException exception =
new SQLException("Failed to parse bundle " + id);
exception.initCause(e);
throw exception;
}
}
示例8: testGetBinaryStream
import java.sql.ResultSet; //导入方法依赖的package包/类
public void testGetBinaryStream(ResultSet resultSet) throws SQLException {
try {
resultSet.getBinaryStream(ordinal);
fail("Was expecting to throw SQLDataException");
} catch (Exception e) {
assertThat(e, isA((Class) SQLDataException.class)); // success
}
}
示例9: getBlobAsBinaryStream
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException {
logger.debug("Returning BLOB as binary stream");
if (this.wrapAsLob) {
Blob blob = rs.getBlob(columnIndex);
return blob.getBinaryStream();
}
else {
return rs.getBinaryStream(columnIndex);
}
}
示例10: getObjectFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* <p>
* This method should be overridden by any delegate subclasses that need
* special handling for BLOBs. The default implementation uses standard
* JDBC <code>java.sql.Blob</code> operations.
* </p>
*
* @param rs
* the result set, already queued to the correct row
* @param colName
* the column name for the BLOB
* @return the deserialized Object from the ResultSet BLOB
* @throws ClassNotFoundException
* if a class found during deserialization cannot be found
* @throws IOException
* if deserialization causes an error
*/
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
InputStream binaryInput = rs.getBinaryStream(colName);
if(binaryInput == null || binaryInput.available() == 0) {
return null;
}
Object obj = null;
ObjectInputStream in = new ObjectInputStream(binaryInput);
try {
obj = in.readObject();
} finally {
in.close();
}
return obj;
}
示例11: getJobDataFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
protected Object getJobDataFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
if (canUseProperties()) {
InputStream binaryInput = rs.getBinaryStream(colName);
return binaryInput;
}
return getObjectFromBlob(rs, colName);
}
示例12: getJobDataFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
protected Object getJobDataFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
if (canUseProperties()) {
InputStream binaryInput = rs.getBinaryStream(colName);
return binaryInput;
}
return getObjectFromBlob(rs, colName);
}
示例13: get
import java.sql.ResultSet; //导入方法依赖的package包/类
public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
if ( Environment.useStreamsForBinary() ) {
InputStream inputStream = rs.getBinaryStream(name);
if (inputStream==null) return toExternalFormat( null ); // is this really necessary?
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
byte[] buffer = new byte[2048];
try {
while (true) {
int amountRead = inputStream.read(buffer);
if (amountRead == -1) {
break;
}
outputStream.write(buffer, 0, amountRead);
}
inputStream.close();
outputStream.close();
}
catch (IOException ioe) {
throw new HibernateException( "IOException occurred reading a binary value", ioe );
}
return toExternalFormat( outputStream.toByteArray() );
}
else {
return toExternalFormat( rs.getBytes(name) );
}
}
示例14: getJobDetailFromBlob
import java.sql.ResultSet; //导入方法依赖的package包/类
protected Object getJobDetailFromBlob(ResultSet rs, String colName)
throws ClassNotFoundException, IOException, SQLException {
if (canUseProperties()) {
InputStream binaryInput = rs.getBinaryStream(colName);
return binaryInput;
}
return getObjectFromBlob(rs, colName);
}
示例15: doFillWithResurltSetCol
import java.sql.ResultSet; //导入方法依赖的package包/类
public void doFillWithResurltSetCol(ResultSet resultSet, int nCol)
throws SQLException
{
m_is = resultSet.getBinaryStream(nCol);
}