本文整理汇总了Java中org.springframework.jdbc.support.lob.DefaultLobHandler类的典型用法代码示例。如果您正苦于以下问题:Java DefaultLobHandler类的具体用法?Java DefaultLobHandler怎么用?Java DefaultLobHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultLobHandler类属于org.springframework.jdbc.support.lob包,在下文中一共展示了DefaultLobHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addExternalIds
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的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;
}
示例2: addExternalIdBundles
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的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;
}
示例3: addUploadContent
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的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);
}
});
}
示例4: insertFile
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的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;
}
示例5: saveResource
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的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);
}
});
}
示例6: writeConfiguration
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
/**
* @param serviceID ID of the service for which the configuration will be
* inserted
* @param configurationXMLRepresentation the used MELA configuration to be
* persisted in XML and reused
*/
public void writeConfiguration(final String serviceID, final ConfigurationXMLRepresentation configurationXMLRepresentation) {
final StringWriter stringWriter = new StringWriter();
try {
JAXBContext context = JAXBContext.newInstance(ConfigurationXMLRepresentation.class);
context.createMarshaller().marshal(configurationXMLRepresentation, stringWriter);
} catch (JAXBException e) {
log.warn("Cannot marshal configuration into string: " + e);
return;
}
String sql = "INSERT INTO Configuration (monSeqID, configuration) " + "VALUES (?, ?)";
jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(new DefaultLobHandler()) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setString(1, serviceID);
lobCreator.setClobAsString(ps, 2, stringWriter.toString());
}
});
}
示例7: createDefaultLobHandler
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
/**
* 创建一个通用的的LobHandler,但对SqlServer数据库做了特殊处理.
*
* @param productName
* 数据库驱动的名称
* @return 返回DefaultLobHandler对象
*/
private DefaultLobHandler createDefaultLobHandler(String productName) {
DefaultLobHandler defaultLobHandler = new DefaultLobHandler();
// 为支持sqljdbc4的处理方式,需要将其大对象流包装到BLOB/CLOB里,否则流将被自动关闭
if (StringUtils.containsIgnoreCase(productName, SQLSERVER)) {
defaultLobHandler.setWrapAsLob(true);
}
return defaultLobHandler;
}
示例8: initInMemoryDatabaseAndTemplate
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
@Before
public void initInMemoryDatabaseAndTemplate() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
db = builder.setType(EmbeddedDatabaseType.H2).addScript(PATH_TO_SCRIPT_CREATE_TABLE).addScript(PATH_TO_SCRIPT_FILL_DATA).build();
LobHandler lobHandler = new DefaultLobHandler();
templateUnderTest = new SpringJdbcTemplateSamlClientDaoImpl(db, lobHandler, TABLE_NAME, ENVIRONMENT);
}
示例9: getBlobAsBytes
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
public byte[] getBlobAsBytes() {
return (byte[]) getJdbcTemplate().queryForObject(getSql(), getParams(null), new RowMapper<byte[]>() {
@Override
public byte[] mapRow(ResultSet rs, int rowNum) throws SQLException {
return new DefaultLobHandler().getBlobAsBytes(rs, 1);
}
});
}
示例10: getBlobAsBinaryStream
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
public InputStream getBlobAsBinaryStream(final String columnName) {
return (InputStream) getJdbcTemplate().queryForObject(getSql(), getParams(null), new RowMapper<InputStream>() {
@Override
public InputStream mapRow(ResultSet rs, int rowNum) throws SQLException {
return new DefaultLobHandler().getBlobAsBinaryStream(rs, columnName);
}
});
}
示例11: JbpmClobStringType
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
public JbpmClobStringType() {
super(new DefaultLobHandler(), null);
}
示例12: lobHandler
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
@Bean
public LobHandler lobHandler() {
DefaultLobHandler defaultLobHandler = new DefaultLobHandler();
defaultLobHandler.setStreamAsLob(true);
return defaultLobHandler;
}
示例13: PluginDAOMysqlImpl
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
public PluginDAOMysqlImpl(DataSource dataSource) {
setDataSource(dataSource);
lobHandler = new DefaultLobHandler();
}
示例14: getLobHandler
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
@Override
public LobHandler getLobHandler() {
DefaultLobHandler handler = new DefaultLobHandler();
handler.setWrapAsLob(true);
return handler;
}
示例15: getLobHandler
import org.springframework.jdbc.support.lob.DefaultLobHandler; //导入依赖的package包/类
@Override
public LobHandler getLobHandler() {
DefaultLobHandler handler = new DefaultLobHandler();
handler.setWrapAsLob(false);
return handler;
}