Java Code Examples for java.sql.ResultSet.updateBinaryStream()

The following are Jave code examples for showing how to use updateBinaryStream() of the java.sql.ResultSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: the-vigilantes   File: StatementRegressionTest.java   View Source Code Vote up 6 votes
/**
 * Tests fix for updatable streams being supported in updatable result sets.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testUpdatableStream() throws Exception {
    try {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
        this.stmt.executeUpdate("CREATE TABLE updateStreamTest (keyField INT NOT NULL AUTO_INCREMENT PRIMARY KEY, field1 BLOB)");

        int streamLength = 16385;
        byte[] streamData = new byte[streamLength];

        /* create an updatable statement */
        Statement updStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

        /* fill the resultset with some values */
        ResultSet updRs = updStmt.executeQuery("SELECT * FROM updateStreamTest");

        /* move to insertRow */
        updRs.moveToInsertRow();

        /* update the table */
        updRs.updateBinaryStream("field1", new ByteArrayInputStream(streamData), streamLength);

        updRs.insertRow();
    } finally {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
    }
}
 
Example 2
Project: OpenVertretung   File: StatementRegressionTest.java   View Source Code Vote up 6 votes
/**
 * Tests fix for updatable streams being supported in updatable result sets.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testUpdatableStream() throws Exception {
    try {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
        this.stmt.executeUpdate("CREATE TABLE updateStreamTest (keyField INT NOT NULL AUTO_INCREMENT PRIMARY KEY, field1 BLOB)");

        int streamLength = 16385;
        byte[] streamData = new byte[streamLength];

        /* create an updatable statement */
        Statement updStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

        /* fill the resultset with some values */
        ResultSet updRs = updStmt.executeQuery("SELECT * FROM updateStreamTest");

        /* move to insertRow */
        updRs.moveToInsertRow();

        /* update the table */
        updRs.updateBinaryStream("field1", new ByteArrayInputStream(streamData), streamLength);

        updRs.insertRow();
    } finally {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
    }
}
 
Example 3
Project: ProyectoPacientes   File: StatementRegressionTest.java   View Source Code Vote up 6 votes
/**
 * Tests fix for updatable streams being supported in updatable result sets.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testUpdatableStream() throws Exception {
    try {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
        this.stmt.executeUpdate("CREATE TABLE updateStreamTest (keyField INT NOT NULL AUTO_INCREMENT PRIMARY KEY, field1 BLOB)");

        int streamLength = 16385;
        byte[] streamData = new byte[streamLength];

        /* create an updatable statement */
        Statement updStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

        /* fill the resultset with some values */
        ResultSet updRs = updStmt.executeQuery("SELECT * FROM updateStreamTest");

        /* move to insertRow */
        updRs.moveToInsertRow();

        /* update the table */
        updRs.updateBinaryStream("field1", new ByteArrayInputStream(streamData), streamLength);

        updRs.insertRow();
    } finally {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
    }
}
 
Example 4
Project: BibliotecaPS   File: StatementRegressionTest.java   View Source Code Vote up 6 votes
/**
 * Tests fix for updatable streams being supported in updatable result sets.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testUpdatableStream() throws Exception {
    try {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
        this.stmt.executeUpdate("CREATE TABLE updateStreamTest (keyField INT NOT NULL AUTO_INCREMENT PRIMARY KEY, field1 BLOB)");

        int streamLength = 16385;
        byte[] streamData = new byte[streamLength];

        /* create an updatable statement */
        Statement updStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

        /* fill the resultset with some values */
        ResultSet updRs = updStmt.executeQuery("SELECT * FROM updateStreamTest");

        /* move to insertRow */
        updRs.moveToInsertRow();

        /* update the table */
        updRs.updateBinaryStream("field1", new ByteArrayInputStream(streamData), streamLength);

        updRs.insertRow();
    } finally {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS updateStreamTest");
    }
}
 
Example 5
Project: all-file   File: File.java   View Source Code Vote up 5 votes
public void fileToField(ResultSet resultset, String s)
    throws ServletException, IOException, SmartUploadException, SQLException
{
    long l = 0L;
    int i = 0x10000;
    int j = 0;
    int k = m_startData;
    if(resultset == null)
        throw new IllegalArgumentException("The RecordSet cannot be null (1145).");
    if(s == null)
        throw new IllegalArgumentException("The columnName cannot be null (1150).");
    if(s.length() == 0)
        throw new IllegalArgumentException("The columnName cannot be empty (1155).");
    l = BigInteger.valueOf(m_size).divide(BigInteger.valueOf(i)).longValue();
    j = BigInteger.valueOf(m_size).mod(BigInteger.valueOf(i)).intValue();
    try
    {
        for(int i1 = 1; (long)i1 < l; i1++)
        {
            resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, i), i);
            k = k != 0 ? k : 1;
            k = i1 * i + m_startData;
        }

        if(j > 0)
            resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, j), j);
    }
    catch(SQLException sqlexception)
    {
        byte abyte0[] = new byte[m_size];
        System.arraycopy(m_parent.m_binArray, m_startData, abyte0, 0, m_size);
        resultset.updateBytes(s, abyte0);
    }
    catch(Exception exception)
    {
        throw new SmartUploadException("Unable to save file in the DataBase (1130).");
    }
}
 
Example 6
Project: parabuild-ci   File: BadResultSetAccessTest.java   View Source Code Vote up 4 votes
public void test4( ResultSet rs ) throws SQLException {
	rs.updateBinaryStream( 1, null, 0 );
}