Ballerina version used: 0.992.0
Wednesday, May 29, 2019
Insert byte[] into BIT data type in MySQL using Java
First, you need to create a database and table as below to work with the following sample.
Sample:
Sample:
Working with JDBC Client Call Procedures with BIT data type using Ballerina
This sample explains how to execute stored procedures using JDBC Client with BIT data type. Before running the sample, copy the
MySQL JDBC driver to the
Sample:
Ballerina version used: 0.992.0
How to run:
Output:
BALLERINA_HOME/bre/lib
folder.Sample:
Ballerina version used: 0.992.0
How to run:
ballerina run callProcedureWithBitDataType.bal
Output:
Creating table and procedures: Create bittypes table status: 0 Update bittypes table status: 1 Update bittypes table using sql:Parameter. status: 1 Update bittypes table by passing as direct parameter. status: 1 Stored procedure with IN and OUT param creation status: 0 Call operation with OUT params successful =============bitVal1============= true =============bitVal2============= 258 Drop stored procedure TestBitOutParam status: 0
Working with Postgresql database using Ballerina
- First, install Postgresql database.
- Download the postgresql driver jar and copy the Postgresql JDBC driver jar into $BALLERINA_HOME/bre/lib.
- Connect to your postgresql server and create a database:
This is the sample to create a table using the Ballerina jdbc client, then insert a BIT data type record to the table.
Ballerina version used: 0.992.0
Running the sample:
ballerina run workingWithBitDataPostgresql.bal
Output:
Create BitTypes table status: 0 Update BitTypes table status: 1
Working with an Oracle database using Ballerina
Ballerina version used: 0.992.0
Oracle database version used: Oracle-xe-11g (Follow these instructions explained here to install Oracle-xe-11g with Docker).
This Sample is written using ballerinax/jdbc module. Before running this sample you need to copy the Oracle JDBC driver jar into $BALLERINA_HOME/bre/lib.
First, create the table using the following command:
This is a sample to insert byte array into oracle database:
Running the sample:
Output:
Oracle database version used: Oracle-xe-11g (Follow these instructions explained here to install Oracle-xe-11g with Docker).
This Sample is written using ballerinax/jdbc module. Before running this sample you need to copy the Oracle JDBC driver jar into $BALLERINA_HOME/bre/lib.
First, create the table using the following command:
This is a sample to insert byte array into oracle database:
Running the sample:
ballerina run insertByteArray.bal
Output:
Update oracledb table status: 1
Working with mysql BIT data type using Ballerina
This example is written using Ballerina MYSQL Client which is used to access and manipulate data in MYSQL databases.
Output:
- First, you need to install MySQL.
- Download and install Ballerina 0.992.0.
- Copy the MySQL JDBC driver(mysql-connector-java-5.1.39.jar) to the BALLERINA_HOME/bre/lib folder and change the DB connection properties as required.
Sample
How to run:
ballerina run workingWithBitData.bal
Output:
Create database testdb status: 1 Create bittypes table status: 0 Update bittypes table status: 1 Update bittypes table status: 1 =================================== 1 true [0, 0, 0, 0, 0, 0, 0, 14] 2 true [0, 0, 0, 0, 0, 1, 2, 3] =================================== Drop Database testdb status: 1
Install SQL*Plus on Ubuntu 16.04
- First, you need to download Instant Client Downloads.
- Install alien software.
- Navigate to the folder where the downloaded rpm files are located and execute the following commands:
- Type following command to install libaio.so
- Create an Oracle configuration file:
- Put the following line in the created file:
- Update the configuration by running the following command:
- Try to connect using the following command:
sudo apt-get install alien
sudo alien -i oracle-instantclient*-basic*.rpm sudo alien -i oracle-instantclient*-sqlplus*.rpm sudo alien -i oracle-instantclient*-devel*.rpm
sudo apt-get install libaio1
sudo nano /etc/ld.so.conf.d/oracle.conf
/usr/lib/oracle/<your oracle version>/client64/lib/
sudo ldconfig
sqlplus system/oracle@localhost:49161/xe
Installing Oracle XE 11g on Ubuntu
Installing Oracle XE with Docker
Docker is an application container for Linux. It is based on LXC and gives you the ability to package complete application including their dependencies to a self-containing file called an image. These images can be exchanged and run on every Linux machine where Docker is installed. It is the easiest way to install Oracle XE. Docker images are also shared around the community on https://index.docker.io.
- First, you need to install Docker on Ubuntu. Follow the instructions given in this doc.
- Pull the image to your machine using the following command :
- Run the image using the following command :
- Connect to the database with the following setting:
- You can connect to the database using SQL*Plus
docker pull arahman/docker-oracle-xe-11g
docker run -d -p 49160:22 -p 49161:1521 -p 49162:8080 arahman/docker-oracle-xe-11g /sbin/my_init
hostname: localhost
port: 49161
sid: xe
username: system
password: oracle
Friday, April 19, 2019
Tracking Form Submissions
This is to send an event to Google Analytics when the contact form is submitted, with the following data:
- Event category: Form Submission
- Event action: Form Submitted
- Event label: Form ID: [Form ID]
When there are multiple forms on the website
and if you want to distinguish between forms, the event label will be replaced with the ID of the form is submitted.
Enable the required variables
Go to the Variables screen and enable the built-in variables called Form Element and Form ID by ticking the checkbox. At least one form variable must be enabled to ensure GTM records form submissions.
Create a trigger
Go to the Triggers screen and create a new trigger called Form Submission, trigger type as Form Submission.
Then you can choose if you want the trigger to fire on all form submissions or specific forms. If you want to fire on specific forms, click on SOme Forms radio button checked, then save the trigger. In the appeared text boxes you can specify conditions.
Create a tag
Create a Universal Analytics tag to fire the event to Google Analytics.
Go to the tags screen and create a tag called GA Form Submission Tag.
Choose the Universal Analytics tag type.
Enter your Google Analytics property ID.
Select Event from the Track Type dropdown menu.
Enter your event category, action and label values as appropriate (remember to use the Form ID variable in the event label).
Finally, attach the created Form Submission trigger to the tag.
Subscribe to:
Posts (Atom)