Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
1. ConnectingTo MS SQL Server With
Mulesoft (Stored Procedure To Insert
data)
JITENDRA BAFNA
2. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into 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.
3. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into Table
4. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into Table
Place HTTP Listener components at the message source in Mule flow and
configure it.This time we will use POST method.
Place the database component at message processor and configure Generic
DatabaseConfiguration in same way as we have done above and press OK.
Make sure you are selecting the Operation. In this case we will use Store
Procedure operation.
5. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into Table
Now, provide Database Url and Drive Class Name. Press OK.
URL: jdbc:sqlserver://${mssql.server}:${mssql.port};databaseName=${mssql.database};user=${mssql.user};password=${mssql.password}
DriverClass Name: com.microsoft.sqlserver.jdbc.SQLServerDriver
6. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into Table
Provide the ParameterizedQuery depending on your requirements.
7. Connecting MS SQL Server To Call Stored Procedure To
Insert Data Into Table
Add Parameter and map fields with input json message.
8. Connecting MS SQL Server To Call Stored Procedure
To Insert Data Into Table
Add Parameter and map fields with input json message.
{
"Country":"India",
"Year":"2005",
"TotalPopulation":"1000000"
}
9. Testing Application
We will use Postman to test the application and url will used to invoke Mule
Flow http://localhost:8081/