Dynamic datasources??

I made a Datasource to an SqlServer database, and I succesfully programmed a CMP Bean which gets it's data from that db.
The datasource is defined in the data-source-name tag of the persistent.xml file.
But I have several test databases. How do I manage that? Is it necessary to make several persistent.xml files? Or can I provide the required datasource from the client application somehow???

Hi Jan,
persistent.xml is one of so called <a href="http://help.sap.com/saphelp_nw04/helpdata/en/3f/40bd71ae1a9b45a0f3eb6ff0a27aae/frameset.htm">Deployment Descriptors</a>, so they are used on <i>deployment</i> phase for database validation, O/R mapping etc. The only EJB properties that you can change on runtime are listed there <a href="http://help.sap.com/saphelp_nw04/helpdata/en/07/12104b7031014fbd4273aafaa5dcf3/frameset.htm">Runtime Changes in Deployed Enterprise Beans</a>.
Best regards, Maksim Rashchynski.

Similar Messages

  • Dynamic datasource query in Content Presenter

    I have a Documents region with a custom Content Presenter template.
    I would like to use a dynamic datasource query with this, which makes use of the currently logged in user and the user's role.
    The task flow parameters look like this now:
    <parameters>
    <parameter id="taskFlowInstId"
    value="${'afd37bc3-bd2e-4e97-b838-74c975529633'}"/>
    <parameter id="datasourceType" value="${'dsTypeQueryExpression'}"/>
    <parameter id="datasource"
    value="${'SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:dDocType = \'Dagbericht\''}"/>
    <parameter id="templateCategory" value="${''}"/>
    <parameter id="templateView" value="${'dagberichten.list.template'}"/>
    <parameter id="maxResults" value="${'3'}"/>
    </parameters>
    What are my options to achieve this?

    Jaap,
    You can use expression language in that query to make it dynamic.
    You could either build the full query from a managed bean or just some parameters.
    here's how you can do it when building the query from a MB:
    This should be the method in your bean:
    public String getQuery(){
      String user = ADFContext.getCurrent().getSecurityContext().getUserName();
      String query = "SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:dDocType = 'Dagbericht' and ora:p:dCreatedBy = '" + user + "'";
      return query;
    }Your datasource parameter should be something like this:
    <parameter id="datasource" value="#{yourBean.query}"/>note: the "and ora:p:dCreatedBy..." might not be correct but it shows how you can dynamicly build the query.
    Hope this helps.

  • 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

  • Using dynamic DataSources with WL 6.1

    Hi All,
    Here is an example of how to create, use and delete
    JDBC DataSources dynamically using JMX and WL 6.1.
    Regards,
    Slava Imeshev
    [DynamicDataSource.java]

    Hi Srinivas,
    "Srinivas Chennamaraja" <[email protected]> wrote in message news:[email protected]..
    Hi Slava!
    If I just have Weblogic 6.1 (as an Admin Server), Would I be able to create
    Dynamic DataSources?. The documentation says that you can't create aYes, you'll be able to create a datasource.
    dynamic Datasource in Weblogic. what is JMX?. I would appreciate if youThis is a brand-new feature.
    describe in detail?.Look here for JMX http://java.sun.com/products/JavaManagement/
    >
    can I create a any type of Datasources dynamically (like TXDatasources...).Yes, you can. Look at our doc site for details.
    http://e-docs.bea.com/wls/docs61/javadocs/weblogic/management/configuration/JDBCTxDataSourceMBean.html
    >
    thanks,
    Srini
    "Slava Imeshev" <[email protected]> wrote in message
    news:3b783560$[email protected]..
    Hi All,
    Here is an example of how to create, use and delete
    JDBC DataSources dynamically using JMX and WL 6.1.
    Regards,
    Slava Imeshev
    [att1.html]

  • Dynamic datasource in ColdFusion via LCDS ES

    Hi All,
    I'm hitting a wall on a requirement for a Flex application which utilizes the LCDS version included with ColdFusion.
    I have the project setup to use DAO's, Assemblers and ValueObject (cfc's) which I call from Flex via DataService implmentation and the fill(), getItem(), etc... methods.
    I need to setup my ColdFusion layer to access multiple datasources from the same Flex application.  However, because of the way LCDS gets called from Flex, it doesn't seem that Application or Session variables in ColdFusion persist when I set them.  I was thinking I could just have the HTML (cfm) wrapper page for my Flex application set that, but it is not recognized when I go to make a fill or get call against the assembler.
    I thought about passing the datasource as a parameter each time a call is made, but while that would work when I initiate fill and get methods, the sync methods are "invisible" and I wouldn't be able to append an argument to them.
    So my issue is... how do I go about having ColdFusion read a dynamic variable to define it's datasource?
    Thanks in advance for the help.
    Brendan

    Hi Ian,
    Thanks very much for the reply.  While it doesn't provide the solution, you definitely hit the nail on the head as to the problem :-) 
    Ben Forta provides and explanation (and solution) for what you describe here: http://www.forta.com/blog/index.cfm/2007/11/15/Flex-And-ColdFusion-Session-Variables  However, I tried his method out, and it didn't work for me... perhaps the difference between HTTP RemoteObject access, and RTMP DataServices.
    You know... I tried it out a while ago before I had a better understanding of the problem... perhaps I'll try again :-)  Will post results of latest attempt...
    Thanks again,
    Brendan

  • Help with dynamic datasource and record selection

                                                                                                                                                                                                                                                                                     <span>Hi, I&#39;m having some difficulty with part of an application I&#39;m trying to build, but here&#39;s some background first.<br /> <br /> I am a student at the University of Maryland, and I&#39;m writing an application for one of the departments here at the university.  It is sort of a front-end for an access database with a lot of extra functionality.  This includes reports.  First of all, the user can change the databse that the application uses, so I store that in an appsetting.  For this reason, I have to tell the report what database to use at runtime rather than using the database expert.  I am building a sort of report wizard in which the user selects certain values, and based upon those values, the SQL statement that the report gets data from changes.  So almost everything about the report&#39;s data is dynamic and will be determined at runtime.  <br /> <br /> So for example if the user chooses an officer report by chapter names, I do this (chapters is a comma delimited string):<br /> <br /><span style="font-weight: bold"> string sel = "SELECT * FROM [Undergrad Leadership] WHERE [Leadership Position] = &#39;" + txtPosition.Text + "&#39; AND [Chapter Name] IN (" + chapters + ");";</span><br /> <br /> The part I am lost on, is how to actually interface with crystal reports.  In the following code, conn is an OleDbConnection to the correct database, rep is the ReportDocument, and view is a CrystalReportsViewer.<br /> <br /><span style="font-weight: bold"> rep.DataSourceConnections[0].SetConnection(conn.DataSource, conn.Database, false); <br /> rep.RecordSelectionFormula = sel;</span><br /><span style="font-weight: bold"> view.ReportSource = rep;</span><br /> <br /> When I try to load the report, I get the following error message:<br /> Error in formula <Record Selection>:  a number, currency amount, boolean, date, time, date-time, or string is expected here.<br /> <br /> Also, assuming this formula gets fixed, how do I actually get fields from this formula and datasource onto my report, since I can&#39;t do it at design time?  Thanks in advance for the help.<br /> <br /> -Jared<br />    </span>

    <p>RCAPI (Report Creation and Modification) calls are only available with Crystal Reports Server RAS SDKs.  This means that using the bundled version of Crystal Reports for Visual Studio will not allow you to place fields onto the report.  A free copy of Crystal Reports Server comes with a registered copy of Crystal Reports Developer.  My guess is that you don&#39;t have either of these products and that you are just using the product that came with Visual Studio.</p><p>All is not lost.  The first question is, do you really need to add the fields at runtime?  In many cases developers just want to have control of the data that gets sent to the report and they are ok with having the same fields display.</p><p>In your code you are changing the datasource which is fine, and you are assigning a Record selection formula which is also fine.  </p><p>The problem with the record selection is that it doesn&#39;t fit the syntax of the Report.  I would suggest printing out the value that you programatically get for the formula and insert it into the Crystal Report Designer.  You will probably get the same error there and gets some  hints as to why it doesn&#39;t work.</p><p>What I would suggest is creating a template report that already has the fields on the report and then change its datasource at runtime and add a RecordSelectionFormula.</p><p>Otherwise you will have to use RAS to be able to add fields at runtime. </p><p>Rob Horne<br /><a href="/blog/10">Rob&#39;s blog - http://diamond.businessobjects.com/blog/10</a></p>

  • 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.

  • Dynamic datasources and connnection pools cont...

    sorry.. i got an error when replying to the original message..
    Thanks for the quick response. I'm assuming this applies to datasources as well. So, there's not much WL overhead with creating hundreds datasources and connection pools up front?
    Ken

    Ken Yeung wrote:
    sorry.. i got an error when replying to the original message..
    Thanks for the quick response. I'm assuming this applies to datasources as well. So, there's not much WL overhead with creating hundreds datasources and connection pools up front?
    Kencorrect.

  • Dynamic Datasource

    Hi Big Minds,
    I want a solution for transparency of creating datasource & connection pool accross Application server.
    e.g. Let suppose i had a web interface in which user selects an application server, A database(or Tablespace0 some JDBC property and click on create datasource. Now this web interface connect to application server which is of that select type and running on specified IP & Port. Now at this time a simplified code should be executed and creates a datasource with connection pool , without opening any web console of application server.
    Now problem is that every Application server has its command line as well as web interface but no mangaement API, JBOSS and webloagic has some JMAPI such as JDBCDataSourceMBean etc... and require some startup clasees , but Oracle 10G have not such type of beans.
    How can I resolve this problem.
    My alternate email address is [email protected]
    Any kind of workaround may be helpfull.
    Thanks & regards
    Dinesh Parikh

    I understand what you mean I think.
    If I use different environments (e.g. different BI Publisher servers) I can use one logical name and in every environment it will mean something else.
    Hmm.
    I wanted to know wether it could be done on one BI Publisher server.
    Thanks
    If someone knows a solution for one server I am all ears.

  • CFsearch as datasource

    Is there a way to turn CFsearch results into a dynamic
    datasource that can be easily used with Spry datasets? I would like
    to return a CFsearch result into a Spry table, but am having a
    mental block on the possible solution. I've thought of creating a
    static XML page from search results, but that sounds clunky. Any
    ideas out there?
    Thanks,

    From the documentation it seems like you should be able to
    use <cfcollection action="list"> in conjunction with some
    code that converts a CF recordset into XML (I've seen some custom
    tags floating around that do that). You'll just have to make sure
    you format the XML in a way that will work with Spry (Spry doesn't
    play well with too many nested elements).

  • JPA using dynamic database connection

    Hello everybody.
    My current project requires JPA to use dynamic datasource connection. And I need to register the database connection implementation in JNDI. For the dynamic part, the idea is that if user A logs in, JPA should use A's id and pw to create a datasource connection. When user B logs in, JPA should use B's credentials to create a datasource connection instead. I poked around a bit in the forum and found out that DataNucleus supports Dynamic datasource for JPA.
    But, could any one tell me if JPA supports dynamic datasource connection out of the box? If it does, could you point me to some samples.
    Thanks!

    Hello,
    I am using an implementation of OpenJPA.
    I can now overwrite the database user id/password defined in a data source with Persistence.createEntityManagerFactory(name, props). However, the props (java.util.Map) needs openjpa.ConnectionUserName and openjpa.ConnectionPassword key/value pairs.
    My issue now is that the user authentication will be through LDAP, so I won't be able to know the password of any user ( therefore no value for openjpa.ConnectionPassword). I am wondering if there is any way that JPA can use LDAP for the data source authentication. I guess Datanucleus framework could probably do that, but is there any way other than using Datanucleus?
    Thank you.

  • Report Designer odbc connection string for data source using a parameter

    I am using stand alone report designer 3 for the present and have a question/problem regarding the odbc connection string for MySQL when setting up the data-source
    I need to be able to enter a parameter which is the database name i.e. BOE-201401 or say BOE-201312 etc  from a list of databases the user can choose from.
    at present the odbc connection string points to BOE-201402
    the connection string is at present  Dsn=Development Server for MYsql;description=MYSQL;server=ldndw01;database=BOE-201402;port=3306
    my parameter has the name BOE_DATABASE
    and in an expression it is  as such
    =Parameters!BOE_DATABASE.Value
    I want to point the datasource for the report to the parameter value before the user sees the report.

    Hi Leslie,
    Based on your description, we want to design a report with a dynamic DataSource connection string. There are the basic steps below for your reference:
    Create report with static database.
    Change data source to report parameter.
    Send new database connection string as a report parameter. 
    More detail information, please refer to the following blog: Dynamic Database in SSRS 2008.
    http://haseebmukhtar.wordpress.com/2011/11/09/dynamic-database-in-ssrs-2008/
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • How to use container's data source as mapviewer data source?

    Hi,
    I want to take advantage of connection pooling and hence was trying to create a mapviewer datasource from J2EE container.
    When I use the J2EE ds as the Mapviewer datasource in the Mapviewer admin page, it wouldn't work.
    Rest of the applications deployed on the OC4J container which makes use of the same J2EE ds works fine.
    I referred to the article below to configure the datasource(not the permanent stuff), but it didnt work.
    http://www.oracle.com/technology/products/mapviewer/htdocs/faq_1012/mvfaq_1012.html#oc4jds
    Any help is much appreciated.
    Cheers,
    Sumanth

    I am running mapviewer application with my dynamic datasource created out of JDBC URL. All the shipped-in demos and my own mapviewer application works fine with this.
    The trouble is when my application runs it creates too many database connections (my observation is a connection each for a theme).
    There are about 16 themes and the application opens up 16 connections (I have monitored the statements for each of these connections and they are for the individual themes). Although we could increase the max connections of our database, ideally we would like to make use of less connections.
    An efficient way of solving this would be to create the dynamic datasource out of J2EE data source rather than JDBC URL.
    So, when I define a dynamic datasource through the mapviewer admin page from an existing J2EE data source, it creates a datasource with JDBC URL as "thin:@:1521:" and schema user as "scott", both of which are incorrect. Referred to the article below to solve this but with no luck
    http://www.oracle.com/technology/products/mapviewer/htdocs/faq_1012/mvfaq_1012.html#oc4jds
    Sorry if I sound stupid with this elementary question. Would appreciate any help.
    Cheers,
    Sumanth

  • Stored Procedure Universe with Webi and Xcelcius

    Business Objects XI 3.0, Xcelcius 2008
    Created a stored procedure Universe on top of SQL Server 2005.  The stored procedure inserts a row into a table, and works fine when calling it from SQL Server server.  When I call it from Webi it wraps a transaction around the call and rolls it back after executing it.
    Are the new Stored Procedure Universes in 3.0 meant to be only "read only" and don't allow inserts/updates/deletes commands in the stored procedures they execute ? Seems a little short sighted if they are.
    Thanks,
    Keith
    Edited by: Keith Johnson on Aug 16, 2008 11:30 PM

    Keith,,
    absolutely with universe designer you can never use such like those procedures, you can not use insert or update statements on those procedure, it will give you errors.
    but in xcelsius, you can do it with another layer
    check this please
    xml data button
    http://resources.businessobjects.com/support/cx/samples/learning/downloads/ttv4-xml_data_button.pdf
    XCELSIUS DYNAMIC DATA SOURCE
    Dynamic datasources for Xcelsius
    good luck

  • JHeadstart & (Scalable Vector) Graphics - From the AMIS JHeadstart Cookbook

    A picture can tell more than a thousand words. Adding meaningful graphics to our web-application can enhance the visual attractiveness s well as the functional effectiveness. Simple, data-drive graphics such as progress indicators, status ‘traffic lights’, gauge and speedometer like indicators can all represent data-values in a explicit, obvious way. Charts such as line-graphs, bar-charts and pie-charts facilitate quick interpretation of multiple values and trends.
    Using SVG in JHeadstart Applications - Scalable Vector Graphics are a technology for describing graphics in a structured, XML-based definition that can be rendered in browsers using a (free) plugin. Because of their XML-foundation, SVG objects can be generated by XML/XSL-T Transformations from dynamic datasources. That in turn makes it quite straightforward to generate graphics that are data-driven: the overall layout of the graphic is defined in an XSLT file while the dynamic data is fed into the SVG generation process in an XML document.
    In this recipe, we look at the use of SVG technology together with the JHeadstart architecture for incorporating data-driven graphics in our web-application. See: http://www.amis.nl/technology/Cookbook/Recipe%20for%20GeneratingSVGObjects.htm
    The Dutch Oracle partner AMIS has a 10-person JHeadstart team, currently involved in 4 JHeadstart-projects in The Netherlands. Their experiences and ideas are compiled in the AMIS JHeadstart Cookbook that is published on the internetsite (http://www.amis.nl) for other JHeadstart developers to share.
    I hope the recipes are of use to you.
    best regards,
    Lucas Jellema

    As a result of reorganizing (and re-providing) our website, some of the URLs stopped working. I apologize for any inconvencience.
    The JHeadstart Cookbook can now be found at: http://www.amis.nl/files/technology/Cookbook/AMISJHeadstartCookbook.htm and the Recipe on Generating SVG is located at: http://www.amis.nl/files/technology/Cookbook/RecipeforGeneratingSVGObjects.htm.
    Note that the AMIS Demo Application (AMIS Library System) created along with our Cookbook is now shipped as part of JHeadstart 9.0.5.1 to demonstrate the use of Oracle Toplink. This will make it easier for you all to apply our recipes - since you have the ALS application already available when using JHeadstart 9.0.5.1.
    best regards,
    Lucas Jellema, AMIS JHeadstart team

Maybe you are looking for