本文整理匯總了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 ();
}
}