java.sql.PreparedStatement Interface

GemFire XD provides all required JDBC type conversions and additionally allows use of the individual setXXX methods for each type as if a setObject(Value, JDBCTypeCode) invocation were made. This means that setString can be used for any built-in target type. Cursors are not supported in GemFire XD; setCursorName method throws an unsupported feature exception.

Prepared Statements and Streaming Columns

setXXXStream requests stream data between the client and the server. JDBC allows an IN parameter to be set to a Java input stream for passing in large amounts of data in smaller chunks. When the statement is run, the JDBC driver makes repeated calls to this input stream. GemFire XD supports the three types of streams that the JDBC API provides:

The stream object passed to these three methods can be either a standard Java stream object or the user's own subclass that implements the standard java.io.InputStream interface. According to the JDBC standard, streams can be stored only in columns with the data types shown in the following table.

Streamable JDBC Data Types

Column Data Type Corresponding Java Type AsciiStream UnicodeStream BinaryStream
CLOB java.sql.Clob x x '
CHAR ' x x '
VARCHAR ' x x '
LONGVARCHAR ' X X '
BINARY ' x x x
BLOB java.sql.Blob x x x
VARBINARY ' x x x
LONGVARBINARY ' x x X

Note:

Example

The following example shows how a user can store a streamed java.io.File in a LONG VARCHAR column:

Statement s = conn.createStatement();
s.executeUpdate("CREATE TABLE atable (a INT, b LONG VARCHAR)");
conn.commit();
java.io.File file = new java.io.File("derby.txt");
int fileLength = (int) file.length();
// first, create an input stream
java.io.InputStream fin = new java.io.FileInputStream(file);
PreparedStatement ps = conn.prepareStatement("INSERT INTO atable VALUES (?, ?)"); 
ps.setInt(1, 1);
// set the value of the input parameter to the input stream
ps.setAsciiStream(2, fin, fileLength);
ps.execute();
conn.commit();