PreparedStatement.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:lams 作者:
/**
 * JDBC 2.0 Set a CLOB parameter.
 * 
 * @param i
 *            the first parameter is 1, the second is 2, ...
 * @param x
 *            an object representing a CLOB
 * 
 * @throws SQLException
 *             if a database error occurs
 */
public void setClob(int i, Clob x) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        if (x == null) {
            setNull(i, Types.CLOB);
        } else {

            String forcedEncoding = this.connection.getClobCharacterEncoding();

            if (forcedEncoding == null) {
                setString(i, x.getSubString(1L, (int) x.length()));
            } else {
                try {
                    setBytes(i, StringUtils.getBytes(x.getSubString(1L, (int) x.length()), forcedEncoding));
                } catch (UnsupportedEncodingException uee) {
                    throw SQLError.createSQLException("Unsupported character encoding " + forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
                            getExceptionInterceptor());
                }
            }

            this.parameterTypes[i - 1 + getParameterIndexOffset()] = Types.CLOB;
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号