SlideShare a Scribd company logo
Mule Integration Workshop
JDBC
Rajarajan Sadhasivam
• Rapidly connect any application, anywhere
• Anypoint Platform helps companies prepare for the future with a next-
generation SOA platform that connects on-premises systems and the
cloud.
• Mule ESB, CloudHub, Mule Studio, Mule Enterprise Management,
Anypoint Connectors
Anypoint
Platform for
SOA
• Connect SaaS with any application, anywhere
• Anypoint Platform helps companies connect SaaS applications to each
other and the enterprise, in the cloud and on-premises.
• CloudHub, Mule ESB, Mule Studio, CloudHub Insight, Anypoint
Connectors
Anypoint
Platform for
SaaS
• All you need to connect any app, any device and any API
• With the Anypoint Platform for APIs, you can build new APIs, design
new interfaces for existing APIs and more efficiently manage all your
APIs using a single platform.
• API Portal, API Manager, Mule Studio, Mule ESB, CloudHub
Anypoint
Platform for
API
1
MuleSoft Anypoint Platforms
Chapters
Schedule
Filter Types
JDBC - Introduction
JDBC Endpoint: Inbound vs Outbound
JDBC Connector Attributes
Data sources Shortcuts
Results Data Structure
JDBC - CE vs EE
JDBC Transactions
MEL - JDBC
JDBC - Introduction
 The Java Database Connectivity (JDBC) transport connects to any relational
database that supports JDBC.
 A JDBC inbound endpoint maps to an SQL SELECT statement while a JDBC
outbound endpoint maps to an SQL SELECT, UPDATE, INSERT or DELETE
statement.
 Similar to the File transport, consumption of records needs to be simulated.
 Schema definition
CE Version:
<xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jdbc
http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd">
EE Version:
<xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jdbc
http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd">
JDBC Endpoint: Inbound vs Outbound
 A SELECT on a JDBC inbound endpoint is polling. This means that Mule will
attempt to read records every so often from a given database table. In
addition, Mule will only retrieve un-read records. In other words, a JDBC
inbound endpoint will consume records.
 Inbound Endpoints can only be configured for SELECT queries
 A SELECT on a JDBC outbound endpoint is triggered by a Mule event. For
example, this Mule event could have been created as a result of an HTTP
request.
 A JDBC outbound endpoint does not care if a record has been read or not. It
will retrieve all records matching the SELECT’s WHERE clause.
 Outbound Endpoints can be configured for any allowed (as set by database)
query.
JDBC Connector Attributes
 JDBC transport requires configuration of the JDBC connector. In the connector,
we must point the dataSource-ref attribute to a Spring bean and the Spring
bean would configure a class which implements the javax.sql.DataSource
interface. Configuring a DataSource usually involves setting the URL, JDBC
driver, username and password bean properties.
 JDBC connector we can also add the queries that are to be executed by the
JDBC inbound and outbound endpoints.
 Each query is represented as a child element in the JDBC connector element.
Moreover, each query needs a key (which is a descriptive name for the query)
as well as the actual SQL query itself.
 There are three types of queries available:
 Read queries are SELECT SQL statements bound to an inbound or an
outbound endpoint.
 Write queries are INSERT or UPDATE SQL statements bound to an outbound
endpoint.
JDBC Connector Attributes (Contd)
 Acknowledgement queries are executed immediately after a read query. This
type of query is identified with the same name as the read query together
with an '.ack' suffix. An acknowledgement query is normally used to mark
the previously selected rows as having been processed or consumed. This
type of query is usually an UPDATE statement.
 Other properties that are set on the connector but are optional are:
 pollingFrequency: The frequency to poll the database for new records, in
milliseconds.
 queryRunner-ref: The name of the class to execute queries. The default class
is org.apache.commons.dbutils.QueryRunner.
 resultSetHandler-ref: The name of the class used to pass query results back.
The default class is org.apache.commons.dbutils.handlers.MapListHandler
converts the result set to an object.
Eg:
<jdbc:connector dataSource-ref="ordersDB" name="salesDB“ pollingFrequency="1000">
JDBC Connector Attributes (Contd)
<jdbc:query key="getTest“ value="SELECT ID, TYPE, DATA, ACK, RESULT FROM TEST WHERE
TYPE =#[map-payload:type] AND ACK IS NULL"/>
<jdbc:query key="getTest.ack“ value="UPDATE TEST SET ACK = #[map-payload:NOW] WHERE
ID = #[map-payload:id] AND TYPE =#[map-payload:type] AND DATA = #[map-payload:data]"/>
<jdbc:query key="writeTest“ value="INSERT INTO TEST (ID, TYPE, DATA, ACK, RESULT) VALUES
(NULL, #[map-payload:type], #[map-payload:payload], NULL, NULL)"/>
</jdbc:connector>
<flow name="...">
<jdbc:inbound-endpoint queryKey="getTest"/>
...
<jdbc:outbound-endpoint queryKey="writeTest"/>
</flow>
<spring:bean class="org.springframework.jdbc.datasource. DriverManagerDataSource" id="ordersDB">
<spring:property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<spring:property name="url" value="jdbc:mysql://localhost:3306/orderdb"/>
<spring:property name="username" value="myName"/>
<spring:property name="password" value="myPwd"/>
</spring:bean>
Datasources Shortcuts
 Mule 3.2 and later versions provide shortcuts for configuring a number of data
sources including Derby, MySQL, Oracle and PostgreSQL:
Eg:
MySql:
<jdbc:mysql-data-source database="mule" name="dataSource" password="secret" user="mysql"/>
Derby:
<jdbc:derby-data-source create="true" database="mule" name="dataSource"/>
Oracle:
<jdbc:oracle-data-source instance="mule" name="dataSource" password="secret" user="oracle"/>
Results Data Structure
 Query(SELECT statement) result, is an array of Maps
 Each Map represents a record in the database and each entry in the Map
represents a column in the record.
 Using a Groovy expression is one way of retrieving the required data from the
result set.
JDBC - CE vs EE
 The EE version of the JDBC transport offers a number of extra features over and above
the features provided by the CE version. List of JDBC features offered by both versions:
 Select queries with acknowledgement
 Basic Insert/Update/Delete: Single row Insert/Update/Delete
 Basic Stored Procedure Support: Supports only in parameters
 Unnamed Queries: Queries can be invoked programmatically
 Flexible Data Source Config: Can configure data sources through JNDI, XAPool or
Spring.
 Transactions
 Outbound Select Query: Retrieve records using the select statement configured on
outbound endpoints.
 The EE JDBC transport also offers:
 Large Dataset Retrieval: Allows the consumption of records in smaller batches thus
allows the retrieval of large datasets.
JDBC - CE vs EE (Contd)
 Batch Insert/Update/Delete: Batch inserts/update/delete improve the
performance of the JDBC transport considerably when large datasets need
to be inserted/updated.
 Advanced Transformers: These transformers include XML and CSV
transformers.
 Advanced Stored Procedures: Allows both in and out parameters.
JDBC Transactions
 Similar to JMS, the JDBC transport has support for single resource JDBC transactions. This is
configured using the jdbc:transaction element as seen in the following example.
Eg:
<jdbc:connector dataSource-ref="jdbcDataSource" name="jdbcConnector">
<jdbc:query key="JobSearch“ value="SELECT Id,Task FROM Jobs WHERE Started IS NULL"/>
<jdbc:query key="JobSearch.ack“ value="UPDATE Jobs SET Started=#[function:now] WHERE Id = #[map-
payload:Id]"/>
<jdbc:query key="InsertNewTask“ value="INSERT INTO Tasks (JobId,Task) VALUES (#[map-payload:Id],#[map-
payload:Task])"/>
</jdbc:connector>
<flow name="JdbcSimpleTransaction">
<jdbc:inbound-endpoint queryKey="JobSearch">
<jdbc:transaction action="ALWAYS_BEGIN"/>
</jdbc:inbound-endpoint>
<component class="com.mulesoft.MyCustomComponent"/>
<jdbc:outbound-endpoint queryKey="InsertNewTask">
<jdbc:transaction action="ALWAYS_JOIN"/>
</jdbc:outbound-endpoint>
</flow>
MEL - JDBC
Arrays and Lists
 Literal forms for Lists ({item1, item2, . . }) and Arrays ([item1, item2, . . ]). Using the
literal form the payload can be set by:
Eg: Message.payload = ({‘foo’, ‘bar’, ‘dog’})
This will set the payload to a list of 3 elements. In the MEL, as in many other
languages, indexes start at 0. Eg: Message.payload[2] results in ‘dog’
 Arrays and Lists in Java must specify the type of their contents, but in MEL they are
untyped.
 The MEL supplies the correct type when we use them – either by determining it at
compile time or coercing the array to the correct type at run time.
Eg: Valid MEL: Message.payload = ({‘foo’, 1234, 1234.56})
Mule Maps
 The MEL has built-in support for maps.
 Maps are used to store "associative arrays" or "dictionaries".
Eg: Message.payload = [ "Brett":100,"Pete":"Did not finish", "Andrew":86.879]
MEL – JDBC (Contd)
 MEL provides a very clean way to access the values in a map.
 Use square brackets to address the key:
 Eg: Message.payload ["Pete"] => Output: 'Did not finish'
 The MEL supplies the correct type when we use them – either by determining it at
compile time or coercing the array to the correct type at run time. If there is no value,
the operation returns a Null.
Arrays of Maps
 The very common Mule Payload is an array of maps
Eg: {['destination':'SFO', 'price':500]}. Price of SFO can be found by
Message.payload[0]['price']
 The following example shows how to check the size of an array in a WHEN statement,
evaluates to true if the array is not empty:
Eg: <when expression="message.payload.size() > 0"> This can be used to avoid
NullPayloads when potentially asking for something that the database didn't return any
values for.
Thank you

More Related Content

What's hot

Mule Microsoft Service Bus
Mule Microsoft Service BusMule Microsoft Service Bus
Mule Microsoft Service Bus
Ankush Sharma
 
Mule overview-ppt
Mule overview-pptMule overview-ppt
Mule overview-ppt
Prabhat gangwar
 
Overview of Mule
Overview of MuleOverview of Mule
Overview of Mule
mdfkhan625
 
Mule jms
Mule   jmsMule   jms
Mulesoft Consuming Web Service - Web Service Consumer
Mulesoft Consuming Web Service - Web Service ConsumerMulesoft Consuming Web Service - Web Service Consumer
Mulesoft Consuming Web Service - Web Service Consumer
Vince Soliza
 
Distributed database
Distributed databaseDistributed database
Distributed database
sanjay joshi
 
Mule new jdbc component
Mule new jdbc componentMule new jdbc component
Mule new jdbc component
Anirban Sen Chowdhary
 
Mule: Java Transformer
Mule: Java TransformerMule: Java Transformer
Mule: Java Transformer
Sulthony Hartanto
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
Son Nguyen
 
Message structure
Message structureMessage structure
Message structure
Son Nguyen
 
Mule esb
Mule esbMule esb
Mule esb
charan teja R
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
akashdprajapati
 
Mule any point studio
Mule any point studioMule any point studio
Mule any point studio
Son Nguyen
 
Mule esb
Mule esbMule esb
Mule esb
Son Nguyen
 
Mulesoft ppt
Mulesoft pptMulesoft ppt
Mulesoft ppt
Achyuta Lakshmi
 
Mule java part-1
Mule java part-1Mule java part-1
Mule java part-1
Ravinder Singh
 
Muletransformers
MuletransformersMuletransformers
Muletransformers
vijaynerd
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
Praneethchampion
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
javeed_mhd
 

What's hot (19)

Mule Microsoft Service Bus
Mule Microsoft Service BusMule Microsoft Service Bus
Mule Microsoft Service Bus
 
Mule overview-ppt
Mule overview-pptMule overview-ppt
Mule overview-ppt
 
Overview of Mule
Overview of MuleOverview of Mule
Overview of Mule
 
Mule jms
Mule   jmsMule   jms
Mule jms
 
Mulesoft Consuming Web Service - Web Service Consumer
Mulesoft Consuming Web Service - Web Service ConsumerMulesoft Consuming Web Service - Web Service Consumer
Mulesoft Consuming Web Service - Web Service Consumer
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Mule new jdbc component
Mule new jdbc componentMule new jdbc component
Mule new jdbc component
 
Mule: Java Transformer
Mule: Java TransformerMule: Java Transformer
Mule: Java Transformer
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
 
Message structure
Message structureMessage structure
Message structure
 
Mule esb
Mule esbMule esb
Mule esb
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
 
Mule any point studio
Mule any point studioMule any point studio
Mule any point studio
 
Mule esb
Mule esbMule esb
Mule esb
 
Mulesoft ppt
Mulesoft pptMulesoft ppt
Mulesoft ppt
 
Mule java part-1
Mule java part-1Mule java part-1
Mule java part-1
 
Muletransformers
MuletransformersMuletransformers
Muletransformers
 
Mule esb introduction
Mule esb introductionMule esb introduction
Mule esb introduction
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 

Viewers also liked

Mule exception strategies
Mule exception strategiesMule exception strategies
Mule exception strategies
Krishna_in
 
Mule JMS Transport
Mule JMS TransportMule JMS Transport
Mule JMS Transport
Rupesh Sinha
 
Error Handling Framework in Mule ESB
Error Handling Framework in Mule ESBError Handling Framework in Mule ESB
Error Handling Framework in Mule ESB
Sashidhar Rao GDS
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
Khan625
 
Mule esb
Mule esbMule esb
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
Mohammed246
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
KalaimathiS
 
Rate Limiting - SLA Based Policy
Rate Limiting - SLA Based PolicyRate Limiting - SLA Based Policy
Rate Limiting - SLA Based Policy
Vince Soliza
 
Exception handling in mule
Exception handling in muleException handling in mule
Exception handling in mule
nagarajupatangay
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
Mohammed246
 
Anypoint platform for api
Anypoint platform for apiAnypoint platform for api
Anypoint platform for api
Vince Soliza
 
Mapping and listing in mule
Mapping and listing in muleMapping and listing in mule
Mapping and listing in mule
Khan625
 
Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
vijay dhanakodi
 
Apply Rate Limiting Policy
Apply Rate Limiting Policy Apply Rate Limiting Policy
Apply Rate Limiting Policy
Vince Soliza
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
Ravinder Singh
 
SOAP To REST API Proxy
SOAP To REST API ProxySOAP To REST API Proxy
SOAP To REST API Proxy
Vince Soliza
 
Mule properties
Mule propertiesMule properties
Mule properties
Ravinder Singh
 
Mule esb examples
Mule esb examplesMule esb examples
Mule esb examples
Sashidhar Rao GDS
 
Mule batch job
Mule batch jobMule batch job
Mule batch job
Anirban Sen Chowdhary
 

Viewers also liked (19)

Mule exception strategies
Mule exception strategiesMule exception strategies
Mule exception strategies
 
Mule JMS Transport
Mule JMS TransportMule JMS Transport
Mule JMS Transport
 
Error Handling Framework in Mule ESB
Error Handling Framework in Mule ESBError Handling Framework in Mule ESB
Error Handling Framework in Mule ESB
 
Message properties component in Mule
Message properties component in MuleMessage properties component in Mule
Message properties component in Mule
 
Mule esb
Mule esbMule esb
Mule esb
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
Rate Limiting - SLA Based Policy
Rate Limiting - SLA Based PolicyRate Limiting - SLA Based Policy
Rate Limiting - SLA Based Policy
 
Exception handling in mule
Exception handling in muleException handling in mule
Exception handling in mule
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
 
Anypoint platform for api
Anypoint platform for apiAnypoint platform for api
Anypoint platform for api
 
Mapping and listing in mule
Mapping and listing in muleMapping and listing in mule
Mapping and listing in mule
 
Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
 
Apply Rate Limiting Policy
Apply Rate Limiting Policy Apply Rate Limiting Policy
Apply Rate Limiting Policy
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
SOAP To REST API Proxy
SOAP To REST API ProxySOAP To REST API Proxy
SOAP To REST API Proxy
 
Mule properties
Mule propertiesMule properties
Mule properties
 
Mule esb examples
Mule esb examplesMule esb examples
Mule esb examples
 
Mule batch job
Mule batch jobMule batch job
Mule batch job
 

Similar to Mule jdbc

Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivitybackdoor
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
Arati Gadgil
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
Fulvio Corno
 
Jdbc
JdbcJdbc
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
varun arora
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
AISHWARIYA1S
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
Dharani Kumar Madduri
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
Mindfire Solutions
 
Jdbc
JdbcJdbc
Data access
Data accessData access
Data access
Joshua Yoon
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise Spring
Emprovise
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Sourabrata Mukherjee
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
Kumar
 
Spring framework DAO
Spring framework  DAOSpring framework  DAO
Spring framework DAO
Anuj Singh Rajput
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
arikazukito
 

Similar to Mule jdbc (20)

Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
 
JDBC programming
JDBC programmingJDBC programming
JDBC programming
 
MyBatis
MyBatisMyBatis
MyBatis
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
Data access
Data accessData access
Data access
 
Enterprise Spring
Enterprise SpringEnterprise Spring
Enterprise Spring
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
Spring framework DAO
Spring framework  DAOSpring framework  DAO
Spring framework DAO
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 

Mule jdbc

  • 2. • Rapidly connect any application, anywhere • Anypoint Platform helps companies prepare for the future with a next- generation SOA platform that connects on-premises systems and the cloud. • Mule ESB, CloudHub, Mule Studio, Mule Enterprise Management, Anypoint Connectors Anypoint Platform for SOA • Connect SaaS with any application, anywhere • Anypoint Platform helps companies connect SaaS applications to each other and the enterprise, in the cloud and on-premises. • CloudHub, Mule ESB, Mule Studio, CloudHub Insight, Anypoint Connectors Anypoint Platform for SaaS • All you need to connect any app, any device and any API • With the Anypoint Platform for APIs, you can build new APIs, design new interfaces for existing APIs and more efficiently manage all your APIs using a single platform. • API Portal, API Manager, Mule Studio, Mule ESB, CloudHub Anypoint Platform for API 1 MuleSoft Anypoint Platforms
  • 3. Chapters Schedule Filter Types JDBC - Introduction JDBC Endpoint: Inbound vs Outbound JDBC Connector Attributes Data sources Shortcuts Results Data Structure JDBC - CE vs EE JDBC Transactions MEL - JDBC
  • 4. JDBC - Introduction  The Java Database Connectivity (JDBC) transport connects to any relational database that supports JDBC.  A JDBC inbound endpoint maps to an SQL SELECT statement while a JDBC outbound endpoint maps to an SQL SELECT, UPDATE, INSERT or DELETE statement.  Similar to the File transport, consumption of records needs to be simulated.  Schema definition CE Version: <xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd"> EE Version: <xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd">
  • 5. JDBC Endpoint: Inbound vs Outbound  A SELECT on a JDBC inbound endpoint is polling. This means that Mule will attempt to read records every so often from a given database table. In addition, Mule will only retrieve un-read records. In other words, a JDBC inbound endpoint will consume records.  Inbound Endpoints can only be configured for SELECT queries  A SELECT on a JDBC outbound endpoint is triggered by a Mule event. For example, this Mule event could have been created as a result of an HTTP request.  A JDBC outbound endpoint does not care if a record has been read or not. It will retrieve all records matching the SELECT’s WHERE clause.  Outbound Endpoints can be configured for any allowed (as set by database) query.
  • 6. JDBC Connector Attributes  JDBC transport requires configuration of the JDBC connector. In the connector, we must point the dataSource-ref attribute to a Spring bean and the Spring bean would configure a class which implements the javax.sql.DataSource interface. Configuring a DataSource usually involves setting the URL, JDBC driver, username and password bean properties.  JDBC connector we can also add the queries that are to be executed by the JDBC inbound and outbound endpoints.  Each query is represented as a child element in the JDBC connector element. Moreover, each query needs a key (which is a descriptive name for the query) as well as the actual SQL query itself.  There are three types of queries available:  Read queries are SELECT SQL statements bound to an inbound or an outbound endpoint.  Write queries are INSERT or UPDATE SQL statements bound to an outbound endpoint.
  • 7. JDBC Connector Attributes (Contd)  Acknowledgement queries are executed immediately after a read query. This type of query is identified with the same name as the read query together with an '.ack' suffix. An acknowledgement query is normally used to mark the previously selected rows as having been processed or consumed. This type of query is usually an UPDATE statement.  Other properties that are set on the connector but are optional are:  pollingFrequency: The frequency to poll the database for new records, in milliseconds.  queryRunner-ref: The name of the class to execute queries. The default class is org.apache.commons.dbutils.QueryRunner.  resultSetHandler-ref: The name of the class used to pass query results back. The default class is org.apache.commons.dbutils.handlers.MapListHandler converts the result set to an object. Eg: <jdbc:connector dataSource-ref="ordersDB" name="salesDB“ pollingFrequency="1000">
  • 8. JDBC Connector Attributes (Contd) <jdbc:query key="getTest“ value="SELECT ID, TYPE, DATA, ACK, RESULT FROM TEST WHERE TYPE =#[map-payload:type] AND ACK IS NULL"/> <jdbc:query key="getTest.ack“ value="UPDATE TEST SET ACK = #[map-payload:NOW] WHERE ID = #[map-payload:id] AND TYPE =#[map-payload:type] AND DATA = #[map-payload:data]"/> <jdbc:query key="writeTest“ value="INSERT INTO TEST (ID, TYPE, DATA, ACK, RESULT) VALUES (NULL, #[map-payload:type], #[map-payload:payload], NULL, NULL)"/> </jdbc:connector> <flow name="..."> <jdbc:inbound-endpoint queryKey="getTest"/> ... <jdbc:outbound-endpoint queryKey="writeTest"/> </flow> <spring:bean class="org.springframework.jdbc.datasource. DriverManagerDataSource" id="ordersDB"> <spring:property name="driverClassName" value="com.mysql.jdbc.Driver"/> <spring:property name="url" value="jdbc:mysql://localhost:3306/orderdb"/> <spring:property name="username" value="myName"/> <spring:property name="password" value="myPwd"/> </spring:bean>
  • 9. Datasources Shortcuts  Mule 3.2 and later versions provide shortcuts for configuring a number of data sources including Derby, MySQL, Oracle and PostgreSQL: Eg: MySql: <jdbc:mysql-data-source database="mule" name="dataSource" password="secret" user="mysql"/> Derby: <jdbc:derby-data-source create="true" database="mule" name="dataSource"/> Oracle: <jdbc:oracle-data-source instance="mule" name="dataSource" password="secret" user="oracle"/>
  • 10. Results Data Structure  Query(SELECT statement) result, is an array of Maps  Each Map represents a record in the database and each entry in the Map represents a column in the record.  Using a Groovy expression is one way of retrieving the required data from the result set.
  • 11. JDBC - CE vs EE  The EE version of the JDBC transport offers a number of extra features over and above the features provided by the CE version. List of JDBC features offered by both versions:  Select queries with acknowledgement  Basic Insert/Update/Delete: Single row Insert/Update/Delete  Basic Stored Procedure Support: Supports only in parameters  Unnamed Queries: Queries can be invoked programmatically  Flexible Data Source Config: Can configure data sources through JNDI, XAPool or Spring.  Transactions  Outbound Select Query: Retrieve records using the select statement configured on outbound endpoints.  The EE JDBC transport also offers:  Large Dataset Retrieval: Allows the consumption of records in smaller batches thus allows the retrieval of large datasets.
  • 12. JDBC - CE vs EE (Contd)  Batch Insert/Update/Delete: Batch inserts/update/delete improve the performance of the JDBC transport considerably when large datasets need to be inserted/updated.  Advanced Transformers: These transformers include XML and CSV transformers.  Advanced Stored Procedures: Allows both in and out parameters.
  • 13. JDBC Transactions  Similar to JMS, the JDBC transport has support for single resource JDBC transactions. This is configured using the jdbc:transaction element as seen in the following example. Eg: <jdbc:connector dataSource-ref="jdbcDataSource" name="jdbcConnector"> <jdbc:query key="JobSearch“ value="SELECT Id,Task FROM Jobs WHERE Started IS NULL"/> <jdbc:query key="JobSearch.ack“ value="UPDATE Jobs SET Started=#[function:now] WHERE Id = #[map- payload:Id]"/> <jdbc:query key="InsertNewTask“ value="INSERT INTO Tasks (JobId,Task) VALUES (#[map-payload:Id],#[map- payload:Task])"/> </jdbc:connector> <flow name="JdbcSimpleTransaction"> <jdbc:inbound-endpoint queryKey="JobSearch"> <jdbc:transaction action="ALWAYS_BEGIN"/> </jdbc:inbound-endpoint> <component class="com.mulesoft.MyCustomComponent"/> <jdbc:outbound-endpoint queryKey="InsertNewTask"> <jdbc:transaction action="ALWAYS_JOIN"/> </jdbc:outbound-endpoint> </flow>
  • 14. MEL - JDBC Arrays and Lists  Literal forms for Lists ({item1, item2, . . }) and Arrays ([item1, item2, . . ]). Using the literal form the payload can be set by: Eg: Message.payload = ({‘foo’, ‘bar’, ‘dog’}) This will set the payload to a list of 3 elements. In the MEL, as in many other languages, indexes start at 0. Eg: Message.payload[2] results in ‘dog’  Arrays and Lists in Java must specify the type of their contents, but in MEL they are untyped.  The MEL supplies the correct type when we use them – either by determining it at compile time or coercing the array to the correct type at run time. Eg: Valid MEL: Message.payload = ({‘foo’, 1234, 1234.56}) Mule Maps  The MEL has built-in support for maps.  Maps are used to store "associative arrays" or "dictionaries". Eg: Message.payload = [ "Brett":100,"Pete":"Did not finish", "Andrew":86.879]
  • 15. MEL – JDBC (Contd)  MEL provides a very clean way to access the values in a map.  Use square brackets to address the key:  Eg: Message.payload ["Pete"] => Output: 'Did not finish'  The MEL supplies the correct type when we use them – either by determining it at compile time or coercing the array to the correct type at run time. If there is no value, the operation returns a Null. Arrays of Maps  The very common Mule Payload is an array of maps Eg: {['destination':'SFO', 'price':500]}. Price of SFO can be found by Message.payload[0]['price']  The following example shows how to check the size of an array in a WHEN statement, evaluates to true if the array is not empty: Eg: <when expression="message.payload.size() > 0"> This can be used to avoid NullPayloads when potentially asking for something that the database didn't return any values for.