Configuring Database connection at runtime

Hi,
I am new to JDBC and urgently needs ur help.
What I want is to provide the URL (Connection String and DB info) in a config file and read that in the code. Also I should be able to change the DB location and connection string at runtime so that the next time the code executes, it takes the new connection string. I heard something about MBeans, can anyone help me in this.
Thanks in advance
Pankaj
PS: I might use JBoss or Tomcat.

Thanks for the reply..
Yes, but how to do it using MBean? Is Mbean the only solution available or there are some better approaches?
regards
Pankaj

Similar Messages

  • Set password for database connection at runtime

    Hi there,
    is it possible to set the password and/or the user for the database connection at runtime.
    The use case is to read the values from a file and decrypt them, and the to establish the conenction. So that i don't habe to redeploy everything if there is a change.
    Thanks in advance.

    How exactly do i set these values for the datasource?
    Edited by: Alex on 15.02.2012 09:50
    €: JDeveloper 11.1.1.5.0
    The use case is, that there is a file with an encrypted password. This should be decrypted and then be used for the connection. So when this encrypted passowrd changes, i don't want to edit and deploay the app once again. Instead the new encrypted password should be decrypted via code an then be used.
    Edited by: Alex on 15.02.2012 10:00

  • Configuring database connection (metadata repository) from jsp

    anybody could help me to configuring database connection from portal schema from jsp page.
    i dont have idea.
    Thanks.

    Hi,
    You won't be able to access the DB connections used by iAS from the JSP. As these connections are managed by mod_plsql component in iAS.
    Thanks,
    Ved

  • Different database connections at runtime

    How can I change different database connections at runtime on the same Application Module ?
    I use BC4J as business layer and uiXml as presentation layer.

    Does anyone know how to do this?
    I need the same, but i couldn't find any documentation about it.
    Looking forward to hearing good news.....

  • Dynamic database connections at Runtime dbAdapter

    Hi
    I need to connect to a database defined a runtime in a BPEL process using the dbadapter. All the configuration parameters for making the connection are provided at runtime (connectionURL, User, Password) and i need a way to configure them in the dbAdapter make the connection and execute some SQLStatements.
    Until now we were testing with some bpelx Properties changing dynamically the name of the jndi (jca.jndi) that works fine, but we cant define a datasource for every database. We also tried with another set of properties for setting the connection at runtime (jca.mcf.ConnectionString, jca.mcf.Password,jca.mcf.UserName) unsuccessfully.
    Do you know a way to define connections parameters at runtime in dbAdapter? Is that possible with SOA version 11.1.1.6 ?
    If this is not possible what alternative do you suggest for making dynamic connections to a database.?
    Regards
    Sergio

    You can try using the function query-database and formulate the 4th parameter which is JDBC connect string at runtime.
    oraext:query-database()
    Returns a node-set by executing the sql-query against the specified database. The second parameter rowset indicates if the rows should be enclosed in a element. The third parameter row indicates if each row should be enclosed in a element. The fourth parameter datasource is either a JDBC connect string (jdbc:oracle:thin:USER-NAME/PASSWORD@HOST:PORT:SID) or a JNDI name for the database. Only Oracle Thin Driver is supported if JDBC connect string is used. Usage: oraext:query-database(sqlquery as string, rowset as boolean, row as boolean, datasource as string). Example: oraext:query-database('select last_name from employee where id=1234',false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL'.
    This does not require a database adapter .

  • How to configure database connectivity in OC4J App server.

    Hi,
    I am working on Oracle ESB flows. I have the flow inserting rows into database table using database connection that I have defined. I havent set up connection settings in OC4J EM console.
    I dont wonder when JDeveloper is inserting rows into tables, as connection is explicitely defined in JDeveloper.
    Now I login to EM enviroment and click on Home, click on Web Services tab, and when I use this flow as a Web Service end point and feed values through the form that it provided, it also works. But since I havent defined any connection properties in App Server explicitely, I wonder where is it getting connection properties(JNDI name) from.
    I want to configure some settings in Testing Environment and am kind of stuck at this point.
    Thanks,

    Hi.
    When you don't have JNDI configured, OC4J uses the design time connection defined in the Adapter's WSDL. Look for the following description in your Adapter WSDL:
    <!-- Your runtime connection is declared in
    J2EE_HOME/application-deployments/default/DbAdapter/oc4j-ra.xml
    These 'mcf' properties here are from your design time connection and
    save you from having to edit that file and restart the application server
    if your JNDI is missing.
    These 'mcf' properties are safe to remove.
    -->
    Now, for JNDI configuration, you can use the SOA Suite tutorial as a reference:
    http://download.oracle.com/docs/cd/B31017_01/core.1013/b28937/setting_up.htm#CIHBHEFC
    There you can find the steps to create a connection pool, data source, etc.
    Denis

  • ADF Database Connection at Runtime

    Hi,
    I have developed a ADF based Web Application, deploy the code into different appServers [connecting to Different Databases] but unable to connect to the Required Database at Runtime.
    I have the following in my dataSources.xml & web.xml which looks like this.
    dataSources.xml
    <managed-data-source connection-pool-name="AIAQueryConnectionPool" jndi-name="jdbc/AIAQueryDataSource" name="AIAQueryDataSource"/>
    <connection-pool name="AIAQueryConnectionPool">
    <connection-factory factory-class="oracle.jdbc.pool.OracleDataSource" user="aia" password="aia" url="jdbc:oracle:thin:@//occf09.techmahindra.com:1521/ftsit"/>
    </connection-pool>
    web.xml
    <resource-ref>
    <description>AIA data source connection for FastTelco</description>
    <res-ref-name>jdbc/AIAQueryDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    deployed the web Application "TestTransaction" and created ConnectionPool & DataSources for this Application "TestTransaction"
    when i run the Application i am unable to connect to the required Database/(s)
    Is that correct what i was doing ?
    BUT If i have the entry of that specific Database in ./model/common/bc4j.xcfg file i am able to Connect to the Database
    and if i remove the entry from ./model/common/bc4j.xcfg file, I am unable to Connect to the Database.
    Why is it so ??
    Can anybody give me the process / code to Connect to the Database in web based ADF Application at Runtime.
    or
    Pick up the Database Configuration Values from a Properties file and establish a Database Connection ??
    thanks in Advance...
    regards,
    anvv sharma

    Hi,
    I got it working today and not yes'day to the modifications suggested by arun...the only difference being i have stop / start the Application then it started with the working what i have done yes'day
    also thanks for shay....... it was useful link
    regards,
    anvv sharma

  • Sharepoint 2013 MP - Configuration Database connection failed

    Hi all!
    I run a WS2012 R2 with SCOM 2012R2. I'm trying to monitor Sharepoint 2013 Farm, with the Sharepoint 2013 MP. The Sharepoint farm and it's SQL server is on another domain, with two-way trust, and the agents are working on the Sharepoint and SQL servers.
    I use SQL aliases for Sharepoint DB's, so I've made an override to the connection string to make it connect to the correct database. 
    The override is working fine, I can see that SCOM is trying to connect to the SQL server, but I cannot seem to make SCOM use the correct Run As account on these configuration databases. Most of the Sharepoint MP seems to be working fine, with the farm admin
    account, but I don't know how I can force this override connectionString to use a specific user.
    WS2012R2 with SCOM2012R2 UR3
    Sharepoint 2013 Farm on WS2008R2 OS.
    MS SQL 2012 on WS2008R2.
    It uses the default SCOM monitoring account, instead of the Sharepoint RunAs account.
    Any suggestions?
    How do I make it use the correct Run As account?
    (This guy has the
    same problem)
    Thanks,
    Nikolaj

    I was looking at this issue not too long ago, and looked through the management pack xml, to see if there was a missing secure reference for DB connection monitors. I only glanced through the MP, but it looked to me as if the DB connection
    monitors references the same account as the other sharepoint monitors. (Yes, that full-blown farm admin account). Again I am not sure, but it seems the management pack has trouble using the referenced RunAs account in the connection strings and then, because
    the watcher node is setup default to run off the management server, it falls back to the management server action account.
    You mention, that you have a two-way trust between you management group and SPS SQL servers. You could then bring this to work by granting your management server action account public rights on your configuration and content DB’s. Not
    optimal, but it’s a workaround. For SPS 2013 this should work without changing the connection strings, as you would have to with SPS 2010.
    I know this is not solution you’re are looking for, but it just might be enough for you to get a step further. I don’t know of any solution, so far, to get the DB connections to use the SPS RunAs account.

  • Configure Database Connection to Weblogic 8.1 Connection Pool

    Hi,
    I've got an ADF BC web application which is working find for an embedded JDBC Oracle Database connection. It's Jdeveloper 10.1.2 deployed to Weblogic 8.1.
    Now I'm trying to change the Database connection so it can point to a weblogic connection pool through its JNDI name. The goal is to make .ear file transportable through different weblogic domains and databases, without recompile application.
    I've been trying to configure an "OracleConnectionPoolDataSource" selecting "third party driver" in Database connection wizard, but Jdeveloper throws error: Java Cast Exception, and don't let continue. What else have to do?
    thanks.

    I did that, but WebLogic ignores whatever I configure in Services->JDB->Connection Pools and Data Sources. Even if I remove them the application keeps on running.
    Because the server only reads the connection defined from JDeveloper, which is configured in the connections.xml file placed inside the deployed .ear file.
    I need to change this behaviour, and configure connections.xml pointing to Weblogic Datasource.
    Thanks for your attention.

  • Configure database connection after deploy to Tomcat

    I developed a Web Application in JDeveloper. The database connection is defined in data-sources.xml for internal testing. When I deploy my application to Oracel Application Server, I can configure data sources in Oracle application server. My question is: when I deploy my application to Tomcat, I followed Tomcat document to create data source in Tomcat, but where is the java code to change to database connection in the application created in JDeveloper?

    Hi,
    Java EE data sources is a standard. If e.g. you reference jdbc/hrconn in your application (you don't mention what you use) then configuring this as a JNDI name for the data source in Tomcat should be enough to get it working
    Frank

  • Choose Database Connection at runtime?

    I have a few databases with the same structure but different content. In fact it are databases from the same application, but from different customers.
    But the choice of the database connection is part of the VC model.
    What will be the easiest way to use the same model with different databases?

    Hi
    I think that you should create seperate systems for each DB and then in your VC model use guard conditions to allow access to the specific data base.
    Jarrod Williams

  • Changing Database connection at runtime in CR2008

    Hi,
    I have a VS2008 application which is using CR2008 to generate pdf reports for the user. Problem is I am not able to change the database connection to any server other than the one that was used to create the report template.
    My environment has CR2008 SP2. I have tried reports with no paramter as well as the ones with parameters both dont seem to work.
    I have already tried a couple of things:
    a) report document refresh after loading it
    b) setting the database connection as
    this._crReport.DataSourceConnections[0].SetConnection(dbServerName, dbName, dbUserId, dbPwd);
    c) setting the database connection as
    tbls = this._crReport.Database.Tables;
                    bool test = false;
                    foreach (Table tbl in tbls)
                        tblLogonInfo = tbl.LogOnInfo;
                        tblLogonInfo.ConnectionInfo = connInfo;
                        tbl.ApplyLogOnInfo(tblLogonInfo);
                        test = tbl.TestConnectivity(); ** note this alwys return a true for the changed database server
    I have read a couple of thread but none has worked for me...Is this a known issue with CR2008?
    Thanks
    Kajal

    Hi Kajal,
    I am assuming that you are not changing the schema of the report at any point of time. I would suggest you to try pointing to the other database through designer to make sure that you can hit the database and the schema is correct. You can also create a udl file to check the database connectivity.
    Then just for testing purpose you can try the following code:
    ReportDocument reportDoc = new ReportDocument();
    reportDoc.Load("path of the report");
    reportDoc.SetDatbaseLocation("uid","pwd","Servername","tablename");
    reportDoc.SetParameterValues("Parameter-Name","values");
    CrystalReportViewer.ReportSoure=reportDoc;
    Does that help?
    Thanks.

  • Changing database connection at runtime

    Hi All,
    I have multiple screens based from different database instances. How can I make a single menu screen which will allow log in for another database connection? I tried using the LOGIN_SCREEN built in but it does not change the connection once you are already connected to one database.

    If you want to change connections, you first have to logout. Besides the logon_screen builtin does not change the connection, but it only sets several application properties.
    In the Forms Help there is an example how to use the logon_screen. It basically comes to the next pl/sql code:
    declare
    MyUsername VARCHAR2(40);
    MyPassword VARCHAR2(40);
    MyConnect VARCHAR2(40);
    begin
    logon_screen;
    MyUsername := Get_Application_Property(USERNAME);
    MyPassword := Get_Application_Property(PASSWORD);
    MyConnect := Get_Application_Property(CONNECT_STRING);
    logout;
    if MyConnect is not null then
    logon(MyUsername,MyPassword&#0124; &#0124;'@'&#0124; &#0124;MyConnect);
    else
    logon(MyUsername,MyPassword);
    end if;
    end;
    null

  • How TO use configurable Database connection with ADF BC

    I have developed a simple JSF/ ADF BC web application that connects to a database and read/display data from the db tables. I have successfully deployed the application to Tomcat 5.5.17. However, now i need to change the database the application is connecting to. My question is How can I change the Database connection without having to change the application modules or rebuild the war file ??? In other words, is there a specific file (xml) where the database connection can be changed?

    If you set up the application with a data source (I am not sure if this is possible using another app server, I use OC4J), then you would just change it there. However if you created a database connection in the JDEV and pointed your data model to that, then you will have to change and rebuild.
    You might be able to edit the xml file that contains the setttings, I am not sure my CM guys dont allow this, all of our changes have to go through our code repository.

  • Allow users to change database connection at runtime

    Folks,
    CR 12.2.0.290
    BOE 12.1.0
    I develop CR on desktop and then save to the BOE repository.  Users need the ability to point the report to a different Oracle schema.  Tables and elements are the same, just the data is stored via streams so that each location has its own reporting schema.  So one (16 total) report needs to run against multiple schemas based on which origin the user is trying to report against; one at a time.  Other than having a set of reports for each site, how can I allow the users to select the schema to run against at runtime?
    Thanx
    Mike

    When you schedule a report with InfoView, there is a Database option where an ODBC connection, user and password can be specified.  Can this be used?  (I'm not familiar enough with Oracle to know for sure...  Also, this option doesn't show if the report uses Business Views.)
    HTH,
    Carl

Maybe you are looking for