Skip to main content
Skip table of contents

Operation: Execute

The Execute operation of the Apache Cassandra Connector executes the statement specified in the input document.

For more information on other operations of the Apache Cassandra Connector, see Apache Cassandra Connector.

Parameters

Parameters

Description

Adapter

Adapter main class (do not change!)

Possible values: de.softproject.integration.adapter.apache.cassandra.ApacheCassandraConnectorAdapter: Main Class (Standard)

host

Host within the cluster

Example:

Cluster cluster1 = cluster.builder().addContactPoints("172.30.210.11","172.30.210.12").build();

Note:

You can add multiple IPs or hostnames that correspond with different servers, which are executed as executable files within the module by Apache Cassandra.

port

Native protocol port

login

Login if the cluster requires credentials

Possible values: Any string with the login, e.g. myLogin

password

Password if the cluster requires credentials

Possible values: Any string with the password, e.g. myPassword

Status values

1

The adapter operation was executed successfully

-1

The operation failed due to a technical error.

Input <Statement/>

The adapter expects a predefined XML structure as input.

CODE
<RootElement>
  <Statement>
      select * from keyspace.table;
  </Statement>
  <Statement>
      INSERT INTO keyspace.table (id, lastname, firstname) VALUES (uuid(), myLastname,'myFirstName');
  </Statement>
  ....
</RootElement>

Input <Preparedstatement/>

The adapter expects a predefined XML structure as input.

XML
<RootElement>
    <Preparedstatement resulttag="result element name" timeZone="timezone">
        <Cql>
			select * from keyspace.table;
		</Cql>
		<Parameters>
			<parameter index="n" type="Cassandra_Type">Value</parameter>
		</Parameters>
    </Preparedstatement>
    <Preparedstatement resulttag="result 2 element name" timeZone="timezone 2">
       <Cql>
			INSERT INTO keyspace.table (id, lastname, firstname) VALUES (uuid(), myLastname,'myFirstName');
		</Cql>
    </Preparedstatement>
    ....
</RootElement>

Input rules

The input XML document must comply with the following rules:

Element/Attribute

Description

resulttag

This attribute is required for the Preparedstatement element.

timeZone

This attribute is optional for the Preparedstatement element.

Determines the timezone according to java.util.TimeZone (e.g. GMT+2 ). By default, the UTC timezone is used for dates.

Cql

Element within the Preparedstatement element. Contains the CQL statement. Can be used as often as desired within Preparedstatement.

Note:

If characters are used within the CQL statement that are predefined in XML, you need to escape the SQL statement with a CDATA block.

Parameters

Element within the Preparedstatement element. May only be used exactly once within Preparedstatement. Contains any number of parameter elements with parameter values.

parameter

Element within the Parameters element. Can be used as many times as required within Parameters.

Attributes:

Possible parameter types for type

type

Description

TEXT

UTF-8 encoded text

VARCHAR

UTF-8 encoded text

ASCII

US-ASCII-encoded text

BLOB

Hexadecimal-encoded binary files without validation

BOOLEAN

Boolean values

BIGINT

64-bit integer

COUNTER

64-bit counter value

INT

32-bit integer

SMALLINT

2-byte integer

TINYINT

1-byte integer

DATE

Date in yyyy-mm-dd format

Note:

Apacha Cassandra encodes dates as a 32-bit integer representing the days since January 1, 1970.

DECIMAL

Decimal number

DOUBLE

64-bit-IEEE floating point number

FLOAT

32-bit-IEEE floating point number

INET

IP address in IPv4 or IPv6 format

TIME

Time of day

Note:

Apache Cassandra encodes time information as a 64-bit integer representing the nanoseconds since midnight.

TIMESTAMP

Date and time

The format must be specified using the format attribute, for example:

CODE
<parameter index="n" type="TIMESTAMP" format="yyyy-MM-dd HH:mm:ss">2012-06-01 08:00:00</parameter>

TIMEUUID

UUID version 1

UUID

UUID in standard UUID format

VARINT

Integer

MAP

Array of characters in JSON format

LIST

Collection of one or more ordered elements, for example:

CODE
<parameter index="n" type="LIST">["tcodd@relational.com","ted.codd@relational.com"]</parameter>

Note:

The use of quotation marks is required.

SET

Collection of one or more elements, for example:

CODE
<parameter index="n" type="SET">["Element 1","Element 1","Element 3"]</parameter>

Note:

The use of quotation marks is required.

TUPLE

A group of comma-separated fields. Can contain several simple types:

  • keySpace: Name of the key space of the table

  • table: Name of the table

  • column: Name of the column

Note:

If the TUPLE field includes DATE, TIME, or TIMESTAMP fields, the following attributes are required:

  • formatWithoutTime: Required if the TUPLE field contains DATE fields.

  • format: Required if the TUPLE field contains TIMESTAMP fields.

  • formatTime: Required if the TUPLE field contains TIME fields.

TUPLE example
CODE
<parameter index="n" type="TUPLE" keySpace="videodb" table="videos" column="tupleColl"
formatWithoutTime="yyyy-MM-dd"
format="yyyy-MM-dd HH:mm:ss"
formatTime="HH:mm:ss:SSS">1, fisrt tuple element, V1, 1.01, 14:25:16:555, 2012-06-01 08:00:00, 2018-04-03, 127.0.0.1, 5.678, 9e816244-f90a-4394-86a5-ddcf4fb9f7aa, true, 97, blobValue</parameter>

In the example above, the TUPLE field is defined during table creation as follows:

CODE
tupleColl tuple<int, text, varchar, float, time, timestamp, date, inet, decimal, uuid, boolean, ascii, blob>   

Output

The output is an XML document containing the errors and the result of the adapter execution. Depending on the operation, the adapter outputs data in different XML structures:

Batch operations (INSERT, UPDATE, DROP, CREATE , ...)

XML
<Result>
	<resulttag_name> Operation executed successfully</resulttag_name>
</Result>

Operation: SELECT

XML
<Result>
	<resulttag_name>
		<Object>
			<Value name="field_name" type="String|Number|Boolean...">field_value</Value>
			...
			<Object name="Map_field_name">
				<Value name="key_name" type="String|Number|Boolean...">object_value</Value>
			</Object>
			<Array name="Colleciton_field_name">
				<Value type="String|Number|Boolean...">value_of_the_array_at_this_position</Value>
				...
			</Array>
			...
		</Object>
	</resulttag_name>
</Result>

Note:

If the field is of the MAP data type, its value is represented by an object node. If the field is of the LIST, SET, or TUPLE data type, its value is represented by an array node. If the field is a simple type, its value is represented within the value node.

Examples

Here, you can find example inputs for the different prepared statements of the Execute operation:

Example: CREATE
CODE
<RootElement>
	<Preparedstatement resulttag="createTableVideos">
		<Cql>
			<![CDATA[CREATE TABLE videodb.videos (
				videoid uuid,
				videoname varchar,
				username varchar,
				description varchar,
				location map<varchar,varchar>,
				tags set<varchar>,
				tupleColl tuple<int, text, varchar, float, time, timestamp, date, inet, decimal, uuid, boolean, ascii, blob>,
				upload_date timestamp,
				upload_date_noTime date,
				PRIMARY KEY (videoid));]]>
		</Cql>
	</Preparedstatement>
</RootElement>
Example: DROP
CODE
<RootElement>
	<Preparedstatement resulttag="drop_Users">
		<Cql>
			<![CDATA[DROP TABLE IF EXISTS videodb.users;]]>
		</Cql>
	</Preparedstatement>
</RootElement>
Example: INSERT
CODE
<RootElement>
	<Preparedstatement resulttag="insertVideos" timeZone="UTC">
		<Cql>
			INSERT INTO videodb.videos (videoid, videoname, username, description, location, tags, tupleColl, upload_date, upload_date_noTime)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
		</Cql>
		<Parameters>
			<parameter index="0" type="UUID">99051fe9-6a9c-46c2-b949-38ef78858dd0</parameter>
			<parameter index="1" type="VARCHAR">My funny cat</parameter>
			<parameter index="2" type="VARCHAR">tcodd</parameter>
			<parameter index="3" type="VARCHAR">My cat likes to play the piano! So funny.</parameter>
			<parameter index="4" type="MAP">{"US":"/us/vid/99/99051fe9-6a9c-46c2-b949-38ef78858dd0"}</parameter>
			<parameter index="5" type="SET" >["cats","piano","lol"]</parameter>
			<parameter index="6" type="TUPLE" keySpace="videodb" table="videos" column="tupleColl" formatWithoutTime="yyyy-MM-dd" format="yyyy-MM-dd HH:mm:ss" formatTime="HH:mm:ss:SSS">1, fisrt tuple element, V1, 1.01, 14:25:16:555, 2012-06-01 08:00:00, 2018-04-03, 127.0.0.1, 5.678, 9e816244-f90a-4394-86a5-ddcf4fb9f7aa, true, 97, blobValue</parameter>
			<parameter index="7" type="TIMESTAMP" format="yyyy-MM-dd HH:mm:ss">2012-06-01 08:45:32</parameter>
			<parameter index="8" type="DATE" formatWithoutTime="yyyy-MM-dd">2012-06-01</parameter>
		</Parameters>
	</Preparedstatement>
</RootElement>
Example: UPDATE
CODE
<rootElement>
	<Preparedstatement resulttag="add_email_in_list">
		<Cql>
			<![CDATA[ UPDATE videodb.users set email = ? + email where username = ?]]>
		</Cql>
		<Parameters>
			<parameter type="LIST" index="0">["test1@mail.com","test0@mail.com"]</parameter>
			<parameter type="TEXT" index="1">pmcfadin</parameter>
		</Parameters>
	</Preparedstatement>
</rootElement>
Example: SELECT
CODE
<mainNode>
	<Preparedstatement resulttag="select_NY_rides" timezone="UTC">
		<Cql>
			<![CDATA[SELECT * from NY.rides
				where vendor_id = ?
				and pickup_datetime = ?
				and rate_code = ?
				and total_amount = ?
				limit 10 ALLOW FILTERING;
			]]>
		</Cql>
		<Parameters>
			<parameter index="0" type="TEXT">2</parameter>
			<parameter index="1" type="TIMESTAMP" format="yyyy-MM-dd hh:mm:ss">2016-01-02 17:02:28</parameter>
			<parameter index="2" type="INT">1</parameter>
			<parameter index="3" type="DECIMAL">64.56</parameter>
		</Parameters>
	</Preparedstatement>
</mainNode>
Example: DELETE
CODE
<mainNode>
	<Preparedstatement resulttag="delete_video_one_record" timezone="UTC">
		<Cql>
			DELETE FROM videodb.videos WHERE videoid = ?;
		</Cql>
		<Parameters>
			<parameter index="0" type="UUID">7dacb4da-9155-4613-b04e-8c5305a20342</parameter>
		</Parameters>
	</Preparedstatement>
</mainNode>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.