本文整理汇总了Java中org.springframework.jdbc.support.lob.LobHandler类的典型用法代码示例。如果您正苦于以下问题:Java LobHandler类的具体用法?Java LobHandler怎么用?Java LobHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LobHandler类属于org.springframework.jdbc.support.lob包,在下文中一共展示了LobHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbstractDbDialect
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
public AbstractDbDialect(final JdbcTemplate jdbcTemplate, LobHandler lobHandler){
this.jdbcTemplate = jdbcTemplate;
this.lobHandler = lobHandler;
// 初始化transction
this.transactionTemplate = new TransactionTemplate();
transactionTemplate.setTransactionManager(new DataSourceTransactionManager(jdbcTemplate.getDataSource()));
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
// 初始化一些数据
jdbcTemplate.execute(new ConnectionCallback() {
public Object doInConnection(Connection c) throws SQLException, DataAccessException {
DatabaseMetaData meta = c.getMetaData();
databaseName = meta.getDatabaseProductName();
databaseMajorVersion = meta.getDatabaseMajorVersion();
databaseMinorVersion = meta.getDatabaseMinorVersion();
return null;
}
});
initTables(jdbcTemplate);
}
示例2: nullSafeGetInternal
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Override
protected Object nullSafeGetInternal(
ResultSet rs, String[] names, Object owner, LobHandler lobHandler)
throws SQLException, IOException, HibernateException {
InputStream is = lobHandler.getBlobAsBinaryStream(rs, names[0]);
if (is != null) {
ObjectInputStream ois = new ObjectInputStream(is);
try {
return ois.readObject();
}
catch (ClassNotFoundException ex) {
throw new HibernateException("Could not deserialize BLOB contents", ex);
}
finally {
ois.close();
}
}
else {
return null;
}
}
示例3: getResultInternal
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Override
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler)
throws SQLException, IOException {
InputStream is = lobHandler.getBlobAsBinaryStream(rs, index);
if (is != null) {
ObjectInputStream ois = new ObjectInputStream(is);
try {
return ois.readObject();
}
catch (ClassNotFoundException ex) {
throw new SQLException("Could not deserialize BLOB contents: " + ex.getMessage());
}
finally {
ois.close();
}
}
else {
return null;
}
}
示例4: SpringJdbcTemplateSamlClientDaoImpl
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
/**
* Creates a new DAO.
*
* @param dataSource
* A data source.
* @param lobHandler
* LOB handler able to read BLOBs and CLOBs. As of Oracle 10.2, DefaultLobHandler should work with standard setup out of the
* box. No need for OracleLobHandler.
* @param tableName
* Name of the table containing configuration records.
* @param environment
* Environment name; to distinguish records for different environments in a single table.
*/
public SpringJdbcTemplateSamlClientDaoImpl(final DataSource dataSource, final LobHandler lobHandler, final String tableName, final String environment) {
super();
CommonHelper.assertNotNull("dataSource", dataSource);
CommonHelper.assertNotNull("lobHandler", lobHandler);
CommonHelper.assertNotBlank("tableName", tableName);
CommonHelper.assertNotBlank("environment", environment);
this.onlyNamesRowMapper = new OnlyNamesRowMapper();
this.fullRowMapper = new SamlClientConfigurationRowMapper(lobHandler);
this.template = new JdbcTemplate(dataSource);
this.environment = environment;
this.selectAllNamesSqlText = String.format(SELECT_ALL_NAMES_SQL_TEXT, tableName);
this.selectAllClientsSqlText = String.format(SELECT_ALL_CLIENTS_SQL_TEXT, tableName);
this.selectSingleClientSqlText = String.format(SELECT_SINGLE_CLIENT_SQL_TEXT, tableName);
this.selectAllNamesParameters = new Object[] {environment};
this.selectAllClientsParameters = new Object[] {environment};
this.selectAllNamesParameterTypes = new int[] {Types.VARCHAR};
this.selectAllClientsParameterTypes = new int[] {Types.VARCHAR};
this.selectSingleClientParameterTypes = new int[] {Types.VARCHAR, Types.VARCHAR};
}
示例5: buildConfig
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
private void buildConfig(final ResultSet rs, final long docId) throws SQLException {
final long docOid = rs.getLong("DOC_OID");
final Timestamp versionFrom = rs.getTimestamp("VER_FROM_INSTANT");
final Timestamp versionTo = rs.getTimestamp("VER_TO_INSTANT");
final Timestamp correctionFrom = rs.getTimestamp("CORR_FROM_INSTANT");
final Timestamp correctionTo = rs.getTimestamp("CORR_TO_INSTANT");
LobHandler lob = getDialect().getLobHandler();
byte[] bytes = lob.getBlobAsBytes(rs, "DETAIL");
ManageableExchange exchange = FUDGE_CONTEXT.readObject(ManageableExchange.class, new ByteArrayInputStream(bytes));
ExchangeDocument doc = new ExchangeDocument();
doc.setUniqueId(createUniqueId(docOid, docId));
doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
doc.setCorrectionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(correctionTo));
doc.setExchange(exchange);
_documents.add(doc);
}
示例6: addExternalIds
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
private void addExternalIds() {
FudgeMsgEnvelope env = s_fudgeContext.toFudgeMsg(ExternalId.of("A", "B"));
byte[] bytes = s_fudgeContext.toByteArray(env.getMessage());
String cls = ExternalId.class.getName();
LobHandler lobHandler = new DefaultLobHandler();
final JdbcOperations template = _cfgMaster.getDbConnector().getJdbcOperations();
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
101, 101, toSqlTimestamp(_version1aInstant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1aInstant), MAX_SQL_TIMESTAMP, "TestConfig101", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
102, 102, toSqlTimestamp(_version1bInstant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1bInstant), MAX_SQL_TIMESTAMP, "TestConfig102", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
201, 201, toSqlTimestamp(_version1cInstant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1cInstant), MAX_SQL_TIMESTAMP, "TestConfig201", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
202, 201, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, "TestConfig202", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
_totalExternalIds = 3;
}
示例7: addExternalIdBundles
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
private void addExternalIdBundles() {
FudgeMsgEnvelope env = s_fudgeContext.toFudgeMsg(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
byte[] bytes = s_fudgeContext.toByteArray(env.getMessage());
String cls = ExternalIdBundle.class.getName();
LobHandler lobHandler = new DefaultLobHandler();
final JdbcOperations template = _cfgMaster.getDbConnector().getJdbcOperations();
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
301, 301, toSqlTimestamp(_version1aInstant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1aInstant), MAX_SQL_TIMESTAMP, "TestConfig301", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
302, 302, toSqlTimestamp(_version1bInstant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1bInstant), MAX_SQL_TIMESTAMP, "TestConfig302", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
401, 401, toSqlTimestamp(_version1cInstant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1cInstant), MAX_SQL_TIMESTAMP, "TestConfig401", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
template.update("INSERT INTO cfg_config VALUES (?,?,?,?,?, ?,?,?,?)",
402, 401, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, "TestConfig402", cls,
new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
_totalBundles = 3;
}
示例8: addUploadContent
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Transactional(readOnly = false)
public int addUploadContent(final String digest, final long fileSize, final InputStream content,
final String contentType) {
LobHandler lobHandler = new DefaultLobHandler();
return jdbc.getJdbcOperations().execute(queries.addUploadContent(),
new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
@Override
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setString(1, digest);
ps.setLong(2, fileSize);
lobCreator.setBlobAsBinaryStream(ps, 3, content, (int) fileSize);
ps.setString(4, contentType);
}
});
}
示例9: insertFile
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
public String insertFile(UploadBase64FileModification file) {
String digest = DigestUtils.sha256Hex(file.getFile());
if(Integer.valueOf(1).equals(repository.isPresent(digest))) {
return digest;
}
LobHandler lobHandler = new DefaultLobHandler();
jdbc.getJdbcOperations().execute(repository.uploadTemplate(),
new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
@Override
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setString(1, digest);
ps.setString(2, file.getName());
ps.setLong(3, file.getFile().length);
lobCreator.setBlobAsBytes(ps, 4, file.getFile());
ps.setString(5, file.getType());
ps.setString(6, Json.GSON.toJson(getAttributes(file)));
}
});
return digest;
}
示例10: saveResource
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
public int saveResource(int organizationId, int eventId, UploadBase64FileModification file) {
if (hasResource(organizationId, eventId, file.getName())) {
uploadedResourceRepository.delete(organizationId, eventId, file.getName());
}
LobHandler lobHandler = new DefaultLobHandler();
return jdbc.getJdbcOperations().execute(uploadedResourceRepository.uploadTemplate(organizationId, eventId, file.getName()),
new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
@Override
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setInt(2, organizationId);
ps.setInt(3, eventId);
setFileValues(ps, lobCreator, file, 3);
}
});
}
示例11: nullSafeGetInternal
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Override
protected Object nullSafeGetInternal(
ResultSet rs, String[] names, Object owner, LobHandler lobHandler)
throws SQLException {
return lobHandler.getBlobAsBytes(rs, names[0]);
}
示例12: nullSafeGetInternal
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Override
protected Object nullSafeGetInternal(
ResultSet rs, String[] names, Object owner, LobHandler lobHandler)
throws SQLException {
return lobHandler.getClobAsString(rs, names[0]);
}
示例13: nullSafeGetInternal
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
@Override
protected Object nullSafeGetInternal(
ResultSet rs, String[] names, Object owner, LobHandler lobHandler)
throws SQLException, UnsupportedEncodingException {
byte[] bytes = lobHandler.getBlobAsBytes(rs, names[0]);
if (bytes != null) {
String encoding = getCharacterEncoding();
return (encoding != null ? new String(bytes, encoding) : new String(bytes));
}
else {
return null;
}
}
示例14: getLobHandler
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
/**
* 根据数据库类型取得LobHander接口的具体实现。
* <p>
* <li>MySQL、MSSQL、DB2等都遵循JDBC标准的BLOB和CLOB操作API,因此使用DefaultLobHander即可</li>
* <li>Oracle9i及以前的版本需要使用OracleLobHandler</li>
* </p>
*
* @return LobHander 特定于数据库的实例
*/
protected LobHandler getLobHandler() {
if (null == this.lobHandler) {
synchronized (this) {
if (null == this.lobHandler) {
LobHandlerResolver lobHandlerResolver = new LobHandlerResolver(
this);
super.getJdbcTemplate().execute(lobHandlerResolver);
}
}
}
return this.lobHandler;
}
示例15: doInConnection
import org.springframework.jdbc.support.lob.LobHandler; //导入依赖的package包/类
public Void doInConnection(Connection connection) throws SQLException,
DataAccessException {
String productName = connection.getMetaData().getDatabaseProductName();
LobHandler lobHandler = null;
if (StringUtils.containsIgnoreCase(productName, ORACLE)) {
lobHandler = createOracleLobHandler();
} else {
lobHandler = createDefaultLobHandler(productName);
}
this.lobStoreServiceImpl.setLobHandler(lobHandler);
return null;
}