10
CONNECTING TO MS SQL SERVER WITH MULESOFT (QUERY DATABASE)

Connecting To MS SQL Server With Mulesoft (Query Database)

Embed Size (px)

Citation preview

Page 1: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING TO MS SQL SERVER WITH

MULESOFT (QUERY DATABASE)

Page 2: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Mulesoft provides wide range of connectors which is very handy while integrating solution. In many

scenarios, we required to connect to database for querying, inserting and updating the table.

Mulesoft provides a database connector which allows JDBC connectivity with relational database to

execute various SQL operations like Select, Insert, Update, Delete and Stored Procedures.

Mulesoft provide database connector to connects various JDBC databases like MS SQL, Oracle,

Derby, MYSQL etc.

Prerequisite To connect MS SQL Server With Mulesoft

• Download and Install sqljdbc4.jar file. It will require to connect MS SQL database.

• Ensure that TCP/IP port is enabled in SQL configuration (default port is 1433).

• Add sqljdbc4.jar into your build path of Mule application. Right click on your application then

Build Path < Configure Build Path < Libraries < Add External Jars.

Page 3: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Page 4: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Place HTTP Listener components at the message source in Mule flow and

configure it.

Use flow variable to store query parameter and this flow variable can be used

in select query as filter expression.

Page 5: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Place the database component at message processor and configure Generic

Database Configuration and press OK.

Page 6: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Now, provide Database Url and Drive Class Name. Press OK.

Make sure you are selecting the Operation. In this case we will use Select

operation.

URL: jdbc:sqlserver://${mssql.server}:${mssql.port};databaseName=${mssql.database};user=${mssql.user};password=${mssql.password}

Driver Class Name: com.microsoft.sqlserver.jdbc.SQLServerDriver

Page 7: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Provide Parameterized Query as per your requirements.

Page 8: Connecting To MS SQL Server With Mulesoft (Query Database)

CONNECTING MS SQL SERVER TO QUERY DATA FROM TABLE

Now, select query will return result as java.util.LinkedList object. So need to use

Object to Json transformer.

Page 9: Connecting To MS SQL Server With Mulesoft (Query Database)

TESTING APPLICATION

We will use Postman to test the application and url will used to invoke Mule Flow

http://localhost:8081/country?country=India

Page 10: Connecting To MS SQL Server With Mulesoft (Query Database)

THANK YOU.