Similar approach is used in ml [1] too.

[1]
https://github.com/wso2/carbon-ml/blob/master/components/ml/org.wso2.carbon.ml.database/src/main/java/org/wso2/carbon/ml/database/internal/MLDataSource.java#L30

Regards,

On Tue, Sep 27, 2016 at 8:03 AM, Niranda Perera <[email protected]> wrote:

> Hi all,
>
> I want to use a jdbc connection provided by a carbon-datasource.
>
> I found the following blog from Kishanthan [1], which was done in 2013.
>
> it uses the org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory as
> follows
>
> Hashtable environment = new Hashtable();
>  environment.put("java.naming.factory.initialoorg.wso2.carbon.tomcat.jndi.
> CarbonJavaURLContextFactory");
>     Context initContext = new InitialContext(environment);
>     Object result = initContext.lookup("jdbc/MyCarbonDataSource");
>     if (result != null) {
>         // Do your work here
>     } else {
>         System.out.println(“Cannot find MyCarbonDataSource”);
>     }
>
> My question is, is there a better way of doing this now (a util method may
> be?) or is this method still applicable?
>
> Best
>
> [1] https://kishanthan.wordpress.com/2013/02/11/access-cabon-data-sources-
> within-webapps-in-wso2-application-server/
>
> --
> *Niranda Perera*
> Software Engineer, WSO2 Inc.
> Mobile: +94-71-554-8430
> Twitter: @n1r44 <https://twitter.com/N1R44>
> https://pythagoreanscript.wordpress.com/
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Supun Sethunga*
Senior Software Engineer
WSO2, Inc.
http://wso2.com/
lean | enterprise | middleware
Mobile : +94 716546324
Blog: http://supunsetunga.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to