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


Java PreparedStatement.setClob方法代码示例

本文整理汇总了Java中java.sql.PreparedStatement.setClob方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setClob方法的具体用法?Java PreparedStatement.setClob怎么用?Java PreparedStatement.setClob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.PreparedStatement的用法示例。


在下文中一共展示了PreparedStatement.setClob方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setClobAsString

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsString(PreparedStatement ps, int paramIndex, String content)
		throws SQLException {

	Clob clob = ps.getConnection().createClob();
	clob.setString(1, content);

	this.temporaryClobs.add(clob);
	ps.setClob(paramIndex, clob);

	if (logger.isDebugEnabled()) {
		logger.debug(content != null ? "Copied string into temporary CLOB with length " + content.length() :
				"Set CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:TemporaryLobCreator.java

示例2: setClobAsAsciiStream

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsAsciiStream(
		PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength)
		throws SQLException {

	Clob clob = ps.getConnection().createClob();
	try {
		FileCopyUtils.copy(asciiStream, clob.setAsciiStream(1));
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
	}

	this.temporaryClobs.add(clob);
	ps.setClob(paramIndex, clob);

	if (logger.isDebugEnabled()) {
		logger.debug(asciiStream != null ?
				"Copied ASCII stream into temporary CLOB with length " + contentLength :
				"Set CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:TemporaryLobCreator.java

示例3: setClobAsCharacterStream

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsCharacterStream(
		PreparedStatement ps, int paramIndex, Reader characterStream, int contentLength)
		throws SQLException {

	Clob clob = ps.getConnection().createClob();
	try {
		FileCopyUtils.copy(characterStream, clob.setCharacterStream(1));
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
	}

	this.temporaryClobs.add(clob);
	ps.setClob(paramIndex, clob);

	if (logger.isDebugEnabled()) {
		logger.debug(characterStream != null ?
				"Copied character stream into temporary CLOB with length " + contentLength :
				"Set CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:TemporaryLobCreator.java

示例4: setClobAsString

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsString(PreparedStatement ps, int paramIndex, final String content)
	throws SQLException {

	if (content != null) {
		Clob clob = (Clob) createLob(ps, true, new LobCallback() {
			@Override
			public void populateLob(Object lob) throws Exception {
				Method methodToInvoke = lob.getClass().getMethod("getCharacterOutputStream", (Class[]) null);
				Writer writer = (Writer) methodToInvoke.invoke(lob, (Object[]) null);
				FileCopyUtils.copy(content, writer);
			}
		});
		ps.setClob(paramIndex, clob);
		if (logger.isDebugEnabled()) {
			logger.debug("Set string for Oracle CLOB with length " + clob.length());
		}
	}
	else {
		ps.setClob(paramIndex, (Clob) null);
		logger.debug("Set Oracle CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:OracleLobHandler.java

示例5: setClobAsAsciiStream

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsAsciiStream(
		PreparedStatement ps, int paramIndex, final InputStream asciiStream, int contentLength)
	throws SQLException {

	if (asciiStream != null) {
		Clob clob = (Clob) createLob(ps, true, new LobCallback() {
			@Override
			public void populateLob(Object lob) throws Exception {
				Method methodToInvoke = lob.getClass().getMethod("getAsciiOutputStream", (Class[]) null);
				OutputStream out = (OutputStream) methodToInvoke.invoke(lob, (Object[]) null);
				FileCopyUtils.copy(asciiStream, out);
			}
		});
		ps.setClob(paramIndex, clob);
		if (logger.isDebugEnabled()) {
			logger.debug("Set ASCII stream for Oracle CLOB with length " + clob.length());
		}
	}
	else {
		ps.setClob(paramIndex, (Clob) null);
		logger.debug("Set Oracle CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:OracleLobHandler.java

示例6: setClobAsCharacterStream

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsCharacterStream(
		PreparedStatement ps, int paramIndex, final Reader characterStream, int contentLength)
	throws SQLException {

	if (characterStream != null) {
		Clob clob = (Clob) createLob(ps, true, new LobCallback() {
			@Override
			public void populateLob(Object lob) throws Exception {
				Method methodToInvoke = lob.getClass().getMethod("getCharacterOutputStream", (Class[]) null);
				Writer writer = (Writer) methodToInvoke.invoke(lob, (Object[]) null);
				FileCopyUtils.copy(characterStream, writer);
			}
		});
		ps.setClob(paramIndex, clob);
		if (logger.isDebugEnabled()) {
			logger.debug("Set character stream for Oracle CLOB with length " + clob.length());
		}
	}
	else {
		ps.setClob(paramIndex, (Clob) null);
		logger.debug("Set Oracle CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:OracleLobHandler.java

示例7: 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

示例8: testNullClob

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void testNullClob() throws Exception {
    createTable("testNullClob", "(field1 TEXT NULL)");

    PreparedStatement pStmt = null;

    try {
        pStmt = this.conn.prepareStatement("INSERT INTO testNullClob VALUES (?)");
        pStmt.setClob(1, null);
        pStmt.executeUpdate();
    } finally {
        if (pStmt != null) {
            pStmt.close();
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:16,代码来源:StatementRegressionTest.java

示例9: setClobAsString

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsString(PreparedStatement ps, int paramIndex, String content)
		throws SQLException {

	if (streamAsLob) {
		if (content != null) {
			ps.setClob(paramIndex, new StringReader(content), content.length());
		}
		else {
			ps.setClob(paramIndex, (Clob) null);
		}
	}
	else if (wrapAsLob) {
		if (content != null) {
			ps.setClob(paramIndex, new PassThroughClob(content));
		}
		else {
			ps.setClob(paramIndex, (Clob) null);
		}
	}
	else {
		ps.setString(paramIndex, content);
	}
	if (logger.isDebugEnabled()) {
		logger.debug(content != null ? "Set string for CLOB with length " + content.length() :
				"Set CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:DefaultLobHandler.java

示例10: setClobAsAsciiStream

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setClobAsAsciiStream(
		PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength)
		throws SQLException {

	if (streamAsLob) {
		if (asciiStream != null) {
			try {
				ps.setClob(paramIndex, new InputStreamReader(asciiStream, "US-ASCII"), contentLength);
			}
			catch (UnsupportedEncodingException ex) {
				throw new SQLException("US-ASCII encoding not supported: " + ex);
			}
		}
		else {
			ps.setClob(paramIndex, (Clob) null);
		}
	}
	else if (wrapAsLob) {
		if (asciiStream != null) {
			ps.setClob(paramIndex, new PassThroughClob(asciiStream, contentLength));
		}
		else {
			ps.setClob(paramIndex, (Clob) null);
		}
	}
	else {
		ps.setAsciiStream(paramIndex, asciiStream, contentLength);
	}
	if (logger.isDebugEnabled()) {
		logger.debug(asciiStream != null ? "Set ASCII stream for CLOB with length " + contentLength :
				"Set CLOB to null");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:DefaultLobHandler.java

示例11: 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

示例12: 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 {
			st.setClob( index, javaTypeDescriptor.unwrap( value, Clob.class, options ) );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ClobTypeDescriptor.java

示例13: testParamSettingWhenUnsupportedTypeSaysUnsupported

import java.sql.PreparedStatement; //导入方法依赖的package包/类
/** Tests that "not supported" has priority over possible "type not supported"
 *  check. */
@Test( expected = SQLFeatureNotSupportedException.class )
public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLException {
  PreparedStatement prepStmt = connection.prepareStatement( "VALUES 1" );
  try {
    prepStmt.setClob( 2, (Clob) null );
  }
  catch ( final SQLFeatureNotSupportedException e ) {
    assertThat(
        "Check whether params.-unsupported wording changed or checks changed.",
        e.toString(), PARAMETERS_NOT_SUPPORTED_MSG_MATCHER );
    throw e;
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:PreparedStatementTest.java


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