Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Firebird Open Source J2ee connector - jdbc driver
   *
   * Distributable under LGPL license.
   * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * LGPL License for more details.
  *
  * This file was created by members of the firebird development team.
  * All individual contributions remain the Copyright (C) of those
  * individuals.  Contributors to this file are either listed here or
  * can be obtained from a CVS history command.
  *
  * All rights reserved.
  */
 
 package org.firebirdsql.jdbc;
 
 import java.io.Reader;
 import java.io.Writer;
 import java.sql.Clob;
The mapping in the JavaTM programming language for the SQL CLOB type. An SQL CLOB is a built-in type that stores a Character Large Object as a column value in a row of a database table. CLOBS are not currently supported by the Jaybird driver. The Clob interface provides methods for getting the length of an SQL CLOB (Character Large Object) value, for materializing a CLOB value on the client, and for searching for a substring or CLOB object within a CLOB value. Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getClob and setClob allow a programmer to access an SQL CLOB value. In addition, this interface has methods for updating a CLOB value.

Author(s):
David Jencks
Version:
1.0
 
 public class FBClob implements Clob {
 
 	private FBBlob wrappedBlob;
 
 	public FBClob(FBBlob blob) {
 		this. = blob;
 	}

Returns the number of characters in the CLOB value designated by this Clob object.

Returns:
length of the CLOB in characters
Throws:
java.sql.SQLException if there is an error accessing the length of the CLOB
Since:
1.2
See also:
What Is in the JDBC 2.0 API
 
 	public long length() throws SQLException {
 	}

This operation is not currently supported Truncate this Clob to a given length.

Parameters:
param1 The length to truncate this Clob to
Throws:
java.sql.SQLException this operation is not supported
 
 	public void truncate(long param1throws SQLException {
 	}

Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring begins at position pos and has up to length consecutive characters.

Parameters:
pos the first character of the substring to be extracted. The first character is at position 1.
length the number of consecutive characters to be copied
Returns:
a String that is the specified substring in the CLOB value designated by this Clob object
Throws:
java.sql.SQLException if there is an error accessing the CLOB
Since:
1.2
See also:
What Is in the JDBC 2.0 API
	public String getSubString(long posint lengththrows SQLException {
		try {
		    long toSkip = pos - 1; // 1-based index
		    while (toSkip > 0) {
		        toSkip -= reader.skip(toSkip);
		    }
		    int n;
		    char[] buffer = new char[1024];
		    StringBuffer stringBuffer = new StringBuffer();
			while (length > 0 && (n = reader.read(buffer, 0, Math.min(lengthbuffer.length))) != -1) {
				stringBuffer.append(buffer, 0, Math.min(nlength));
				length -= n;
			}
			return stringBuffer.toString();
catch (IOException e) {
			throw new FBSQLException(e);
finally {
			try {
                reader.close();
            } catch (IOException e) {
                throw new FBSQLException(e);
            }
		}
	}

Gets the CLOB value designated by this Clob object as a Unicode stream.

Returns:
a Unicode stream containing the CLOB data
Throws:
java.sql.SQLException if there is an error accessing the CLOB value
Since:
1.2
See also:
What Is in the JDBC 2.0 API
	public Reader getCharacterStream() throws SQLException {
		if (encoding == null) {
			return new InputStreamReader(inputStream);
else {
			try {
						encoding);
catch (IOException ioe) {
				throw new FBSQLException(ioe);
			}
		}
	}

Gets the CLOB value designated by this Clob object as a stream of Ascii bytes.

Returns:
an ascii stream containing the CLOB data
Throws:
java.sql.SQLException if there is an error accessing the CLOB value
Since:
1.2
See also:
What Is in the JDBC 2.0 API
		InputStream inputStream = null;
		if ( != null) {
			inputStream = .getBinaryStream();
		}
		return inputStream;
	}

Determines the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object. The search begins at position start.

Parameters:
searchstr the substring for which to search
start the position at which to begin searching; the first position is 1
Returns:
the position at which the substring appears, else -1; the first position is 1
Throws:
java.sql.SQLException if there is an error accessing the CLOB value
Since:
1.2
See also:
What Is in the JDBC 2.0 API
	public long position(String searchstrlong startthrows SQLException {
	}

Determines the character position at which the specified Clob object searchstr appears in this Clob object. The search begins at position start.

Parameters:
searchstr the Clob object for which to search
start the position at which to begin searching; the first position is 1
Returns:
the position at which the Clob object appears, else -1; the first position is 1
Throws:
java.sql.SQLException if there is an error accessing the CLOB value
Since:
1.2
See also:
What Is in the JDBC 2.0 API
	public long position(Clob searchstrlong startthrows SQLException {
	}

This operation is not supported Writes the given Java String to the CLOB value that this Clob object designates at the position pos.

Parameters:
start position at which to start writing
searchString The String value to write
Returns:
The number of characters written
Throws:
java.sql.SQLException because this operation is not supported
	public int setString(long startString searchStringthrows SQLException {
	}

This operation is not supported

Parameters:
param1 <description>
param2 <description>
param3 <description>
param4 <description>
Returns:
<description>
Throws:
java.sql.SQLException <description>
	public int setString(long param1String param2int param3int param4)
			throws SQLException {
	}

Set a byte stream to write the contents of this Clob.

Parameters:
pos The position at which writing is to start.
Returns:
<description>
Throws:
java.sql.SQLException <description>
	public OutputStream setAsciiStream(long posthrows SQLException {
	}

Create a writer to add character data to this Clob.

Parameters:
position The position at which the Writer should start writing
Returns:
<description>
Throws:
java.sql.SQLException <description>
	public Writer setCharacterStream(long positionthrows SQLException {
		OutputStream outputStream = .setBinaryStream(position);
		if (encoding == null) {
			return new OutputStreamWriter(outputStream);
else {
			try {
				return new OutputStreamWriter(outputStreamencoding);
catch (UnsupportedEncodingException ioe) {
				throw new FBSQLException(ioe);
			}
		}
	}
	public void free() throws SQLException {
	}
	public Reader getCharacterStream(long poslong lengththrows SQLException {
		InputStream inputStream = .getBinaryStream(poslength);
		if (encoding == null) {
			return new InputStreamReader(inputStream);
else {
			try {
				return new InputStreamReader(inputStreamencoding);
catch (IOException ioe) {
				throw new FBSQLException(ioe);
			}
		}
	}
	public void copyCharacterStream(Reader characterStreamthrows SQLException {
		Writer writer = setCharacterStream(1);
		try {
			int chunk = 0;
			char[] buffer = new char[1024];
			while ((chunk = characterStream.read(buffer)) != -1)
				writer.write(buffer, 0, chunk);
			writer.flush();
			writer.close();
catch (IOException ioe) {
			throw new FBSQLException(ioe);
		}
	}
	public FBBlob getWrappedBlob() throws SQLException {
		return ;
	}
New to GrepCode? Check out our FAQ X