WSO EI 6.2.0 - Options to call stored procedure on 'Google Cloud SQL'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

WSO EI 6.2.0 - Options to call stored procedure on 'Google Cloud SQL'

JSBB
Hi Team,

Can i request some information? we have a requirement to call a database stored procedure on 'Google Cloud SQL' to insert data, but i do not find anything from the WSO2 documentation. Any suggestions?

--
JSB

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WSO EI 6.2.0 - Options to call stored procedure on 'Google Cloud SQL'

Rensburg, Eldrid

<!-- One way of implementation in WSO2 Integrator -->

In Eclipse, create: WSO2 > Extensions > Project Types > Mediator Project

Code fragment:

import org.apache.synapse.mediators.AbstractMediator;

import java.sql.CallableStatement;

import java.sql.DriverManager;

public class CustomMediatorClass extends AbstractMediator {

                public boolean mediate(MessageContext msgCtxt) {

                                ...

                                Connection con = DriverManager.getConnection(dbURL, dbUsr, dbPswd);

                                CallableStatement cs = null;

                                …

                                cs = con.prepareCall("{call yourSP(?, ?)}");

                                cs.setString(1, spParm01); // spParms from msgCtxt

                                cs.setString(2, spParm02);

                                ...

                                cs.execute();

                                if (con != null && !con.isClosed()) {

                                                con.close();

                                                con = null;

                                }

                                ...

                                return true;

                }

}

Build your jar, copy to WSO2_HOME\lib\ - restart Integrator

Include in your Sequence, REST API: <class name="org.your-org.mediator.CustomMediatorClass"/>

ReDeploy your CompositeApp to Integrator

<!-- Hope this helps for your requirement -->

 

Regards

Eldrid

 


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: WSO EI 6.2.0 - Options to call stored procedure on 'Google Cloud SQL'

Rensburg, Eldrid
In reply to this post by JSBB

<!-- One way of implementation in WSO2 Integrator -->

In Eclipse, create: WSO2 > Extensions > Project Types > Mediator Project

Code fragment:

import org.apache.synapse.mediators.AbstractMediator;

import java.sql.CallableStatement;

import java.sql.DriverManager;

public class CustomMediatorClass extends AbstractMediator {

                public boolean mediate(MessageContext msgCtxt) {

                                ...

                                Connection con = DriverManager.getConnection(dbURL, dbUsr, dbPswd);

                                CallableStatement cs = null;

                                …

                                cs = con.prepareCall("{call yourSP(?, ?)}");

                                cs.setString(1, spParm01); // spParms from msgCtxt

                                cs.setString(2, spParm02);

                                ...

                                cs.execute();

                                if (con != null && !con.isClosed()) {

                                                con.close();

                                                con = null;

                                }

                                ...

                                return true;

                }

}

Build your jar, copy to WSO2_HOME\lib\ - restart Integrator

Include in your Sequence, REST API: <class name="org.your-org.mediator.CustomMediatorClass"/>

ReDeploy your CompositeApp to Integrator

<!-- Hope this helps for your requirement -->

 

Regards

Eldrid

 

Including the original msg in email trail:

 

From: Dev <[hidden email]> On Behalf Of Sanjay Bawri
Sent: 06 March 2019 20:56
To: [hidden email]
Subject: [Dev] WSO EI 6.2.0 - Options to call stored procedure on 'Google Cloud SQL'

 

This email originated from outside of CGM. Please do not click links or open attachments unless you know the sender and know the content is safe.

 

Hi Team,

 

Can i request some information? we have a requirement to call a database stored procedure on 'Google Cloud SQL' to insert data, but i do not find anything from the WSO2 documentation. Any suggestions?

 

--

JSB


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev