当前位置: 首页>>代码示例>>Java>>正文


Java PreparedStatement.setCharacterStream方法代码示例

本文整理汇总了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));
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:24,代码来源:TypeDefs.java

示例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");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:DefaultLobHandler.java

示例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() );
			}

		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractHANADialect.java

示例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() );
			}

		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractHANADialect.java

示例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]);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:ImmutableHibernateXStreamType.java

示例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] );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:StringClobType.java

示例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() );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ClobTypeDescriptor.java

示例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() );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:NClobTypeDescriptor.java

示例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);
        }
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:16,代码来源:XmlClobType.java

示例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;
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:20,代码来源:ReaderParameter.java

示例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();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:Wrapper.java

示例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() );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AbstractLongStringType.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AbstractCharArrayType.java

示例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());
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:6,代码来源:ClobTypeHandler.java


注:本文中的java.sql.PreparedStatement.setCharacterStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。