Java 类java.sql.Clob 实例源码

项目:BibliotecaPS    文件:ResultSetRegressionTest.java   
/**
 * Tests for fix to BUG#1130
 * 
 * @throws Exception
 *             if the test fails
 */
public void testClobTruncate() throws Exception {
    createTable("testClobTruncate", "(field1 TEXT)");
    this.stmt.executeUpdate("INSERT INTO testClobTruncate VALUES ('abcdefg')");

    this.rs = this.stmt.executeQuery("SELECT * FROM testClobTruncate");
    this.rs.next();

    Clob clob = this.rs.getClob(1);
    clob.truncate(3);

    Reader reader = clob.getCharacterStream();
    char[] buf = new char[8];
    int charsRead = reader.read(buf);

    String clobAsString = new String(buf, 0, charsRead);

    assertTrue(clobAsString.equals("abc"));
}
项目:lams    文件:OracleLobHandler.java   
@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");
    }
}
项目:lams    文件:OracleLobHandler.java   
@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");
    }
}
项目:lams    文件:DefaultLobHandler.java   
@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");
    }
}
项目:lams    文件:PreparedStatement.java   
/**
 * 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;
        }
    }
}
项目:ProyectoPacientes    文件:BlobRegressionTest.java   
/**
 * Tests fix for BUG#20453671 - CLOB.POSITION() API CALL WITH CLOB INPUT RETURNS EXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20453671() throws Exception {
    this.rs = this.stmt.executeQuery("select 'abcd', 'a', 'b', 'c', 'd', 'e'");
    this.rs.next();

    final Clob in = this.rs.getClob(1);
    final ResultSet locallyScopedRs = this.rs;
    assertThrows(SQLException.class, "Illegal starting position for search, '0'", new Callable<Void>() {
        public Void call() throws Exception {
            in.position(locallyScopedRs.getClob(2), 0);
            return null;
        }
    });
    assertThrows(SQLException.class, "Starting position for search is past end of CLOB", new Callable<Void>() {
        public Void call() throws Exception {
            in.position(locallyScopedRs.getClob(2), 10);
            return null;
        }
    });

    assertEquals(1, in.position(this.rs.getClob(2), 1));
    assertEquals(2, in.position(this.rs.getClob(3), 1));
    assertEquals(3, in.position(this.rs.getClob(4), 1));
    assertEquals(4, in.position(this.rs.getClob(5), 1));
    assertEquals(-1, in.position(this.rs.getClob(6), 1));
}
项目:rapidminer    文件:DatabaseDataSet.java   
public String getString(int columnIndex) throws ParseException {
    try {
        String valueString;
        if(DatabaseDataSet.this.metaData.getColumnType(this.getDatabaseColumnIndex(columnIndex)) == 2005) {
            Clob e = DatabaseDataSet.this.resultSet.getClob(this.getDatabaseColumnIndex(columnIndex));
            if(e != null) {
                try {
                    valueString = Tools.readTextFile(e.getCharacterStream());
                } catch (IOException var5) {
                    throw new ParseException(var5.getMessage(), var5);
                }
            } else {
                valueString = null;
            }
        } else {
            valueString = DatabaseDataSet.this.resultSet.getString(this.getDatabaseColumnIndex(columnIndex));
        }

        return DatabaseDataSet.this.resultSet.wasNull()?null:valueString;
    } catch (SQLException var6) {
        throw new ParseException(var6.getMessage(), var6);
    }
}
项目:OpenDiabetes    文件:JDBCClobClient.java   
/**
 * Retrieves the character position at which the specified
 * <code>Clob</code> object <code>searchstr</code> appears in this
 * <code>Clob</code> object.
 *
 * @param searchstr the <code>Clob</code> object for which to search
 * @param start the position at which to begin searching; the first
 *   position is 1
 * @return the position at which the <code>Clob</code> object appears or
 *   -1 if it is not present; the first position is 1
 * @throws SQLException if there is an error accessing the
 *   <code>CLOB</code> value
 */
public synchronized long position(Clob searchstr,
                                  long start) throws SQLException {

    if (!isInLimits(Long.MAX_VALUE, start - 1, 0)) {
        throw JDBCUtil.outOfRangeArgument();
    }

    if (searchstr instanceof JDBCClobClient) {
        ClobDataID searchClob = ((JDBCClobClient) searchstr).clob;

        try {
            return clob.position(session, searchClob, start - 1);
        } catch (HsqlException e) {
            throw JDBCUtil.sqlException(e);
        }
    }

    return position(searchstr.getSubString(1, (int) searchstr.length()),
                    start);
}
项目:QDrill    文件:PreparedStatementTest.java   
/** 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;
  }
}
项目:lams    文件:JdbcTypeJavaClassMappings.java   
private static ConcurrentHashMap<Class, Integer> buildJdbcJavaClassMappings() {
    ConcurrentHashMap<Class, Integer> jdbcJavaClassMappings = new ConcurrentHashMap<Class, Integer>();

    // these mappings are the ones outlined specifically in the spec
    jdbcJavaClassMappings.put( String.class, Types.VARCHAR );
    jdbcJavaClassMappings.put( BigDecimal.class, Types.NUMERIC );
    jdbcJavaClassMappings.put( Boolean.class, Types.BIT );
    jdbcJavaClassMappings.put( Integer.class, Types.INTEGER );
    jdbcJavaClassMappings.put( Long.class, Types.BIGINT );
    jdbcJavaClassMappings.put( Float.class, Types.REAL );
    jdbcJavaClassMappings.put( Double.class, Types.DOUBLE );
    jdbcJavaClassMappings.put( byte[].class, Types.LONGVARBINARY );
    jdbcJavaClassMappings.put( java.sql.Date.class, Types.DATE );
    jdbcJavaClassMappings.put( Time.class, Types.TIME );
    jdbcJavaClassMappings.put( Timestamp.class, Types.TIMESTAMP );
    jdbcJavaClassMappings.put( Blob.class, Types.BLOB );
    jdbcJavaClassMappings.put( Clob.class, Types.CLOB );
    jdbcJavaClassMappings.put( Array.class, Types.ARRAY );
    jdbcJavaClassMappings.put( Struct.class, Types.STRUCT );
    jdbcJavaClassMappings.put( Ref.class, Types.REF );
    jdbcJavaClassMappings.put( Class.class, Types.JAVA_OBJECT );

    // additional "common sense" registrations
    jdbcJavaClassMappings.put( Character.class, Types.CHAR );
    jdbcJavaClassMappings.put( char[].class, Types.VARCHAR );
    jdbcJavaClassMappings.put( Character[].class, Types.VARCHAR );
    jdbcJavaClassMappings.put( Byte[].class, Types.LONGVARBINARY );
    jdbcJavaClassMappings.put( java.util.Date.class, Types.TIMESTAMP );
    jdbcJavaClassMappings.put( Calendar.class, Types.TIMESTAMP );

    return jdbcJavaClassMappings;
}
项目:OpenVertretung    文件:ServerPreparedStatement.java   
/**
 * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
 */
@Override
public void setClob(int parameterIndex, Clob x) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {

        if (x == null) {
            setNull(parameterIndex, java.sql.Types.BINARY);
        } else {
            BindValue binding = getBinding(parameterIndex, true);
            resetToType(binding, MysqlDefs.FIELD_TYPE_BLOB);

            binding.value = x.getCharacterStream();
            binding.isLongData = true;

            if (this.connection.getUseStreamLengthsInPrepStmts()) {
                binding.bindLength = x.length();
            } else {
                binding.bindLength = -1;
            }
        }
    }
}
项目:ChronoBike    文件:SQLClause.java   
/**Added by Jilali Raki. Needed for ROA
 * 
 * @param nColNumber  Column number
 * @return Serial Clob data
 * @throws TechnicalException
 */
public SerialClob getClob(int nColNumber) throws TechnicalException
{       
    if(m_resultSet != null)
    {
        try
        {
            Clob blVal = m_resultSet.getClob(nColNumber);
            SerialClob sb = new SerialClob(blVal); 
            return sb;
        }
        catch (SQLException e)
        {
            forceCloseOnExceptionCatched();
            ProgrammingException.throwException(ProgrammingException.DB_ERROR_RESULT_SET_COL_ACCESS_INT+nColNumber, m_csQuery, e);
        }           
    }
    return null;
}
项目:the-vigilantes    文件:BlobRegressionTest.java   
/**
 * Tests fix for BUG#20453671 - CLOB.POSITION() API CALL WITH CLOB INPUT RETURNS EXCEPTION
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20453671() throws Exception {
    this.rs = this.stmt.executeQuery("select 'abcd', 'a', 'b', 'c', 'd', 'e'");
    this.rs.next();

    final Clob in = this.rs.getClob(1);
    final ResultSet locallyScopedRs = this.rs;
    assertThrows(SQLException.class, "Illegal starting position for search, '0'", new Callable<Void>() {
        public Void call() throws Exception {
            in.position(locallyScopedRs.getClob(2), 0);
            return null;
        }
    });
    assertThrows(SQLException.class, "Starting position for search is past end of CLOB", new Callable<Void>() {
        public Void call() throws Exception {
            in.position(locallyScopedRs.getClob(2), 10);
            return null;
        }
    });

    assertEquals(1, in.position(this.rs.getClob(2), 1));
    assertEquals(2, in.position(this.rs.getClob(3), 1));
    assertEquals(3, in.position(this.rs.getClob(4), 1));
    assertEquals(4, in.position(this.rs.getClob(5), 1));
    assertEquals(-1, in.position(this.rs.getClob(6), 1));
}
项目:the-vigilantes    文件:CallableStatement.java   
/**
 * @see java.sql.CallableStatement#getClob(int)
 */
public Clob getClob(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Clob retValue = rs.getClob(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
项目:incubator-netbeans    文件:SuperPatternFilter.java   
protected boolean testValue(final Object value) {
    if (value == null) {
        return false;
    }
    final String valueStr;
    if (value instanceof Blob) {
        valueStr = LobHelper.blobToString((Blob) value);
    } else if (value instanceof Clob) {
        valueStr = LobHelper.clobToString((Clob) value);
    } else {
        valueStr = value.toString();
    }
    switch (mode) {
        case LITERAL_FIND:
            if (filterStr == null || filterStr.length() == 0) {
            return true;
        } else {
            return valueStr.toUpperCase().contains(filterStr.toUpperCase());
        }
        case LITERAL_MATCH:
            if (filterStr == null || filterStr.length() == 0) {
            return true;
        } else {
            return filterStr.equals(valueStr);
        }
        case REGEX_FIND:
            return pattern.matcher(valueStr).find();
        case REGEX_MATCH:
            return pattern.matcher(valueStr).matches();
        default:
            throw new RuntimeException(UNKOWN_MODE);
    }
}
项目:the-vigilantes    文件:CallableStatementWrapper.java   
public Clob getClob(String parameterName) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            return ((CallableStatement) this.wrappedStmt).getClob(parameterName);
        }
        throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);

    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
    return null;
}
项目:jdk8u-jdk    文件:SQLOutputImplTests.java   
@Test(enabled = true)
public void test06() throws Exception {
    Clob c = new StubClob();
    outImpl.writeClob(c);
    SerialClob sc = (SerialClob) results.get(0);
    assertTrue(c.getSubString(1,
            (int) c.length()).equals(sc.getSubString(1, (int) sc.length())));
}
项目:OpenVertretung    文件:BlobRegressionTest.java   
/**
 * Tests fix for BUG#20453712 - CLOB.SETSTRING() WITH VALID INPUT RETURNS EXCEPTION
 * server-side prepared statements and streaming BINARY data.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20453712() throws Exception {
    final String s1 = "NewClobData";
    this.rs = this.stmt.executeQuery("select 'a'");
    this.rs.next();
    final Clob c1 = this.rs.getClob(1);

    // check with wrong position
    assertThrows(SQLException.class, "Starting position can not be < 1", new Callable<Void>() {
        public Void call() throws Exception {
            c1.setString(0, s1, 7, 4);
            return null;
        }
    });

    // check with wrong substring index
    assertThrows(SQLException.class, "String index out of range: 12", new Callable<Void>() {
        public Void call() throws Exception {
            c1.setString(1, s1, 8, 4);
            return null;
        }
    });

    // full replace
    c1.setString(1, s1, 3, 4);
    assertEquals("Clob", c1.getSubString(1L, (int) c1.length()));

    // add
    c1.setString(5, s1, 7, 4);
    assertEquals("ClobData", c1.getSubString(1L, (int) c1.length()));

    // replace middle chars
    c1.setString(2, s1, 7, 4);
    assertEquals("CDataata", c1.getSubString(1L, (int) c1.length()));
}
项目:ProyectoPacientes    文件:CallableStatementWrapper.java   
public Clob getClob(String parameterName) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            return ((CallableStatement) this.wrappedStmt).getClob(parameterName);
        }
        throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);

    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
    return null;
}
项目:lams    文件:AbstractLobCreator.java   
@Override
public Clob wrap(Clob clob) {
    if ( NClob.class.isInstance( clob ) ) {
        return wrap( (NClob) clob );
    }
    else {
        return SerializableClobProxy.generateProxy( clob );
    }
}
项目:lams    文件:OracleLobHandler.java   
@Override
public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException {
    logger.debug("Returning Oracle CLOB as character stream");
    Clob clob = rs.getClob(columnIndex);
    initializeResourcesBeforeRead(rs.getStatement().getConnection(), clob);
    Reader retVal = (clob != null ? clob.getCharacterStream() : null);
    releaseResourcesAfterRead(rs.getStatement().getConnection(), clob);
    return retVal;
}
项目:lams    文件:ContextualLobCreator.java   
@Override
public Clob createClob(String string) {
    try {
        final Clob clob = createClob();
        clob.setString( 1, string );
        return clob;
    }
    catch ( SQLException e ) {
        throw new JDBCException( "Unable to set CLOB string after creation", e );
    }
}
项目:BibliotecaPS    文件:CallableStatement.java   
/**
 * @see java.sql.CallableStatement#getClob(int)
 */
public Clob getClob(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Clob retValue = rs.getClob(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
项目:BibliotecaPS    文件:CallableStatementWrapper.java   
public Clob getClob(String parameterName) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            return ((CallableStatement) this.wrappedStmt).getClob(parameterName);
        }
        throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);

    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
    return null;
}
项目:sstore-soft    文件:JDBCPreparedStatement.java   
private void setClobForStringParameter(int parameterIndex,
        Clob x) throws SQLException {

    if (x instanceof JDBCClob) {
        setParameter(parameterIndex, ((JDBCClob) x).data());

        return;
    } else if (x == null) {
        setParameter(parameterIndex, null);

        return;
    }
    checkSetParameterIndex(parameterIndex, false);

    final long length = x.length();

    if (length > Integer.MAX_VALUE) {
        String msg = "Max Clob input character length exceeded: " + length;    // NOI18N

        throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
    }

    try {
        java.io.Reader  reader = x.getCharacterStream();
        CharArrayWriter writer = new CharArrayWriter(reader, (int) length);

        setParameter(parameterIndex, writer.toString());
    } catch (IOException e) {
        throw Util.sqlException(ErrorCode.SERVER_TRANSFER_CORRUPTED,
                                e.toString());
    }
}
项目:dremio-oss    文件:PreparedStatementTest.java   
/** Tests that "not supported" has priority over possible "type not supported"
 *  check. */
@Test( expected = SQLFeatureNotSupportedException.class )
public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLException {
  try(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;
    }
  }
}
项目:tangyuan2    文件:ClobTypeHandler.java   
@Override
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnName);
    if (clob != null) {
        int size = (int) clob.length();
        value = clob.getSubString(1, size);
    }
    return value;
}
项目:OpenVertretung    文件:CallableStatement.java   
/**
 * @see java.sql.CallableStatement#getClob(int)
 */
public Clob getClob(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Clob retValue = rs.getClob(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
项目:the-vigilantes    文件:BlobRegressionTest.java   
/**
 * Tests fix for BUG#20453712 - CLOB.SETSTRING() WITH VALID INPUT RETURNS EXCEPTION
 * server-side prepared statements and streaming BINARY data.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20453712() throws Exception {
    final String s1 = "NewClobData";
    this.rs = this.stmt.executeQuery("select 'a'");
    this.rs.next();
    final Clob c1 = this.rs.getClob(1);

    // check with wrong position
    assertThrows(SQLException.class, "Starting position can not be < 1", new Callable<Void>() {
        public Void call() throws Exception {
            c1.setString(0, s1, 7, 4);
            return null;
        }
    });

    // check with wrong substring index
    assertThrows(SQLException.class, "String index out of range: 12", new Callable<Void>() {
        public Void call() throws Exception {
            c1.setString(1, s1, 8, 4);
            return null;
        }
    });

    // full replace
    c1.setString(1, s1, 3, 4);
    assertEquals("Clob", c1.getSubString(1L, (int) c1.length()));

    // add
    c1.setString(5, s1, 7, 4);
    assertEquals("ClobData", c1.getSubString(1L, (int) c1.length()));

    // replace middle chars
    c1.setString(2, s1, 7, 4);
    assertEquals("CDataata", c1.getSubString(1L, (int) c1.length()));
}
项目:lams    文件:CallableStatement.java   
/**
 * @see java.sql.CallableStatement#getClob(java.lang.String)
 */
public Clob getClob(String parameterName) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?=

        Clob retValue = rs.getClob(fixParameterName(parameterName));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
项目:tangyuan2    文件:NClobTypeHandler.java   
@Override
public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
    String value = "";
    Clob clob = rs.getClob(columnIndex);
    if (clob != null) {
        int size = (int) clob.length();
        value = clob.getSubString(1, size);
    }
    return value;
}
项目:s-store    文件:JDBCPreparedStatement.java   
private void setClobForStringParameter(int parameterIndex,
        Clob x) throws SQLException {

    if (x instanceof JDBCClob) {
        setParameter(parameterIndex, ((JDBCClob) x).data());

        return;
    } else if (x == null) {
        setParameter(parameterIndex, null);

        return;
    }
    checkSetParameterIndex(parameterIndex, false);

    final long length = x.length();

    if (length > Integer.MAX_VALUE) {
        String msg = "Max Clob input character length exceeded: " + length;    // NOI18N

        throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
    }

    try {
        java.io.Reader  reader = x.getCharacterStream();
        CharArrayWriter writer = new CharArrayWriter(reader, (int) length);

        setParameter(parameterIndex, writer.toString());
    } catch (IOException e) {
        throw Util.sqlException(ErrorCode.SERVER_TRANSFER_CORRUPTED,
                                e.toString());
    }
}
项目:the-vigilantes    文件:JDBC4ConnectionWrapper.java   
/**
 * @see java.sql.Connection#createClob()
 */
public Clob createClob() throws SQLException {
    checkClosed();

    try {
        return ((java.sql.Connection) this.mc).createClob();
    } catch (SQLException sqlException) {
        checkAndFireConnectionError(sqlException);
    }

    return null; // never reached, but compiler can't tell
}
项目:jdk8u-jdk    文件:StubJoinRowSetImpl.java   
@Override
public void setClob(String parameterName, Clob x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:dswork    文件:CallableStatementSpy.java   
public void setClob(String parameterName, Clob x) throws SQLException
{
    realCallableStatement.setClob(parameterName, x);
}
项目:GitHub    文件:ClobSeriliazerTest.java   
public void setValue(Clob value) {
    this.value = value;
}
项目:dev-courses    文件:JDBCResultSet.java   
/**
 * <!-- start generic documentation -->
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.io.Reader</code> object.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * HSQLDB supports this feature. <p>
 * </div>
 * <!-- end release-specific documentation -->
 *
 * @return a <code>java.io.Reader</code> object that contains the column
 * value; if the value is SQL <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language.
 * @param columnIndex the first column is 1, the second is 2, ...
 * @exception SQLException if a database access error occurs or this method is
 *            called on a closed result set
 * @since JDK 1.2
 */
public java.io.Reader getCharacterStream(
        int columnIndex) throws SQLException {

    checkColumn(columnIndex);

    Type   sourceType = resultMetaData.columnTypes[columnIndex - 1];
    Object o          = getColumnInType(columnIndex, sourceType);

    if (o == null) {
        return null;
    }

    if (o instanceof ClobDataID) {
        return ((ClobDataID) o).getCharacterStream(session);
    } else if (o instanceof Clob) {
        return ((Clob) o).getCharacterStream();
    } else if (o instanceof String) {
        return new StringReader((String) o);
    }

    throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
项目:openjdk-jdk10    文件:StubSyncResolver.java   
@Override
public void updateClob(int columnIndex, Clob x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:the-vigilantes    文件:JDBC4LoadBalancedMySQLConnection.java   
/**
 * @see java.sql.Connection#createClob()
 */
public Clob createClob() {
    return this.getJDBC4Connection().createClob();
}
项目:blanco-sfdc-jdbc-driver    文件:AbstractBlancoGenericJdbcConnection.java   
public Clob createClob() throws SQLException {
    throw new SQLException("Not Implemented: createClob()");
}