Java Code Examples for org.hsqldb.jdbc.JDBCBlob

The following examples show how to use org.hsqldb.jdbc.JDBCBlob. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: olingo-odata2   Source File:    License: Apache License 2.0 5 votes vote down vote up
public Blob convertToEntityAttribute(final byte[] arg0) {
  try {
    if (arg0 == null) {
      return null;
    return new JDBCBlob(arg0);
  } catch (SQLException e) {
  return null;
Example 2
Source Project: zap-extensions   Source File:    License: Apache License 2.0 4 votes vote down vote up
public void insertMessage(WebSocketMessageDTO message) throws DatabaseException {
    try {
        // synchronize on whole object to avoid race conditions with insertOrUpdateChannel()
        synchronized (this) {
            if (getConnection().isClosed()) {
                // temporarily buffer messages and write them the next time

            do {
                if (!channelIds.contains( {
                    // maybe channel is buffered
                    if (channelsBuffer.size() > 0) {
                    throw new SQLException("channel not inserted: " +;

                if (logger.isDebugEnabled()) {
                    logger.debug("insert message: " + message.toString());

                psInsertMessage.setTimestamp(3, new Timestamp(message.timestamp));
                psInsertMessage.setInt(4, message.opcode);

                // write payload
                if (message.payload instanceof String) {
                    psInsertMessage.setClob(5, new JDBCClob((String) message.payload));
                    psInsertMessage.setNull(6, Types.BLOB);
                } else if (message.payload instanceof byte[]) {
                    psInsertMessage.setNull(5, Types.CLOB);
                    psInsertMessage.setBlob(6, new JDBCBlob((byte[]) message.payload));
                } else {
                    throw new SQLException(
                            "Attribute 'payload' of class WebSocketMessageDTO has got wrong type!");

                psInsertMessage.setInt(7, message.payloadLength);
                psInsertMessage.setBoolean(8, message.isOutgoing);

                if (message instanceof WebSocketFuzzMessageDTO) {
                    WebSocketFuzzMessageDTO fuzzMessage = (WebSocketFuzzMessageDTO) message;
                    psInsertFuzz.setInt(1, fuzzMessage.fuzzId);
                    psInsertFuzz.setString(4, fuzzMessage.state.toString());
                    psInsertFuzz.setString(5, fuzzMessage.fuzz);

                message = messagesBuffer.poll();
            } while (message != null);
    } catch (SQLException e) {
        throw new DatabaseException(e);