本文整理汇总了Java中java.sql.Blob.free方法的典型用法代码示例。如果您正苦于以下问题:Java Blob.free方法的具体用法?Java Blob.free怎么用?Java Blob.free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.Blob
的用法示例。
在下文中一共展示了Blob.free方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import java.sql.Blob; //导入方法依赖的package包/类
@Override
public void close() {
try {
for (Blob blob : this.temporaryBlobs) {
blob.free();
}
for (Clob clob : this.temporaryClobs) {
clob.free();
}
}
catch (SQLException ex) {
logger.error("Could not free LOB", ex);
}
}
示例2: getObjectFromBlob
import java.sql.Blob; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* Caché requires {@code java.sql.Blob} instances to be explicitly freed.
*/
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName) throws ClassNotFoundException, IOException, SQLException {
Blob blob = rs.getBlob(colName);
if (blob == null) {
return null;
} else {
try {
if (blob.length() == 0) {
return null;
} else {
InputStream binaryInput = blob.getBinaryStream();
if (binaryInput == null) {
return null;
} else if (binaryInput instanceof ByteArrayInputStream && ((ByteArrayInputStream) binaryInput).available() == 0 ) {
return null;
} else {
ObjectInputStream in = new ObjectInputStream(binaryInput);
try {
return in.readObject();
} finally {
in.close();
}
}
}
} finally {
blob.free();
}
}
}
示例3: toEvent
import java.sql.Blob; //导入方法依赖的package包/类
private Event toEvent ( final ResultSet resultSet ) throws SQLException, IOException, ClassNotFoundException
{
byte[] data;
switch ( this.jdbcDao.dataFormat )
{
case JSON:
return EventConverter.INSTANCE.toEvent ( resultSet.getString ( 4 ) );
case BLOB:
final Blob blob = resultSet.getBlob ( 4 );
data = blob.getBytes ( 0, Long.valueOf ( blob.length () ).intValue () );
blob.free ();
break;
case BYTES:
//$FALL-THROUGH$
default:
data = resultSet.getBytes ( 4 );
break;
}
logger.trace ( "Deserialize event" );
final BundleObjectInputStream stream = new BundleObjectInputStream ( new ByteArrayInputStream ( data ), Activator.getContext ().getBundle () );
try
{
final Object o = stream.readObject ();
if ( o instanceof Event )
{
return (Event)o;
}
else if ( o == null )
{
logger.warn ( "Found null event" );
return null;
}
else
{
logger.warn ( "Expected event type {} but found {}. Discarding...", Event.class, o.getClass () );
return null;
}
}
finally
{
stream.close ();
}
}