本文整理汇总了Java中java.sql.PreparedStatement.setCharacterStream方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setCharacterStream方法的具体用法?Java PreparedStatement.setCharacterStream怎么用?Java PreparedStatement.setCharacterStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement.setCharacterStream方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAppObject
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/** Sets a parameter in the PreparedStatement.
* @param engineType The engine type as defined in init.xml
* @param pstmt The PreparedStatement.
* @param parameterIndex The index of the parameter that is to be set.
* @param value The object to be assigned to the parameter.
* @throws SQLException if a database access error occurs.
*/
public void setAppObject(PreparedStatement pstmt, int parameterIndex, Object value, String engineType)
throws SQLException {
if (value != null) {
if (!(value instanceof String))
value = DataTypeMapper.instance().map(value, String.class);
if ("oracle".equalsIgnoreCase(engineType) && !supportsStdLob(pstmt)) {
Clob clob = createClob(pstmt.getConnection(), (String) value);
pstmt.setClob(parameterIndex, clob);
} else {
String str = (String) value;
Reader reader = new BufferedReader(new StringReader(str));
pstmt.setCharacterStream(parameterIndex, reader, str.length());
}
} else
pstmt.setNull(parameterIndex, getSqlType(Defaults.CLOB, engineType));
}
示例2: setClobAsCharacterStream
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsCharacterStream(
PreparedStatement ps, int paramIndex, Reader characterStream, int contentLength)
throws SQLException {
if (streamAsLob) {
if (characterStream != null) {
ps.setClob(paramIndex, characterStream, contentLength);
}
else {
ps.setClob(paramIndex, (Clob) null);
}
}
else if (wrapAsLob) {
if (characterStream != null) {
ps.setClob(paramIndex, new PassThroughClob(characterStream, contentLength));
}
else {
ps.setClob(paramIndex, (Clob) null);
}
}
else {
ps.setCharacterStream(paramIndex, characterStream, contentLength);
}
if (logger.isDebugEnabled()) {
logger.debug(characterStream != null ? "Set character stream for CLOB with length " + contentLength :
"Set CLOB to null");
}
}
示例3: getClobBinder
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(final PreparedStatement st, final X value, final int index,
final WrapperOptions options) throws SQLException {
final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class,
options );
if ( value instanceof ClobImplementer ) {
st.setCharacterStream( index, new CloseSuppressingReader( characterStream.asReader() ),
characterStream.getLength() );
}
else {
st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
}
}
};
}
示例4: getNClobBinder
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> BasicBinder<X> getNClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(final PreparedStatement st, final X value, final int index,
final WrapperOptions options) throws SQLException {
final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class,
options );
if ( value instanceof NClobImplementer ) {
st.setCharacterStream( index, new CloseSuppressingReader( characterStream.asReader() ),
characterStream.getLength() );
}
else {
st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
}
}
};
}
示例5: nullSafeSet
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index) throws SQLException
{
if( value != null )
{
String string = xstream.serialiseToXml(value);
StringReader reader = new StringReader(string);
st.setCharacterStream(index, reader, string.length());
}
else
{
st.setNull(index, sqlTypes()[0]);
}
}
示例6: nullSafeSet
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
if ( value != null ) {
String string = (String) value;
StringReader reader = new StringReader( string );
st.setCharacterStream( index, reader, string.length() );
}
else {
st.setNull( index, sqlTypes()[0] );
}
}
示例7: getClobBinder
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
throws SQLException {
final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class, options );
st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
}
};
}
示例8: getNClobBinder
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> BasicBinder<X> getNClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
throws SQLException {
final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class, options );
st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
}
};
}
示例9: nullSafeSet
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
if (value == null) {
ps.setNull(index, sqlTypes()[0]);
} else {
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
XMLWriter writer = new XMLWriter(bytes,OutputFormat.createCompactFormat());
writer.write((Document)value);
writer.flush(); writer.close();
ps.setCharacterStream(index, new CharArrayReader(bytes.toString().toCharArray(),0,bytes.size()), bytes.size());
} catch (IOException e) {
throw new HibernateException(e.getMessage(),e);
}
}
}
示例10: setReaderParameter
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* ステートメントにストリームパラメータを登録。
*
* @param preparedStatement ステートメント
* @param index パラメータインデックス
* @return 次のパラメータインデックス
* @throws SQLException SQL例外
*/
protected int setReaderParameter(final PreparedStatement preparedStatement, int index) throws SQLException {
if (len > -1) {
preparedStatement.setCharacterStream(index, reader, len);
} else {
preparedStatement.setCharacterStream(index, reader);
}
parameterLog(index);
index++;
return index;
}
示例11: addToPartRem
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private void addToPartRem(Connection connection)
throws SQLException {
//String sql = "insert into ZZ_JUT_PART_REM VALUES('Z-TESTPART-01', 'SOME REMARKS'";
//executeSql(connection, sql);
// the following is needed, since jdbc requires that fields having 4000+ characters be passed in via streams
String sql = "insert into ZZ_JUT_PART_REM VALUES(?,?)";
PreparedStatement pstmnt = connection.prepareStatement(sql);
pstmnt.setString(1, "Z-TESTPART-01");
pstmnt.setCharacterStream(2, new BufferedReader(new StringReader(CATZ_REMARKS)), CATZ_REMARKS.length());
pstmnt.execute();
pstmnt.close();
}
示例12: set
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
String str = (String) value;
st.setCharacterStream( index, new StringReader(str), str.length() );
}
示例13: set
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void set(PreparedStatement st, Object value, int index) throws SQLException {
char[] chars = toInternalFormat( value );
st.setCharacterStream(index, new CharArrayReader(chars), chars.length);
}
示例14: setNonNullParameter
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException {
StringReader reader = new StringReader(parameter);
ps.setCharacterStream(i, reader, parameter.length());
}