Search in sources :

Example 11 with ByteArray

use of org.apache.derby.iapi.util.ByteArray in project derby by apache.

the class InsertOperation method writeOptionalDataToBuffer.

/**
 *		Writes out the row that is to be inserted as the optional data.
 *
 *		@exception IOException Can be thrown by any of the methods of ObjectOutput
 *		@exception StandardException Standard Derby policy.
 */
private void writeOptionalDataToBuffer(RawTransaction t, DynamicByteArrayOutputStream logBuffer, Object[] row, FormatableBitSet validColumns, boolean isLongColumn, int realStartColumn, int realSpaceOnPage, int overflowThreshold) throws StandardException, IOException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(this.page != null);
    }
    DynamicByteArrayOutputStream localLogBuffer = null;
    if (logBuffer != null) {
        localLogBuffer = (DynamicByteArrayOutputStream) logBuffer;
    } else {
        realStartColumn = -1;
        realSpaceOnPage = -1;
        localLogBuffer = t.getLogBuffer();
    }
    if (isLongColumn) {
        this.startColumn = this.page.logLongColumn(doMeSlot, recordId, row[0], localLogBuffer);
    } else {
        this.startColumn = this.page.logRow(doMeSlot, true, recordId, row, validColumns, localLogBuffer, this.startColumn, insertFlag, realStartColumn, realSpaceOnPage, overflowThreshold);
    }
    int optionalDataStart = localLogBuffer.getBeginPosition();
    int optionalDataLength = localLogBuffer.getPosition() - optionalDataStart;
    this.preparedLog = new ByteArray(localLogBuffer.getByteArray(), optionalDataStart, optionalDataLength);
}
Also used : DynamicByteArrayOutputStream(org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream) ByteArray(org.apache.derby.iapi.util.ByteArray)

Example 12 with ByteArray

use of org.apache.derby.iapi.util.ByteArray in project derby by apache.

the class ClassLoadingTest method test_01_6654.

/**
 * Test that you can't use Derby's custom class loader to load arbitrary
 * class files. See DERBY-6654.
 */
public void test_01_6654() throws Exception {
    ByteArray classBytes = new ByteArray(new byte[] { (byte) 1 });
    Connection conn = getConnection();
    LanguageConnectionContext lcc = ConstraintCharacteristicsTest.getLCC(conn);
    ClassFactory classFactory = lcc.getLanguageConnectionFactory().getClassFactory();
    String className1 = "BadClassName";
    String className2 = "bad.class.Name";
    vet6654(classFactory, className1, classBytes);
    vet6654(classFactory, className2, classBytes);
}
Also used : ClassFactory(org.apache.derby.iapi.services.loader.ClassFactory) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) Connection(java.sql.Connection) EmbedConnection(org.apache.derby.impl.jdbc.EmbedConnection) ByteArray(org.apache.derby.iapi.util.ByteArray)

Example 13 with ByteArray

use of org.apache.derby.iapi.util.ByteArray in project derby by apache.

the class GenericStorablePreparedStatement method readExternal.

/**
 * @see java.io.Externalizable#readExternal
 *
 * @exception IOException on error
 * @exception ClassNotFoundException on error
 */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    setCursorInfo((CursorInfo) in.readObject());
    setNeedsSavepoint(in.readBoolean());
    isAtomic = (in.readBoolean());
    executionConstants = (ConstantAction) in.readObject();
    resultDesc = (ResultDescription) in.readObject();
    if (in.readBoolean()) {
        savedObjects = new Object[ArrayUtil.readArrayLength(in)];
        ArrayUtil.readArrayItems(in, savedObjects);
    }
    className = (String) in.readObject();
    if (in.readBoolean()) {
        byteCode = new ByteArray();
        byteCode.readExternal(in);
    } else
        byteCode = null;
}
Also used : ByteArray(org.apache.derby.iapi.util.ByteArray)

Aggregations

ByteArray (org.apache.derby.iapi.util.ByteArray)13 DynamicByteArrayOutputStream (org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream)6 IOException (java.io.IOException)2 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)2 RecordHandle (org.apache.derby.iapi.store.raw.RecordHandle)2 StandardException (org.apache.derby.shared.common.error.StandardException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 EOFException (java.io.EOFException)1 InputStream (java.io.InputStream)1 Connection (java.sql.Connection)1 ArrayInputStream (org.apache.derby.iapi.services.io.ArrayInputStream)1 FormatIdInputStream (org.apache.derby.iapi.services.io.FormatIdInputStream)1 StreamStorable (org.apache.derby.iapi.services.io.StreamStorable)1 ClassFactory (org.apache.derby.iapi.services.loader.ClassFactory)1 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)1 LogInstant (org.apache.derby.iapi.store.raw.log.LogInstant)1 TransactionId (org.apache.derby.iapi.store.raw.xact.TransactionId)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1 EmbedConnection (org.apache.derby.impl.jdbc.EmbedConnection)1 LogCounter (org.apache.derby.impl.store.raw.log.LogCounter)1