setXXXStream requests stream data between the application and the database.
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 executed, the JDBC driver makes repeated calls to this input stream, reading its contents and transmitting those contents as the parameter data.
for streams containing uninterpreted bytes
for streams containing ASCII characters
for streams containing Unicode characters
JDBC 2.0 and JDBC 3.0 require that you specify the length of the stream and Derby enforces this requirement if your application runs on JDK 1.5 or earlier. If your application runs on JDK 1.6, then Derby exposes a JDBC 4.0 implementation, which lets you use the streaming interfaces without having to specify the stream length. 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.
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();