With Flint's JDBC Pool Connector you can execute queries against the mostly used databases in any IT infrastructure.

With this document guide you will be able to work with and use a DB Connector.

Features

  • Provide connection pooling.
  • Query all popular databases : MySQL, Microsoft SQL, Oracle and PostgreSQL
  • Simple DB queries : select, insert, update, delete, procedure and execute
  • Databases with/without passwords accessible
  • Direct access to the query execution results from the remote server machine
  • Ability to set Connector execution timeout
  • Synchronous / Asynchronous execution of the Connector

Connector Configuration

add-db-conn

Configuration parameters - config(JSON)

ParameterDescriptionRequired
driver-className of the driver depending on the type of database specified. For example : for a database type of mysql the driver name is com.mysql.jdbc.Drivertrue
max-pool-sizeThe maximum connection to be pool(default 10)false
minimum-idleMinimum number of idle connections that maintain in the poolfalse
userUsername associated with the database. Not required, if already specified in connector configurationtrue
passwordPassword associated with the database. Not required, if already specified in connector configurationfalse
urlThe JDBC connection url for databasetrue

Example

{
  "driver-class": "com.mysql.jdbc.Driver",
  "max-pool-size": 20,
  "minimum-idle": 5,
  "password": "root",
  "url": "jdbc:mysql://localhost:3306/employee",
  "user": "root"
}

 

Actions

select

Retrieving data from the database.

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete , procedure and executetrue
querySpecify the query that you want to performed on the databasetrue

Response parameters

ParameterDescriptionrequired
resultResults as per the query performed on the database. Will reflect the number of rows in database affected in case of insert,delete and update actions. In case of select action, the data retrieved will be displayed in an array format. The result for a procedure action is based on the type of query performedtrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","select" )
              .set("query", "select * from employee")
              .sync

#DB Connector Response Parameters
result=response.get("result") #Query execution results

insert

Inserting data into the database

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete , procedure and executetrue
querySpecify the query that you want to performed on the databasetrue

Response parameters

ParameterDescriptionrequired
resultResults as per the query performed on the database. Will reflect the number of rows in database affected in case of insert,delete and update actions. In case of select action, the data retrieved will be displayed in an array format. The result for a procedure action is based on the type of query performedtrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","insert" )
              .set("query", "insert into employee (age,lastname,city) values(27,'kennedy','pune')")
              .sync

#DB Connector Response Parameters
result=response.get("result") #Query execution results

 

update

Updating data from the database

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete, procedure and executetrue
querySpecify the query that you want to performed on the databasetrue

Response parameters

ParameterDescriptionrequired
resultResults as per the query performed on the database. Will reflect the number of rows in database affected in case of insert,delete and update actions. In case of select action, the data retrieved will be displayed in an array format. The result for a procedure action is based on the type of query performedtrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","update" )
              .set("query", "update employee set lastname='subhramanyam',city='delhi' where age = 27")
              .sync

#DB Connector Response Parameters
result=response.get("result") #Query execution results

 

delete

deleting data from the database

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete, procedure and executetrue
querySpecify the query that you want to performed on the databasetrue

Response parameters

ParameterDescriptionrequired
resultResults as per the query performed on the database. Will reflect the number of rows in database affected in case of insert,delete and update actions. In case of select action, the data retrieved will be displayed in an array format. The result for a procedure action is based on the type of query performedtrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","delete" )
              .set("query", "delete from employee where age=27")
              .sync

#DB Connector Response Parameters
result=response.get("result") #Query execution results

 

procedure

call procedure/function

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete and proceduretrue
querySpecify the query that you want to performed on the databasetrue

Response parameters

ParameterDescriptionrequired
resultResults as per the query performed on the database. Will reflect the number of rows in database affected in case of insert,delete and update actions. In case of select action, the data retrieved will be displayed in an array format. The result for a procedure action is based on the type of query performedtrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","procedure" )
              .set("query", "call simple()")
              .sync

#DB Connector Response Parameters
result=response.get("result") #Query execution results

 

execute

execute DDL queries.

Request parameters

ParameterDescriptionrequired
actionOperations to be performed on the data stored in database. Valid actions : select, insert, update, delete, procedure and executetrue
querySpecify the query that you want to performed on the databasetrue

Example

response=@call.connector("jdbc-pool-connector")
              .set("action","execute" )
              .set("query", "create table employee (id int,name varchar(255))")
              .sync

 

Connector request error handling

Here is how you can handle the connector requests success or failures within your Flintbit. This would help you to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

On this page: