本文整理汇总了Java中org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback类的典型用法代码示例。如果您正苦于以下问题:Java AbstractLobCreatingPreparedStatementCallback类的具体用法?Java AbstractLobCreatingPreparedStatementCallback怎么用?Java AbstractLobCreatingPreparedStatementCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractLobCreatingPreparedStatementCallback类属于org.springframework.jdbc.core.support包,在下文中一共展示了AbstractLobCreatingPreparedStatementCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeBytes
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public String storeBytes(final byte[] content) throws SQLException {
final String sql = "INSERT INTO BDF2_BLOB_STORE(ID_,CONTENT_) VALUES (?,?)";
final String id = this.generateId();
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(1, id);
lobcreator.setBlobAsBytes(preparedstatement, 2, content);
}
});
if (0 == updatedRowCount) {
throw new SQLException("未能成功存储Byte");
}
return id;
}
示例2: updateBytes
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateBytes(final String id, final byte[] content)
throws SQLException {
final String sql = "UPDATE BDF2_BLOB_STORE SET CONTENT_=? WHERE ID_=?";
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
lobcreator
.setBlobAsBytes(preparedstatement, 1, content);
preparedstatement.setString(2, id);
}
});
if (0 == updatedRowCount) {
throw new SQLException(String.format(
"未能成功更新Byte[id=%s],请检查此记录是否存在", id));
}
}
示例3: storeBinaryStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public String storeBinaryStream(final InputStream inputStream,final int contentLength) throws SQLException {
final String sql = "INSERT INTO BDF2_BLOB_STORE (ID_,CONTENT_) VALUES (?,?)";
final String id = this.generateId();
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(1, id);
lobcreator.setBlobAsBinaryStream(preparedstatement, 2,
inputStream, contentLength);
}
});
if (0 == updatedRowCount) {
throw new SQLException("未能成功存储二进制流");
}
return id;
}
示例4: updateBinaryStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateBinaryStream(final String id,
final InputStream inputStream, final int contentLength)
throws SQLException {
final String sql = "UPDATE BDF2_BLOB_STORE SET CONTENT_=? WHERE ID_=?";
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
lobcreator.setBlobAsBinaryStream(preparedstatement, 1,
inputStream, contentLength);
preparedstatement.setString(2, id);
}
});
if (0 == updatedRowCount) {
throw new SQLException(String.format(
"未能成功更新Byte[id=%s],请检查此记录是否存在", id));
}
}
示例5: storeString
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public String storeString(final String content) throws SQLException {
final String sql = "INSERT INTO BDF2_CLOB_STORE (ID_,CONTENT_) VALUES(?,?)";
final String id = this.generateId();
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(1, id);
lobcreator.setClobAsString(preparedstatement, 2,
content);
}
});
if (0 == updatedRowCount) {
throw new SQLException("未能成功储存大字符串");
}
return id;
}
示例6: updateString
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateString(final String id, final String content)
throws SQLException {
final String sql = "UPDATE BDF2_CLOB_STORE SET CONTENT_=? WHERE ID_=?";
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(2, id);
lobcreator.setClobAsString(preparedstatement, 1,
content);
}
});
if (0 == updatedRowCount) {
throw new SQLException(String.format("未能成功更新大字符串[%s],请检查其是否存在", id));
}
}
示例7: storeAsciiStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public String storeAsciiStream(final InputStream asciiStream,
final int contentLength) throws SQLException {
final String sql = "INSERT INTO BDF2_CLOB_STORE (ID_,CONTENT_) VALUES(?,?)";
final String id = this.generateId();
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(1, id);
lobcreator.setClobAsAsciiStream(preparedstatement, 2,
asciiStream, contentLength);
}
});
if (0 == updatedRowCount) {
throw new SQLException("未能成功储存大字符串");
}
return id;
}
示例8: updateAsciiStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateAsciiStream(final String id,
final InputStream asciiStream, final int contentLength)
throws SQLException {
final String sql = "UPDATE BDF2_CLOB_STORE SET CONTENT_=? WHERE ID_=?";
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(2, id);
lobcreator.setClobAsAsciiStream(preparedstatement, 1,
asciiStream, contentLength);
}
});
if (0 == updatedRowCount) {
throw new SQLException(String.format("未能成功更新大字符串[%s],请检查其是否存在", id));
}
}
示例9: storeCharacterStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public String storeCharacterStream(final Reader reader,
final int contentLength) throws SQLException {
final String sql = "INSERT INTO BDF2_CLOB_STORE (ID_,CONTENT_) VALUES(?,?)";
final String id = this.generateId();
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(1, id);
lobcreator.setClobAsCharacterStream(preparedstatement,
2, reader, contentLength);
}
});
if (0 == updatedRowCount) {
throw new SQLException("未能成功储存大字符串");
}
return id;
}
示例10: updateCharacterStream
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateCharacterStream(final String id, final Reader reader,
final int contentLength) throws SQLException {
final String sql = "UPDATE BDF2_CLOB_STORE SET CONTENT_=? WHERE ID_=?";
int updatedRowCount = super.getJdbcTemplate().execute(
sql,
new AbstractLobCreatingPreparedStatementCallback(this
.getLobHandler()) {
@Override
protected void setValues(
PreparedStatement preparedstatement,
LobCreator lobcreator) throws SQLException,
DataAccessException {
preparedstatement.setString(2, id);
lobcreator.setClobAsCharacterStream(preparedstatement,
1, reader, contentLength);
}
});
if (0 == updatedRowCount) {
throw new SQLException(String.format("未能成功更新大字符串[%s],请检查其是否存在", id));
}
}
示例11: insertAndUpdateHelper
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
protected void insertAndUpdateHelper(final CamelContext camelContext, final String key, final Exchange exchange, String sql, final boolean idComesFirst) throws Exception {
final byte[] data = codec.marshallExchange(camelContext, exchange, allowSerializedHeaders);
jdbcTemplate.execute(sql,
new AbstractLobCreatingPreparedStatementCallback(getLobHandler()) {
@Override
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
int totalParameterIndex = 0;
lobCreator.setBlobAsBytes(ps, ++totalParameterIndex, data);
if (idComesFirst) {
ps.setString(++totalParameterIndex, key);
}
if (storeBodyAsText) {
ps.setString(++totalParameterIndex, exchange.getIn().getBody(String.class));
}
if (hasHeadersToStoreAsText()) {
for (String headerName : headersToStoreAsText) {
String headerValue = exchange.getIn().getHeader(headerName, String.class);
ps.setString(++totalParameterIndex, headerValue);
}
}
if (!idComesFirst) {
ps.setString(++totalParameterIndex, key);
}
}
});
}
示例12: storeImage
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
@Transactional
public void storeImage(
final String name, final InputStream contentStream, final int contentLength, final String description)
throws DataAccessException {
getJdbcTemplate().execute(
"INSERT INTO imagedb (image_name, content, description) VALUES (?, ?, ?)",
new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
ps.setString(1, name);
lobCreator.setBlobAsBinaryStream(ps, 2, contentStream, contentLength);
lobCreator.setClobAsString(ps, 3, description);
}
}
);
}
示例13: addUploadContent
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的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);
}
});
}
示例14: saveProcess
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void saveProcess(final Process process) {
super.saveProcess(process);
if(process.getBytes() != null) {
template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
throws SQLException, DataAccessException {
try {
lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
示例15: updateProcess
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; //导入依赖的package包/类
public void updateProcess(final Process process) {
super.updateProcess(process);
if(process.getBytes() != null) {
template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
throws SQLException, DataAccessException {
try {
lobCreator.setBlobAsBytes(ps, 1, process.getBytes());
StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}