Hi Nuwan, On Thu, May 3, 2012 at 10:01 AM, Nuwan Bandara <[email protected]> wrote:
> Hi Anjana, > > I would like to know how I can use the data source component for the > Database API we provide via Jaggery. right now we using DBCP and obtain a > database connection where the user is specifying the connection url etc. do > you see a usecase to use the data source component. > So the data source implementation can be used in two ways. First just as an API to creating DataSource objects to create connections. This is creating your own data sources locally in your app, without registering it in a global way. That is where you will simply need to use the "org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource", where you can give it the properties like connection URL, user / password and all and create connections. The other case is to register the data sources globally, using the *-datasources.xml files in the file system or in the registry by users using the UI. In this way, you can do a JNDI lookup or use the OSGi service that is provided to do an in-memory lookup to get the data sources. The advantage of this is, the connection pools are centrally handled, and also have automatic sync of data sources within a cluster, which is basically, if you update/delete a data source in one node, it will be reflected by all the nodes in the cluster. So in short I guess, in Jaggery, you can use "org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource" in creating local data sources, which you will in turn will get the jdbc-pool functionality, and also give support for providing a JNDI name and do a lookup internally (in case you don't already have it yet), for creating database connections. Cheers, Anjana. > > Regards, > /Nuwan > > > On Thu, May 3, 2012 at 9:57 AM, Anjana Fernando <[email protected]> wrote: > >> Hi Amila, >> >> On Thu, May 3, 2012 at 9:28 AM, Amila Jayasekara <[email protected]> wrote: >> >>> >>> +1 for having a unified data source access management across the >>> platform. This will solve the issue of creating multiple database >>> pools by each component. But is there a specific reason to switch to >>> jdbc-pool from DBCP ? >>> >> >> Yeah, Tomcat guys have given a list of reasons here [1], at the beginning >> of the page, onto why they created a new pooling implementation. They have >> mentioned, DBCP is single threaded and because of poor concurrency >> handling, it's comparatively slow, not actively developed anymore, and >> jdbc-pool is a much simpler implementation with more features and have >> better performance. >> >> >> [1] http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html >> >> Cheers, >> Anjana. >> >> >>> >>> Thanks >>> AmilaJ >>> >>> > >>> > >>> > >>> > On Thu, May 3, 2012 at 6:03 AM, Anjana Fernando <[email protected]> >>> wrote: >>> >> >>> >> Hi, >>> >> >>> >> I've implemented a new data source implementation, which was added to >>> the >>> >> Carbon Core. It was added to Carbon Core because, this functionality >>> is to >>> >> be used by registry / user manager in looking up data sources using >>> JNDI. >>> >> Following are the improvements over the older implementation. >>> >> >>> >> * The connection pooling implementation has been changed to jdbc-pool, >>> >> from DBCP, all of jdbc-pool properties are supported, see [1]. >>> >> * Carbon Secure Vault support. >>> >> * Encryption of password fields etc.. when persisting data sources in >>> the >>> >> registry. >>> >> * Database provider given DataSource support, i.e. that implements >>> >> javax.sql.DataSource, javax.sql.XADataSource, for example if someone >>> need to >>> >> use Oracle supplied poolable DataSource implementation, it is >>> possible to do >>> >> so, and also required for creating data sources to be used in >>> distributed >>> >> transactions. >>> >> * Automatic sync of data sources in a clustered environment using the >>> >> coordination component. >>> >> * Pluggable data source types, so other than RDBMS data sources can be >>> >> registered using this (for in-memory, JNDI access). >>> >> >>> >> The earlier datasources.properties like functionality is now given >>> using a >>> >> separate directory for defining data source, at >>> >> /repository/conf/datasources/. Inside it, it has a single file >>> >> master-datasources.xml that is coming from Carbon Core. It contains >>> the data >>> >> source definition for registry/user-manager database. A single file >>> can >>> >> contain multiple data sources. If need to add more data sources, also >>> a new >>> >> file with the pattern *-datasources.xml can be created, and they will >>> be >>> >> loaded. This was done for products to easily add data sources, for >>> example, >>> >> bps-datasources.xml separately, without maintaining one global data >>> sources >>> >> file, which means, it has to maintain data sources used in Carbon >>> Core in >>> >> their product. >>> >> >>> >> A UI has not been yet created for this, it will be added when the >>> product >>> >> releases are done. I've simply tested the functionality by manually >>> calling >>> >> the admin service. >>> >> >>> >> I was told that the registry support looking up data sources using >>> JNDI, >>> >> but I couldn't find the configuration element that is used to do it. >>> Senaka, >>> >> please add the necessary settings for registry.xml, the JNDI name to >>> use is >>> >> "jdbc/WSO2CarbonDB", which is mentioned in master-datasources.xml. >>> >> >>> >> Also, the places that contain DBCP code, please migrate the code to >>> the >>> >> new implementation, an RDBMS data source can be directly created >>> using the >>> >> class "org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource". >>> >> >>> >> [1] http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html >>> >> >>> >> Cheers, >>> >> Anjana. >>> >> -- >>> >> Anjana Fernando >>> >> Associate Technical Lead >>> >> WSO2 Inc. | http://wso2.com >>> >> lean . enterprise . middleware >>> >> >>> >> _______________________________________________ >>> >> Dev mailing list >>> >> [email protected] >>> >> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >> >>> > >>> > >>> > >>> > -- >>> > /sumedha >>> > +94 773017743 >>> > >>> > _______________________________________________ >>> > Architecture mailing list >>> > [email protected] >>> > https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture >>> > >>> >>> >>> >>> -- >>> Mobile : +94773330538 >>> >> >> >> >> -- >> *Anjana Fernando* >> Associate Technical Lead >> WSO2 Inc. | http://wso2.com >> lean . enterprise . middleware >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > *Thanks & Regards, > > Nuwan Bandara > Associate Technical Lead & Member, MC, Development Technologies > WSO2 Inc. - lean . enterprise . middleware | http://wso2.com > blog : http://nuwanbando.com; email: [email protected]; phone: +94 11 763 > 9629 > * > <http://www.nuwanbando.com/> > -- *Anjana Fernando* Associate Technical Lead WSO2 Inc. | http://wso2.com lean . enterprise . middleware
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
