Dynamically set database url using tomcat jndi

By using Tomcat JNDI, database url information needs to be hardcoded in server.xml file according to the documentation. Is there a way to change the URL information in the code dynamically if necessary?
And also we need multiple connection pools and the connection information about those pools are only known during run time. So the TOMCAT JNDI is still the right way to go???
By the way, does anybody ever use tomcat DBCP package to get datasource and set url dynamically?
Thanks in advance.

By using Tomcat JNDI, database url information needs
to be hardcoded in server.xml file according to the
documentation. Is there a way to change the URL
information in the code dynamically if necessary?
Not that I know of.
And also we need multiple connection pools and the
connection information about those pools are only
known during run time. So the TOMCAT JNDI is still the
right way to go???
I think so. Since it's just a JDNI lookup, perhaps you can set up multiple data sources and decide on the lookup name at the last minute, depending on circumstances. That might work. I haven't tried it myself. - MOD
By the way, does anybody ever use tomcat DBCP package
to get datasource and set url dynamically?
Thanks in advance.

Similar Messages

  • Dynamic Setting of URL in Proxy for binary content in OSB

    I have three external links (to three different images) and external applications change them quite frequently.
    I want to build a proxy service where I should get the dynamic URL as parameter and this proxy should hit that URL to get the images. This proxy service should return these images as binary content.
    So this proxy service will be a routing service for different images coming from external web applications. I would like to know how can I get the content from a dynamic URL (not a fixed one)?
    I cannot use business service because I have to set the URL at run time.
    I will appreciate a prompt response.
    Thanks

    Use BS and in the request action use a Routing Options action http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/ui_ref.htm#i1290930
    Routing option allows you to change the URI of BS as per your runtime need.
    Manoj

  • Creating A File Resource Using Tomcat JNDI

    Hi guys,
    My problem is that I am creating a web service and I cannot get to a properties file without creating an absolute reference to that file. If I was creating a servlet I would simple use getServletContext() method to get a relative reference to it. However since it is an axis web service i have to deploy my applications in the WEB-INF/services directory, and because it does not interact with the axis servlet I cannot use getServletContext(). So i thought I could create a JNDI file resource reference in the tomcatHome/conf/context.xml file, similar to how I created a JNDI connection pool. The resouce definition looks like this;
    <Resource name="resource/dialogueEngineConfig" auth="Container"
                      type="java.io.File"
                      url="file:/Applications/apache-tomcat-5.5.1/webapps/axis2/META-INF/DialogueEngine.properties">
    </Resource>now I tried to access the resource in my code like this;
    // Obtain our environment naming
    Context envCtx = (Context) new InitialContext().lookup("java:comp/env");
    // Look up our file
    File  f = (File) envCtx.lookup("resource/dialogueEngineConfig");However I get a NamingException; 'Cannot create resource instance'
    I don't understand why I cant create a file resource in JNDI, it seems like a simple enough thing to do. Am I doing something wrong or missing something? Any help would be greatly appreciated.
    Thanks

    Hello xalien,
    I have the same problem. I need to access external xml config file via JNDI from my servlet, running on Tomcat 5.0.28. Have you manage to define an URL resource? If so, please provide an example how to do it. Many thanx.

  • How to use tomcat JNDI  resource in eclipse

    hi all, In my project i am using JSF,Tomcat,eclipse... i am planing to implement annotaions as part of my application
    I want to use Jndi resource as part of my project by using java annotaions
    for this i configured my server.xml in tomcat as
    <Context docBase="ALWREPORTSNEW" path="/ALWREPORTSNEW"
    reloadable="true"
    source="org.eclipse.jst.jee.server:ALWREPORTSNEW" >
    <Resource auth="Container"
    driverClassName="com.mysql.jdbc.Driver" maxActive="10000"
    maxIdle="3000" maxWait="10000" name="jdbc/enrollmentschema"
    password="adminadmin" removeAbandoned="true"
    removeAbandonedTimeout="300" type="javax.sql.DataSource"
    url="jdbc:mysql://localhost:3306/enrollment_schema_old"
    username="root" />
    </Context>And i configured web.xml as
    <resource-ref>
    <description>Enrollment Schema Connection pooling</description>
    <res-ref-name>jdbc/enrollmentschema</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>And some where in my project i am using annotaion as follows. i am getting NULL when trying access that annotaion .
    @Resource(name = "jdbc/mobileEnrollProd") DataSource mobileds;
    @Resource(name = "jdbc/enrollmentschema")
    private DataSource enrollds;
    public String UploadBankWise() {
    System.out.println("--------- ds "+enrollds);// *i am getting NULL*
    }but same code working with Glassfish and net benas..
    can any body hint me where i did mistake
    thanks in advance

    Go to Window-Preferences-Java-Debug-Step Filtering. When the dialog opens, press F1 for help. Good luck!

  • Dynamically loading the url of a web reference object in C#

    Hi,
    We have a number of assemblies (C# - VS 2010) that access third party web services via SOAP.  The url to access the site is part of the web reference object.
    We have need to be able to change the url used to access the service at run runtime when conditions require.
    What would the be the best practice of dynamically setting the url to be used at run time?
    Thanks in advance.
    SanDegan99

    You could specify the URLs as keys in the application configuration file (App.config or web.config) of the main application:
    https://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/aa374182(v=vs.85).aspx
    App.config:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <appSettings>
    <add key="url1" value="http://www.url.com/test.asmx"/>
    </appSettings>
    </configuration>
    You can then retrieve these values using the ConfigurationManager class in any assembly that is referenced from the main application like this (add a reference to System.Configuration.dll):
    string url = System.Configuration.ConfigurationManager.AppSettings["url1"].ToString();
    You can change the values of the keys in the application configuration file without having to recompile the application.
    The other option is to specify the URLs in a database or some other persistent storage from which you read at runtime but configuration files are generally used to store these kind of variable application settings.
    Please remember to mark helpful posts as answer to close your threads and remember that any new question you may have should be asked in a new thread of its own.

  • Dynamic Web Service URL

    I'm using a .Net based web service to fetch data. The exported XCelsius will be deployed on the customer's environment along with the web service. In that case, the SWF file should connect to web service deployed on my customer site. But, it looks for the hard coded path of the web service. In XCelsius designer, there is no option to pick the web service URL from a cell, as available in the "XML data" button. Is there any other way to pass on the Web Service URL dynamically to the SWF file. Please note, I may use more that one web service connectors in my SWF file.

    With regards to the Web Service Connector in CX, you can dynamically set the URL/end point path of the Web Service if you have installed the latest hotfix of CX:
    http://support.businessobjects.com/communityCS/FilesAndUpdates/crystal_xcelsius_4.5_hotfix.zip.asp
    After, you will see in the properties of the Web Service Connector by tying it to a cell in the speadsheet.

  • Error Connecting to database URL jdbc:oracle:oci:@rmsdbtst as user rms13 java.lang.Exception:UnsatisfiedLinkError encountered when using the Oracle driver

    Trying to Install RMS application 13.2.2 and I get past the pre-installation checks and when I get to the Data Source details and enter the data source details with the check box checked to validate the schema/Test Data Source I get the following error:
    Error Connecting to database URL jdbc:oracle:oci:@rmsdbtst as user rms13 java.lang.Exception:UnsatisfiedLinkError encountered when using the Oracle driver. Please check that the library path is set up properly or switch to the JDBC thin client oracle/jdbc/driver/T2CConnection.getLibraryVersioNumber()
    Checks performed:
    RMS Application code location and directory contents:
    [oracle@test-rms-app application]$ pwd
    /binary_files/STAGING_DIR/rms/application
    [oracle@test-rms-app application]$ ls -ltr
    total 144
    -rw-r--r-- 1 oracle oinstall   272 Dec 7  2010 version.properties
    -rw-r--r-- 1 oracle oinstall   405 Jan 16 2011 expected-object-counts.properties
    -rw-r--r-- 1 oracle oinstall   892 May 13 2011 ant.install.properties.sample
    -rw-r--r-- 1 oracle oinstall 64004 Jun  6  2011 build.xml
    drwxr-xr-x 9 oracle oinstall  4096 Jun 16 2011 rms13
    drwxr-xr-x 3 oracle oinstall  4096 Jun 16 2011 installer-resources
    drwxr-xr-x 3 oracle oinstall  4096 Jun 16 2011 antinstall
    drwxr-xr-x 2 oracle oinstall  4096 Jun 16 2011 ant-ext
    drwxr-xr-x 5 oracle oinstall  4096 Jun 16 2011 ant
    -rw-r--r-- 1 oracle oinstall 11324 Dec 18 09:18 antinstall-config.xml.ORIG
    -rwxr-xr-x 1 oracle oinstall  4249 Dec 18 10:01 install.sh
    drwxr-xr-x 4 oracle oinstall  4096 Dec 18 10:06 common
    -rw-r--r-- 1 oracle oinstall 16244 Dec 19 10:37 antinstall-config.xml
    -rw-r--r-- 1 oracle oinstall   689 Dec 19 10:37 ant.install.log
    [oracle@test-rms-app application]$
    Application installation:
    [oracle@test-rms-app application]$ ./install.sh
    THIS IS the driver directory
    Verified $ORACLE_SID.
    Verified SQL*Plus exists.
    Verified write permissions.
    Verified formsweb.cfg read permissions.
    Verified Registry.dat read permissions.
    Verified Java version 1.4.2.x or greater. Java version - 1.6.0
    Verified Tk2Motif.rgb settings.
    Verified frmcmp_batch.sh status.
    WARNING: Oracle Enterprise Linux not detected.  Some components may not install properly.
    Verified $DISPLAY - 172.16.129.82:0.0.
    This installer will ask for your "My Oracle Support" credentials.
    Preparing installer. This may take a few moments.
    Your internet connection type is: NONE
    Integrating My Oracle Support into the product installer workflow...
         [move] Moving 1 file to /binary_files/STAGING_DIR/rms/application
    Installer preparation complete.
    MW_HOME=/u01/app/oracle/Middleware/NewMiddleware1034
    ORACLE_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/as_1
    ORACLE_INSTANCE=/u01/app/oracle/Middleware/NewMiddleware1034/asinst_1
    DOMAIN_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/user_projects/domains/rmsClassDomain
    WLS_INSTANCE=WLS_FORMS
    ORACLE_SID=rmsdbtst
    JAVA_HOME=/u01/app/oracle/jrockit-jdk1.6.0_45-R28.2.7-4.1.0
    Launching installer...
    To make sure I have connectivity from the app server to the database (on a database server) here are the steps followed:
    [oracle@test-rms-app application]$ tnsping rmsdbtst
    TNS Ping Utility for Linux: Version 11.1.0.7.0 - Production on 19-DEC-2013 10:41:40
    Copyright (c) 1997, 2008, Oracle.  All rights reserved.
    Used parameter files:
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test-rms-db.vonmaur.vmc)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = rmsdbtst)))
    OK (0 msec)
    [oracle@test-rms-app application]$
    [oracle@test-rms-app application]$ sqlplus rms13@rmsdbtst
    SQL*Plus: Release 11.1.0.7.0 - Production on Thu Dec 19 10:46:18 2013
    Copyright (c) 1982, 2008, Oracle.  All rights reserved.
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@test-rms-app application]$
    [oracle@test-rms-app application]$ ping test-rms-db
    PING test-rms-db.vonmaur.vmc (192.168.1.140) 56(84) bytes of data.
    64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=1 ttl=64 time=0.599 ms
    64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=2 ttl=64 time=0.168 ms
    64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=3 ttl=64 time=0.132 ms
    64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=4 ttl=64 time=0.158 ms
    64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=5 ttl=64 time=0.135 ms
    --- test-rms-db.vonmaur.vmc ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4001ms
    rtt min/avg/max/mdev = 0.132/0.238/0.599/0.181 ms
    [oracle@test-rms-app application]$
    [oracle@test-rms-app application]$ uname -a
    Linux test-rms-app.vonmaur.vmc 2.6.18-128.el5 #1 SMP Wed Jan 21 08:45:05 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
    [oracle@test-rms-app application]$
    [oracle@test-rms-app application]$ cat /etc/*-release
    Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)
    Red Hat Enterprise Linux Server release 5.3 (Tikanga)
    [oracle@test-rms-app application]$
    The database is created and all the batch file scripts have been successfully deployed.  Now working on the application server.  The  Weblogic server is installed and 11g forms and reports are installed successfully.
    Any help would be helpful.
    Thanks,
    Ram.

    Please check MOS Notes:
    FAQ: RWMS 13.2 Installation and Configuration (Doc ID 1307639.1)

  • Set Database path dynamically

    Post Author: santoshk
    CA Forum: Data Connectivity and SQL
    Hi All,
    I am using asp dot net 2.0 With craystalreport and C#.
    While crating report i am giving server,databsename and all the credentials as per my computer. My crystal reports work fine.
    But problem occurs when i try to run the crystalreport other than my machine. It always ask for databse password,server name.
    Is it possible to set database path dynamically for sql server.
    Please help me.
    If anybody give me the detail procedure in c# ,it will be appriciated.
    Waiting for reply.
    thanks in advance

    Post Author: DLO34
    CA Forum: Data Connectivity and SQL
    I recently came across this issue. I was able to get a
    Crystal Report to work dynamically under limited conditions. If you create a
    direct connect report for an Oracle database then, it will only connect to
    other Oracle databases. The same is true for MSSQL and Sybase. When using the
    CRPE or RDC API you must set the logon credentials for the report as a whole
    and for each object within the report. Below is a snippet of my code C++ using
    the RDC API. This should help get you going.
    IReportPtr pReport;
    IDatabaseTablesPtr pTables
    IDatabaseTablePtr  pTable
    Int num_tables, i;
    // set for whole report
    pReport->Database->LogOnServer(DB_DLL, DB_Server_Name, DB_Name,
    DB_User_Name, DB_Password);
    pTables    = pReport->Database->GetTables();
    num_tables = pReport->Database->Tables->Count;
    for (i = 1; i <= num_tables; i++)
        pTable = pTables->GetItem(i);
        pTable->SetLogOnInfo(DB_DLL, DB_Server_Name, DB_Name,
    DB_User_Name, DB_Password);   // set for each object

  • Set Destination URL Dynamically

    Hi,
    I have to set Destination URL Dynamically.
    return.setDestination("OA.jsp?page=/oracle/apps/pa/project/webui/HomePG");
    if(pageContext.getParameter("Return")!=null)
    But when i clk on btn Im nt able to navigate to home page.
    If i use pagecontext.SetforwardURL() for Return button The page URL cant be changed it remains the same page url instead of Home page URL, but page is navigating to Home page.
    Plz help me...
    Thanks
    Nani:)

    Hi,
    For the simple button also you can check in processformRequest if it has been clicked or not..
    This way...
    OAButtonBean button = (OAButtonBean)createWebBean(pageContext,OAWebBeanConstants.BUTTON_BEAN, null, "BUTTON");
    button.setText("Test Button");
    btn.setFireActionForSubmit("navigate",null,null,false,false);
    webBean.addIndexedChild(button);
    then when you click on this button then an event will occur which you can check in processformrequest
    String event = pageContext.getParameter("event");
    if("navigate".equals(event))
    navigate to the desired page using pageContext.setForwardurl()
    Thanks,
    Gaurav

  • How can I set time-out while accessing a url using URL object?

    Hi
    I'm trying to get the content of a URL using the following code. How can I set timeout
    (example, 10 secs), if the webserver takes a while to respond.?
    BufferedReader inbuf=null;
    URL url=null;
    try {      
         String urlString="http://host-machine/sms/index.jsp";          
         url = new URL(urlString);
         inbuf = new BufferedReader(new InputStreamReader(url.openStream()));
         String inputLine;
         String LongString="";
    while ( (inputLine=inbuf.readLine()) != null)
              LongString=LongString+inputLine;
              retString=LongString;          
              inbuf.close();
         catch (Exception e) {System.out.println(e)}
    Thanks a lot for your kind help
    Regards
    Kandasamy

    If you're using Java 5, see this thread (reply 10)
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=576157

  • Can we set the dynamic data source when using getReportParameters() ?

    Hello!
    I have a report where one of its parameters refers to a list of values (LOVs). This list of values is an SQL Query type. When the data source used in the report is defined in the BI Publisher server, I'm able to get the report parameters using the getReportParameters() function in my application. However, if the data source is not defined the function throws an exception, which is understandable.
    I decided to dynamically set the data source so that even if the data source used by the report is not defined in the BI Publisher server, it still will be able to get the LOVs for the parameter. I tried setting the JDBCDataSource of the dynamicDataSource for the ReportRequest object that I passed to the getReportParameters() function. Please see the sample code below:
    reportRequest.dynamicDataSource = new BIP10.BIPDataSource();
    reportRequest.dynamicDataSource.JDBCDataSource = new BIP10.JDBCDataSource();
    setReportDataSource(reportRequest.dynamicDataSource.JDBCDataSource, connectstr, jdbc, dc); //function to set the values for JDBCDataSource object
    reportParams = webrs.getReportParameters(reportRequest, uid, pwd); //call the getReportParameters
    I was expecting this to work as this is what I did to dynamically set the data source before calling the runReport function. So, my question is -- can we set the dynamic data source when using getReportParameters() ? I tried this both in versions 10g and 11g. It does not seem to work on both versions.
    Regards,
    Stephanie

    report_id column of apex_application_page_ir_rpt can help us uniquely identify each saved report.
    We can assign this report_id value to a page item and this page item can be put in the Report ID Item text box of the Advanced section of the Report Attributes page of the IR.
    This should load the saved report identified by report_id and you can get rid of javascript
    Regards,
    Vishal
    http://obiee-oracledb.blogspot.com
    http://www.packtpub.com/oracle-apex-4-2-reporting/book
    Kindly mark the reply as helpful/correct if it solves your problem

  • Problem setting Unicode (utf-8) in http header using tomcat

    Hi:
    I am trying to set a file name in utf-8 to http header using the following code:
    response.setContentType("text/html; charset=utf-8");
    response.setHeader("Content-disposition", "attachment; filename=&#35299;&#27770;.zip");
    // I actually has file name in utf-8 here to set to the header, and I know that the name is correctly
    // and I also looked into the response object MimeHeaders object and saw the head is correctly there
    then write the content of zip file using ServletOutputStream.
    The problem I have is that the file name is not displayed correctly when prompted to save or open in the pop up window next. I found out using Fiddler that the request header is wrong:
    Content-disposition: attachment; filename=&#65533;zn&#65533;�.zip
    I am using Tomcat 5.0.28. Any idea how to get this working?
    Thanks in advance!

    You are setting the charset for the content to be UTF-8. (That is why the method is called setContentType.) But HTTP headers are not part of the content and so that has no effect on the header.
    The original specification for HTTP only allowed US-ASCII characters in headers. It is possible that more recent versions have features that allow for non-ASCII header data, but I don't know if that is the case or how you would use those features if they exist.

  • How to dynamically configure JPA setting at runtime using java code?

    Hi,
    I am new to EJB 3.0 and JPA. I am trying to help my company to deploy the use of JPA in EJB3.0. Currently, i am trying out with OpenJPA in IBM Webshpere Application Server 7.0. We have four different WAS servers running for testing, system integration testing, user testing and production respectively, and in each region, the configurations for data source, JDBC username and password, schema, etc are different. So i think i would need to configure the JPA setting during runtime using Java code that determines which is the environment. And apparently i am stuck with the limited knowledge i have.
    1) I understand that i could override the JDBC in the persistence xml by creating entity manager using entity manager factory. But is it possible that i do similar thing by using inejction of persistence context on entity manager to obtain a container managed entity manager?
    2) Alternatively, it is possible to create multiple persistence unit in the XML and inject different PU to the entity manager, am i right? But how to inject dynamically since @PersistenceContext(unitName="xxx") only accepts constant declaration.
    3) Is it possible that the JDBC username and password are read from properties file?
    Thanks for your help in advance!

    Hi
    Thanks for the reply.
    Are you saying that i have to configure the data source authentication to the backend DB2 using the JAAS-J2C? Correct me if i am mistaken. I guess i am unable to do so as the application server setup only contains one data source, and the server hosted a number of applications. Every applications has their own JDBC username and password supply to the data source (the ID supplied at the DB2 side will decide which resource can access) and thus, i have to supply the username and password at runtime. Talked to the server guy and seems that it is not feasible to have seperate datasource for each applications as considered to the volume of applications hosted inside the server.
    Any suggestion?

  • How to use dynamic set in calculated measure

    Hi, 
    I have this calculated measure in my cube:
    member [Measures].[Estimate]
    as 
    iif(
    isleaf([Calendar].[By Year - Quarter - Month].currentmember),
    iif(
    1=1, // Simplified for examples sake
    [Measures].[Actual],
    [Measures].[Budget]
    sum(
    [Calendar].[By Year - Quarter - Month].currentmember.children,
    [Measures].[Estimate]
    It works fine, however when the user filters on the calendar hierarchy, the totals does not seem to react. As far as I can read, this is related the use of sub cubes when filtering in Excel, and this can be fixed by using a dynamic set, but how? I am unsure
    how one would use it with this measure.
    Thanks in advance

    This used to be a problem with Excel 2003 though I thought it had been fixed with the more recent versions. I've only seen this issue when using named sets in a calculated measure and not when the set is defined within the calculated measure and that's corrected
    by declaring EXISTING before the named set reference as below.
    SET [Member Descendants] AS
    [Calendar].[By Year - Quarter - Month].CurrentMember.CHILDREN
    MEMBER [Measures].[Estimate] AS
    IIF(
    ISLEAF([Calendar].[By Year - Quarter - Month].currentmember),
    IIF(
    1=1, // Simplified for examples sake
    [Measures].[Actual],
    [Measures].[Budget]
    SUM(
    EXISTING [Member Descendants],
    [Measures].[Estimate]
    EXISTING will force the named set to be evaluated with the context of each cell evaluation.
    Martin Mason Wordpress Blog

  • Dynamically building a Database URL

    Hi all,
    I'd like to create a database URL at runtime without knowing which database driver I'll have. I'd love some advice on how I should "discover" the sub-protocol for a selected driver, and the exact format for the url string. Wouldn't it be great if the programmer could supply connection properties like server, port, database, schema, and get a properly formatted url? Does this capability exist anywhere?
    Thanks,
    Mac

    Wouldn't it be great if the programmer could
    supply connection properties like server, port,
    database, schema, and get a properly formatted url?Yes, but it isn't going to happen.
    The information that appears after the driver name can take any form. And some databases don't even have 'server' much less 'port'. And many databases don't have 'schema' although many have something called 'database' it can take different forms. And there are many other parameter types that can appear in the connection string and those are much more exotic.

Maybe you are looking for