Dynamic shared datasource

Hi,
   How to create a dynamic shared data source in SSRS?

Hi,
  Dynamic in the sense i can connect to all SQL servers in my environment using a single data source by giving expression. How i can convert this data source into shared data source? I'm getting error that Expression defined data source can't be converted
into shared data source.
Yes its a SSRS limitation
expression based connection string is only alllowed for embedded data sources
But you can apply this workaround if you want which would require a linked server setup
http://blog.softartisans.com/2011/04/19/how-to-create-a-dynamic-reporting-services-shared-data-source-using-linked-servers/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Shared Datasource Is Not Valid Error

    Using Reporting Services (SQL Server 2008 R2), I have a VS SSRS project with 23 reports, all running off the same Shared Data Source.  They all execute in VS.  I have deployed the datasource, datasets & reports to server.  From the Report
    Manager, I can execute all reports except 4, which have the same error:
    The report server cannot process the report or shared dataset. The shared data source '22d600c2-a3d5-4178-8a39-d05361607ebd' for the report server or SharePoint site is not valid. Browse to the server or site and select a shared data source. (rsInvalidDataSourceReference)
    I have tried the following, without success:
    1)verified that the datasource exists in the Data Sources folder, and is Enabled
    2) Checked and reset the Shared Datasource to point to the deployed datasource in the Data Sources folder
    3) Recreated & redeployed the datasource
    4) Deleted the 4 reports on the server and re-deployed
    5) Deleted the reports, used Upload instead of Deploy, then set the Shared Datasource to point to the one on the server
    6) Verified that the Link column in ReportServer.DataSource is NOT NULL.  Actually have the same Link as the other 19 reports.  Verified that the GUID in the LinkID exists in Catalog table and is the id for the Datasource.
    No matter what I have tried, for some reason, the GUID in these failing reports appear to get set to '22d600c2-a3d5-4178-8a39-d05361607ebd', which does not exist in Catalog table.  The other reports never fail, these reports never execute.  Anyone
    have any ideas?
    Victor 
     

    As I recall, I went into the Report server db and updated the Catalog table.  Open the table and you'll find your reports listed with a link to their datasource (in the DataSource table).  I found the 4 reports that failed had a different value
    in the LinkID column than the reports that executed, even though they use the same shared datasource.
    So I copied the good LinkID value (a GUID) into the 4 reports that failed, and then they ran fine.    For some unknown reason, there was an invalid value stuck in the LinkID column which pointed to a datasource that really did not exist. 
    Go figure.
    Victor
    Victor Kushdilian

  • Shared datasource using stored credentials still keeps prompting for password

    We have a reporting services running in sharepoint 2013 integrated mode.We have deployed a shared datasource and used a stored credentials to connect to an oracle database. However, whenever i try to build a report and use this report datasource, it will
    display a dialog box and prompt for the stored credentials password, and once the password has been entered, we can succeessfully connect to the oracle db and build our report. For security reasons, we can't divulge the password to the users.
    Is there anyway where reporting service will not prompt for the stored credentials password whenever we use this data source to build our report. We have already prepopulated the password in the data source definition page. Please help

    In the Shared Data Source, where you configured the name and password, there are two boxes that could be ticked:
    1. If the account is a Windows domain user account, specify it in this format: <domain>\<account>, and then select
    Use as Windows credentials when connecting to the data source.
    2. If the user name and password are database credentials, do not select
    Use as Windows credentials when connecting to the data source. If the database server supports impersonation or delegation, you can select
    Impersonate the authenticated user after a connection has been made to the data source.
    I'm not sure if Oracle allows for Windows authentication.  You need to tick one of these two boxes for the password to be passed through to the database.
    Cheers,
    Martina White

  • Shared DataSource

    Now that SSDT BI has been released for 2014 for a while, is it possible for a single shared DataSource to be referenced/used across SSRS Projects?  If not, why has this functionality been added yet?  With all the power and functionality of Visual
    Studio 2013 and TFS and the .NET Framework, I still find myself developing with one hand tied behind my back when developing SSRS. 
    The laundry list at this point includes:
    There is no way for projects to reference one another to share common functionality
    The Folder structure is flat which just causes clutter when projects start to grow more than 15 files
    The core rs.exe deployment logic requires VB.NET when the majority of .NET development is done on C#
    The version of .NET supported through RS.exe doesn't appear to be any greater than 2.0
    The WebServer/Services are still running on the .NET 3.5 Framework
    When deploying through SSDT, there is no way to indicate if the directories should be hidden or descriptions be added to reports

    Hi Chritopher,
    Just as you said, a shared data source cannot be used across projects in SQL Server Data Tools. It is a set of data source connection properties that can be referenced by multiple reports, models, and data-driven subscriptions that run on a Reporting Services
    report server.
    And the script must be written in Visual Basic .NET code, and stored in a Unicode or UTF-8 text file with an .rss file name extension when using rs.exe utility processes it. Other features you post are still not updated.
    Personally, I understand your feeling and how frustrated when you find this issue. So, it is my pleasure to help you to reflect your recommendation to the proper department for their consideration. Please feel free to submit your situation on our product
    to the following link:
    https://connect.microsoft.com/SQLServer/Feedback. Your feedback is valuable for us to improve our products and increase the level of service provided.
    Thank you for your understanding.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Why do shared datasources have to reside with the project?

    Background:
    SQL SERVER 2008 r2
    Visual Studio 2008
    I inherited a mess that I'm trying to clean up.  We have 8 projects for a single application and each one of these projects has its own solution.  I'm trying to create a single solution that holds all 8 projects with each project in it's own folder.
     I'm able to add all 8 projects to a single solution in Visual Studio but the problem I'm having is with shared datasources and datasets.  Every one of these projects is using a single datasource pointing to the exact same database.  When I
    add the shared datasource to the project it copies it to the project folder.  I end up with the exact same datasource in 8 different folders.  The same holds true for the datasets.
    The report server as a separate folder for the shared datasources and another for the shared datasets.  The reports are in their own folders.  How can I replicate this hierarchy in Visual Studio?

    Hi RayMajewski,
    Per my understanding that you have 8 projects and you want to move these 8 projects under a single solution, but now you have some issue with the shared data sources and datasets, right?
    As you know, by default when you create to add an new project, there will be three default folders under the project, if each 8 project have its own shared data sources and shared Datasets, when move to one solution, the shared data sources and
    shared Datasets will keep together under the project.
    Please reference to details information below to make sure you have move the project correctly.
    Copy the 8 projects to the solution folder in the local disk: .\\Visual Studio 2008\Projects\Solution2.
    Click the file and select the Open to open "Solution/Project" to add these project to the solution one by one:
    You will find the data sources and datasets move together under the project like below:
    If what you want is to replicate this hierarchy in Visual Studio outside the project, currently we couldn't find any good method to do this and it is not support to keep them outside of the current project. If all the 8 project point to the same database,
    you can just copy the share data source from one project to another project to create the same shared data source in another project.
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • Dynamic xml datasource

    Post Author: ililal
    CA Forum: Data Connectivity and SQL
    This is a java web application  using:jdk 1.4.12crystal reports xi r2sun application server  8.2Here's the problem:I would like to generate a dynamic XML document as the datasource. (This XML datasource is a result set from a query.  I've completed and tested the XML file; it works.) Using this new XML datasource as the driver for the Crystal Report, my reports should display in a web environment.BTW, I created the Crystal Report rpt file by first selecting XML.  Created a second report with the Database  files option.  They both worked with in the Crystal report view section; however, they didn't work in the application.this is the error:com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: No database connector has been specified.---- Error code :-2147467259 Error code name:failedI've searched the net with no luck.Hereu2019s my source code:ReportClientDocument reportClientDoc = new ReportClientDocument();reportClientDoc.open("Report1.rpt", 0);             IXMLDataSet xmlDS = new XMLDataSet(new ByteArray(bytesFromFile(XMLFileLocation)), new ByteArray(bytesFromFile(XMLFileLocation)));// Change the XML datasource to the new XML datasource reportClientDoc.getDatabaseController().setDataSource(xmlDS, "", "");

    Post Author: ililal
    CA Forum: Data Connectivity and SQL
    I spoke directly with Business Objects. They said,"Sun Application Server 8.2 is not supported."

  • Dynamically creating DataSources

    Our current client requirements dictates that as new Engineering projects are started that a seperate instance of our Engineering database needs to be set up. I have a login screen in which a user enters the project number they need to connect to and the application then connects to the correct DataSource and everything works as planned. However, new projects are added daily and I need to be made aware of the additions and update the datasources.xml then restart oc4j. This is becoming a maintenence nightmare. The way I plan on circumventing this is to catch the NamingException when a lookup on a nonexistent datasource is done then dynamically create the datasource by modifing the datasources.xml file. This I have succeeded in doing but the oc4j container still requires a restart. Can I programitically bind the required datasources to the JNDI tree so they are available without a restart or is there some other way I could accomplish this.

    Buster -- You cannot programmatically bind the data source but you could call out to admin.jar to create a new data source for you and then you do not need to restart OC4J.
    Thanks -- Jeff

  • Dynamic Shared Object - Is This Possible?

    What I want in my app is to have 2 tilelists and an array collection of items which will populate the first tilelist and these objects can be dragged between both tilelists. Then the user can click a save button which will save the statuses of both tilelists so the items that are present/not present in each tilelist when the app is closed will still be there when the app is restarted.
    The problem is I want my array collection to be populated dynamically from mysql data on a server.
    I have no problem getting dynamic data from a mysql database into an array colllection via http request and I have no problem getting the shared object to work IF the array collection is defined within the app the usual way but I'm having trouble getting these 2 things to work together. 
    Can anybody tell me if it is indeed possible to have a dynamically populated array collection stored as a shared object on the user's system and would anyone be willing to help me out if I post my code so far? Cheers.

    Hi Greg. The way I usually post code is by clicking the small arrows above and then clicking syntax highlighting and then xml. The problem is this seems to remove all of the quotation marks ("") from my code which is what is causing the errors you mentioned. I've posted it below just by simply copying and pasting. I hope that works better. Cheers for your help:-
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="newsService.send(); initprofile1NewsAndSportSO()">
    <mx:Script><![CDATA[
     import mx.rpc.events.ResultEvent; 
    import mx.collections.*; 
    import flash.net.SharedObject; 
    public var profile1NewsAndSportSO:SharedObject; 
    Bindable] 
    private var profile1NewsAndSportaddLinksFullAC:ArrayCollection; 
    Bindable] 
    private var profile1NewsAndSportaddLinksAC:ArrayCollection; 
    private function newsResultHandler(event:ResultEvent):void{
    profile1NewsAndSportaddLinksFullAC=newsService.lastResult.newscategory.news
    as ArrayCollection;profile1NewsAndSportaddLinksAC=newsService.lastResult.newscategory.news
    as ArrayCollection;}
    // private var profile1NewsAndSportaddLinksFullAC:ArrayCollection = new ArrayCollection([
    // {label:"BBC News"},
    // {label:"ITV"},
    // {label:"Sky News"}
    // ]); // private var profile1NewsAndSportaddLinksAC:ArrayCollection = new ArrayCollection([
    // {label:"BBC News"},
    // {label:"ITV"},
    // {label:"Sky News"}
     private function profile1NewsAndSportReset():void{resetprofile1NewsAndSportAC();
    profile1NewsAndSportAddLinksTilelist.dataProvider = profile1NewsAndSportaddLinksAC;
    profile1NewsAndSportLinkChoice.dataProvider =
    new ArrayCollection([]);}
    private function resetprofile1NewsAndSportAC():void{profile1NewsAndSportaddLinksAC.removeAll();
    for each(var obj:Object in profile1NewsAndSportaddLinksFullAC){profile1NewsAndSportaddLinksAC.addItem(obj);
    private function initprofile1NewsAndSportSO():void{profile1NewsAndSportSO = SharedObject.getLocal(
    "profile1NewsAndSport"); 
    if(profile1NewsAndSportSO.size > 0){ 
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList){ 
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList != "empty"){ 
    var profile1NewsAndSportaddList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportaddList.split(","); 
    var profile1NewsAndSporttempAC1:ArrayCollection = new ArrayCollection(); 
    for each(var str:String in profile1NewsAndSportaddList){ 
    for each(var obj1:Object in profile1NewsAndSportaddLinksAC){ 
    if(str == obj1.label){profile1NewsAndSporttempAC1.addItem(obj1);
    continue;}
    if(profile1NewsAndSporttempAC1.length > 0){profile1NewsAndSportAddLinksTilelist.dataProvider = profile1NewsAndSporttempAC1;
    if(profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList){ 
    var profile1NewsAndSportchoiceList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList.split(","); 
    var profile1NewsAndSporttempAC2:ArrayCollection = new ArrayCollection(); 
    for each(var str2:String in profile1NewsAndSportchoiceList){ 
    for each(var obj2:Object in profile1NewsAndSportaddLinksAC){ 
    if(str2 == obj2.label){profile1NewsAndSporttempAC2.addItem(obj2);
    continue;}
    if(profile1NewsAndSporttempAC2.length > 0){profile1NewsAndSportLinkChoice.dataProvider = profile1NewsAndSporttempAC2;
    else{profile1NewsAndSportReset();
    private function saveprofile1NewsAndSport(event:MouseEvent):void{ 
    var profile1NewsAndSportaddList:String = ""; 
    if(profile1NewsAndSportAddLinksTilelist.dataProvider){ 
    if(ArrayCollection(profile1NewsAndSportAddLinksTilelist.dataProvider).length > 0){ 
    for each(var obj1:Object inprofile1NewsAndSportAddLinksTilelist.dataProvider){
    profile1NewsAndSportaddList += obj1.label +
    else{profile1NewsAndSportaddList =
    "empty";}
    profile1NewsAndSportSO.data.profile1NewsAndSportaddList = profile1NewsAndSportaddList;
    var profile1NewsAndSportchoiceList:String = ""; 
    for each(var obj2:Object inprofile1NewsAndSportLinkChoice.dataProvider){
    profile1NewsAndSportchoiceList += obj2.label +
    profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList = profile1NewsAndSportchoiceList;
    profile1NewsAndSportSO.flush();
    ]]>
    </mx:Script>
     <mx:HTTPService id="newsService" resultFormat="object" result="newsResultHandler(event)" url="http://www.coolvisiontest.com/getnews.php"/> 
    <mx:TileList id="profile1NewsAndSportLinkChoice" fontWeight="bold" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" height="166" width="650" top="5" left="521" columnCount="5" rowHeight="145" columnWidth="125" backgroundColor="#000000" color="#FFFFFF">
     <mx:itemRenderer>
     <mx:Component>
     <mx:Canvas width="125" height="129" backgroundColor="#000000">
     <mx:Image source="{'http://www.coolvisiontest.com/interfaceimages/images/'+ data.icon}" top="5" horizontalCenter="0"/>
     <mx:Label text="{data.label}" bottom="1" horizontalCenter="0"/>
     </mx:Canvas>  
    </mx:Component>
     </mx:itemRenderer>  
    </mx:TileList>
     <mx:TileList id="profile1NewsAndSportAddLinksTilelist" fontWeight="bold" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" height="166" width="385" top="5" left="128" columnCount="3" rowHeight="145" columnWidth="125" backgroundColor="#000000" color="#FFFFFF">
     <mx:itemRenderer>
     <mx:Component>
     <mx:Canvas width="125" height="129" backgroundColor="#000000">
     <mx:Image source="{'http://www.coolvisiontest.com/interfaceimages/images/'+ data.icon}" top="5" horizontalCenter="0"/>
     <mx:Label text="{data.label}" bottom="1" horizontalCenter="0"/>
     </mx:Canvas>  
    </mx:Component>
     </mx:itemRenderer>  
    </mx:TileList>
     <mx:Button click="profile1NewsAndSportReset()" id="reset" label="Reset" y="5" height="25" x="5"/>
     <mx:Button click="saveprofile1NewsAndSport(event)" id="save" label="Save Changes" x="5" y="38" width="113" height="25.5"/>
     </mx:WindowedApplication>

  • Pass parameter to dynamically assign datasource?

    Post Author: bradness
    CA Forum: Data Connectivity and SQL
    I've been struggling with this one... I have a current set of reports that run on a single set of SQL queries. The problem is that at the end of each period (lets just say a year) the tables and queries are archived and relabled with <tablenameyear>/<querynameyear>, so that each query will pull the appropriate year's data. Can I pass a parameter to my reports that will tell the report which set of queries to use as the datasource? And can this be passed onto each subreport within the Parent report?
    Thanks in advance.

    Post Author: bradness
    CA Forum: Data Connectivity and SQL
    SUCCESS! Thank you kcheeb for your help!
    I don't know why it required that I do it this way, but it works.My report and 4 subreports used a total of 7 different tables (which were already defined in SQL database)I had to create all 7 tables in VB as follows
    conn_string.open()Dim SQL as string = "SELECT * FROM mytable"Dim cmd as new sqlCommand(SQL, conn_string)Dim dr as sqldatareaderdr = cmd.executereaderDim nTable as datatable = new dataTablenTable.Load(dr)conn_string.close()
    Then using some logic to determine object was report or subreport, I had to set the datasource for each table that was original contained in the report. Using
    crdocument.Database.Tables("tableName").SetDataSource(nTable)   for main report tablescrdocument.OpenSubreport("subreportName").Database.Tables("tableName").SetDataSource(nTable) for subreport tables

  • Installing the Apache HTTP Server Plug-In as a Dynamic Shared Object

    My environment is: Windows 2000 Server SP3 + Apache 2.0.45 + WebLogic 7.0 SP2
    I followed the install guide.
    1. Locate the shared object file for your platform. >>> No problem
    2. Enable the shared object. >>> No problem
    3. Install the Apache HTTP Server Plug-In in the Apache server with a support
    program called apxs (APache eXtenSion) that builds DSO-based modules outside of
    the Apache source tree, and adds the following line to the httpd.conf file:
    >>> I don't know how to do this. where can I find apxs,
    >>> and should I add "AddModule mod_so.c" in httpd.conf
    >>> I did it, but Apache -t tell me:
    >>> Syntax error on line 173 of D:/Program/Apache/Apache2/conf/httpd.conf:
    Invalid command 'AddModule', perhaps mis-spelled or defined by a module not incl
    uded in the server configuration
    I don't understand the 4th step, where can I find 'perl' and how to use it?
    thanks.

    For Apache 2.x I think you use LoadModule instead of AddModule. That's what
    the docs say anyway.
    "muli" <[email protected]> wrote in message
    news:3ed558aa$[email protected]..
    >
    My environment is: Windows 2000 Server SP3 + Apache 2.0.45 + WebLogic 7.0SP2
    >
    I followed the install guide.
    1. Locate the shared object file for your platform. >>> No problem
    2. Enable the shared object. >>> No problem
    3. Install the Apache HTTP Server Plug-In in the Apache server with asupport
    program called apxs (APache eXtenSion) that builds DSO-based modulesoutside of
    the Apache source tree, and adds the following line to the httpd.conffile:
    I don't know how to do this. where can I find apxs,
    and should I add "AddModule mod_so.c" in httpd.conf
    I did it, but Apache -t tell me:
    Syntax error on line 173 ofD:/Program/Apache/Apache2/conf/httpd.conf:
    Invalid command 'AddModule', perhaps mis-spelled or defined by a modulenot incl
    uded in the server configuration
    I don't understand the 4th step, where can I find 'perl' and how to useit?
    >
    thanks.

  • Dynamic shared variable node

    Hello, i'd like something like a Shared Variable Node, but with ability to choose at runtime which variable to read/write, for example passing a variable name. Is it possible?
    I have the DSC module and it supports "Shared Variable Costant", which can be passed to a Property Node and allows to dinamically access a SV's properties, but apparently not its value and error status.
    I tried to retrieve the DataSocketURL property and pass it to "Datasocket Read"; it kinda works, but i'm not sure if it's equivalent to a SV Node... it's slower and error status is not easily detected. May it be the right way?

    Greetings and Merry Christmas,
    I guess I’m a little confused about your application. An idea for choosing a variable to read/write from your front panel would be with a state diagram. This could be placed in a stacked sequence to occur first. Is that what you are trying to accomplish? Would you please elaborate on your application as well as what you mean about “choosing a variable”
    For the Shared Variable Constant, I’m not sure why you would want to pass the value or error status when you could just deploy the shared variable?
    Let me know of any head way and good luck!
    Jordan Randall
    National Instruments Italy

  • Dynamically Change DataSource.

    Hi
    I have a VO for a table that exists across multiple databases. The user requirement is to be able to select a database name from a list. I then need to dynamically change the data source on the application module to ensure that the correct data is populated in the VO.
    My approach is to get the configuration using the following code;
    Configuration cfg = new Configuration();
    Hashtable htab = cfg.getConfiguration("AppModuleLocal");
    This however returns a constant error of : "JBO-33005: Configuration AppModuleLocal is not found." I have read various post and tried many different suggested solutions without success for this error.
    Once I can resolve this error, my idea would be to try and change the Data Source Name of the configuration.
    Firstly, is this the correct approach or is there another way to dynamically change the Data Source name, and if so what are my options.
    Regards
    Leon.

    try : accessing a data source....
    Connection Pooling in Data Source
    Amit
    Edited by: amseth on Jan 31, 2011 1:25 PM

  • Shared datasource during migration

    hi, just wanted to check something, even when I think it will not be a problem...
    just started a migration from sccm 2007 to 2012 R2.
    we will be running both environments in parallel for a while.
    in the 2007 environment, all content sources had been placed on a separate fileshare (not dfs)
    I consider I can just leave it there and that this will not be a problem for either environments?

    More info:
    Introduction to Migration in System Center 2012 Configuration Manager
    http://technet.microsoft.com/en-us/library/gg699364.aspx#BKMK_MigrationScenarios
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Dynamic Datasource creation

    I am trying to create datasources dynamically. Using an example from a previous
    post,
    mbeanHome = lookupMBeanHome();
    JDBCDataSourceMBean dsMBean = (JDBCDataSourceMBean)mbeanHome.createAdminMBean(poolName,"JDBCDataSource",
    mbeanHome.getDomainName());
    dsMBean.setJNDIName(poolName);
    dsMBean.setPoolName(poolName);
    dsMBean.addTarget(tserverMBean);
    dsMBean.setPersistenceEnabled(false);
    How can I retrieve the proper TargetMBean reference to send to the addTarget method.
    Does anyone know where I can find an entire class example of dynamically creating
    datasources, or something similar.
    Thanks in advance,
    Fahd

    Hi Fahd,
    Here is a sample I posted here some time ago
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.util.Iterator;
    import java.util.Set;
    import javax.naming.Context;
    import javax.sql.DataSource;
    import weblogic.jndi.Environment;
    import weblogic.management.configuration.JDBCDataSourceMBean;
    import weblogic.management.configuration.ServerMBean;
    import weblogic.management.MBeanHome;
    * This class demonstrates dymamic creation,
    * using and deletion of DataSource via
    * Weblogic management API.
    public class DynamicDataSource {
    private Context ctx = null;
    private JDBCDataSourceMBean dsMBean = null;
    private MBeanHome mbeanHome = null;
    private ServerMBean serverMBean = null;
    // DataSource attributes
    private String cpName = "yourPoolName";
    private String dsJNDIName = "dynamic-data-source";
    private String dsName = "dynamic-data-source";
    // Security credentials
    private String password = "admPasword";
    private String serverName = "yourServer";
    private String url = "t3://localhost:7701";
    private String userName = "system";
    * Creates and starts up a DataSource using
    * management API.
    public void createDataSource() throws SQLException {
    System.out.println("Creating DataSource...");
    try {
    // Get context
    Environment env = new Environment();
    env.setProviderUrl(url);
    env.setSecurityPrincipal(userName);
    env.setSecurityCredentials(password);
    ctx = env.getInitialContext();
    // Lookup for MBean home
    mbeanHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    serverMBean = (ServerMBean)mbeanHome.getAdminMBean(serverName,
    "Server");
    // Delete if DataSource MBean already exists in active domain
    Set dsMBeanSet = mbeanHome.getMBeansByType("JDBCDataSource",
    mbeanHome.getDomainName());
    Iterator iter = dsMBeanSet.iterator();
    while(iter.hasNext()) {
    JDBCDataSourceMBean dsmb = (JDBCDataSourceMBean) iter.next();
    if (dsmb.getJNDIName().equals(dsJNDIName)) {
    dsMBean = dsmb;
    deleteDataSource();
    break;
    // Create DataSource MBean
    dsMBean = (JDBCDataSourceMBean)mbeanHome.createAdminMBean(
    dsName, "JDBCDataSource",
    mbeanHome.getDomainName());
    // Set DataSource attributes
    dsMBean.setJNDIName(dsJNDIName);
    dsMBean.setPoolName(cpName);
    // Startup datasource
    dsMBean.addTarget(serverMBean);
    } catch (Exception ex) {
    throw new SQLException(ex.toString());
    * Symply gets and closes a connection from dynamic
    * DataSource. Will throw a SQLException if datasource
    * does not exists.
    public void createConnection() throws SQLException {
    System.out.println("Getting Connection...");
    try {
    DataSource ds = (DataSource)ctx.lookup (dsName);
    Connection conn = ds.getConnection();
    conn.close();
    } catch (Exception ex) {
    throw new SQLException(ex.toString());
    * Shuts down and deletes DataSource from configuratrion
    * using management API.
    public void deleteDataSource() throws SQLException {
    System.out.println("Deleting DataSource...");
    try {
    // Remove dynamically created datasource from the server
    dsMBean.removeTarget(serverMBean);
    // Remove dynamically created datasource from the configuration
    mbeanHome.deleteMBean(dsMBean);
    } catch (Exception ex) {
    throw new SQLException(ex.toString());
    public static void main(String args[]) {
    DynamicDataSource dds = new DynamicDataSource();
    try {
    dds.createDataSource();
    dds.createConnection();
    dds.deleteDataSource();
    } catch (SQLException ex) {
    ex.printStackTrace();
    "Fahd" <[email protected]> wrote in message
    news:[email protected]...
    >
    I am trying to create datasources dynamically. Using an example from aprevious
    post,
    mbeanHome = lookupMBeanHome();
    JDBCDataSourceMBean dsMBean =(JDBCDataSourceMBean)mbeanHome.createAdminMBean(poolName,"JDBCDataSource",
    mbeanHome.getDomainName());
    dsMBean.setJNDIName(poolName);
    dsMBean.setPoolName(poolName);
    dsMBean.addTarget(tserverMBean);
    dsMBean.setPersistenceEnabled(false);
    How can I retrieve the proper TargetMBean reference to send to theaddTarget method.
    >
    >
    Does anyone know where I can find an entire class example of dynamicallycreating
    datasources, or something similar.
    Thanks in advance,
    Fahd

  • Creating dynamic datasources. Is this possible?

    Can I create a 'subset datasource' from an existing datasource
    and then pass this subset datasource to the <jbo:RowsetIterate>
    Let's assume I have a datasource containing 100 records.
    How is is possible to create a new datasource from the exiting datasource
    which will contain 10 records and then this new data source will be passed
    to <jbo:RowsetIterate>?
    I'd like to write a JSP Tag which reads the datasource and creates a subset datasource
    dynamically
    public class SubsetDS extends TagSupport
         public int doStartTag() throws JspException
            ApplicationModule am  = dataSource.getApplicationModule();
            ViewObject vo = am.findViewObject("V0");  
             while(vo.hasNext()){
            Row r = vo.next();
                   // Iterate based on a certain condition and put the new records
            // in a dynamically created DataSource
    Is this possible?

    I don't know about the custom JSP tag part, there is a <jbo:CreateViewObject> tag and ApplicationModule.createViewObject() methods for defining ViewObjects at runtime. We were not able to locate a mechanism for actually running a query against one VO to select rows for a second VO (whether defined at compile-time or runtime). We created a VO at runtime so we could base it's result set on another VO.
    See "Ways to Add a View Object Instance to the Data Model at Runtime" topic in JDev help (we're using 10.1.2, but there's a <jbo:CreateViewObject> tag going back to at least 9.0.3.3); I located using JDev's Help's text search for createviewobject.
    In our case, because the two queries were related (subset), we obtained the where clause from the VO that we defined at compile-time and whose where clause is being set at run time by values passed in from an HTML query form. We then applied that where clause to the dynamically created VO to get the desired subset.
    Hope that gives you a starting place and helps.

Maybe you are looking for