Hi Niranda, In c5, you can fetch a datasource object using the data source service or using the jndi context manager. [1]
[1] https://github.com/wso2/carbon-datasources Thanks, Chanaka. On Tuesday, September 27, 2016, Niranda Perera <[email protected] <javascript:_e(%7B%7D,'cvml','[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.carbo > n.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/ > -- Chanaka Cooray Software Engineer, WSO2 Inc. http://wso2.com Email: [email protected] Mobile: +94713149860 <https://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
