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

Reply via email to