Use ADF Default Database Connection

Hi All,
I am writing a class that requires to connect to the database and perform some functions. This class is invoked from a button. My challenge is, how can I use the current adf application database connection (jndi) instead of creating another class that returns a connection object?
Thank you.
Eric.

Are you using ADF BC in your application?
If so you can write an AM Service method that uses the current connection/transaction - and then use that method from your UI button.
http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/bcadvgen.htm#BABEIFAI
and then
http://blogs.oracle.com/shay/2010/07/am_service_method_-simpledem.html

Similar Messages

  • How to use Forms Default Database Connection in java class

    When a form based application is started, a connection is made with underlying database. This is the Default (Primay) Database Connection.
    The problem is I have some of my business logic implemented in a java class. In this class I have to make a another connection with the same database. What I want to do is to use the original Database Connection in the java class. In this I may avoid the overhead of reconnection.
    Could anyone pls guide me in this way...

    you can't share the forms connection. Sorry :(

  • Trying to get the default database connection

    I'm trying to use the default database connection that the application server has but when I call this method I get an error :
    Connection conn = (new oracle.jdbc.driver.OracleDriver()).defaultConnection();
    java.sql.SQLException: Invalid Oracle URL specified
    Do I have to do some setup? I don't want to hard code the connection URL in my code.
    Thanks,
    Merced

    Hi Avi,
    Thank you so much. I added the following and I was able to get the connection:
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("jdbc/DBConnection1CoreDS");
    Connection c = ds.getConnection();
    Currently I'm running it from JDeveloper and the data-source.xml gets generated automatically. How will it work when I deploy this application to the Oracle Application server? Do I have to update or copy data-source.xml? What does "jdbc/DBConnection1CoreDS" mean? I only know that in data-source.xml I have location="jdbc/DBConnection1CoreDS". I don't understand how Context is able to find this. I also deleted this entry from data-souce.xml but it got generated again. I don't understand that either.
    Your help is appreciated.
    Thanks,
    Merced

  • How to use the default database service name on creating procedure for data

    how to use the default database service name on creating procedure for datagaurd client failover ??? all oracle doc says create a new service as below and enable at DB startup. but our client is using/wanted database default service to connect from application on the datagaurd environment (rac to non rac setup).please help.
    Db name is = prod.
    exec DBMS_SERVICE.CREATE_SERVICE (service_name => 'prod',network_name =>'prod',failover_method => 'BASIC',failover_type => 'SELECT',failover_retries => 180,failover_delay => 1);
    says already the service available.
    CREATE OR REPLACE TRIGGER manage_dgservice after startup on database DECLARE role
    VARCHAR(30);BEGIN SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
    IF role = 'NO' THEN DBMS_SERVICE.START_SERVICE('prod');
    END IF;
    END;
    says trigger created, but during a swithover still the service is listeneing on listener.
    tns entry.
    prod =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (LOAD_BALANCE = YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod2)(PORT = 1521)) ---> primary db entry
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = proddr)(PORT = 1521)) --> DR DB entry
    (CONNECT_DATA =
    (SERVICE_NAME = prod)
    thanks in advance.
    Edited by: 854393 on Dec 29, 2012 11:52 AM

    Hello;
    So in the example below replace "ernie" with the alias you want the client to use.
    I can show you how I do it :
    First an entry need to be added to the client tnsnames.ora that uses a SERVICE_NAME instead of a SID.
    ernie =
    (DESCRIPTION =
        (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = Primary.host)(PORT = 1521))
           (ADDRESS = (PROTOCOL = TCP)(HOST = Standby.host)(PORT = 1521))
           (CONNECT_DATA =
           (SERVICE_NAME = ernie)
    )Next the service 'ernie' needs to be created manually on the primary database.
    BEGIN
       DBMS_SERVICE.CREATE_SERVICE('ernie','ernie');
    END;
    /After creating the service needs to be manually started.
    BEGIN
       DBMS_SERVICE.START_SERVICE('ernie');
    END;
    /Several of the default parameters can now be set for 'ernie'.
    BEGIN
       DBMS_SERVICE.MODIFY_SERVICE
       ('ernie',
       FAILOVER_METHOD => 'BASIC',
       FAILOVER_TYPE => 'SELECT',
       FAILOVER_RETRIES => 200,
       FAILOVER_DELAY => 1);
    END;
    /Finally a database STARTUP trigger should be created to ensures that this service is only offered if the database is primary.
    CREATE TRIGGER CHECK_ERNIE_START AFTER STARTUP ON DATABASE
    DECLARE
    V_ROLE VARCHAR(30);
    BEGIN
    SELECT DATABASE_ROLE INTO V_ROLE FROM V$DATABASE;
    IF V_ROLE = 'PRIMARY' THEN
    DBMS_SERVICE.START_SERVICE('ernie');
    ELSE
    DBMS_SERVICE.STOP_SERVICE('ernie');
    END IF;
    END;
    /lsnrctl status - should show the new service.
    When I do this the Database will still register with the listener. I don't give that to the clients. That one will still be available but nobody knows about it. Meanwhile "ernie" moves with the database role.
    So in my example the default just hangs out in the background.
    Best Regards
    mseberg
    Edited by: mseberg on Dec 29, 2012 3:51 PM

  • SQLPlus Default Database Connection

    I have two Oracle databases installed on the same LINUX server. One is a training database that is rarely even running.
    When logging in through SQLPlus and only supplying userid and password, the database to which the connect is attempted varies depending on the userid I am currently logged in as under LINUX. Under one userid, SQLPlus even attempts to connect to the idle training database. The 8i documentation indicates that setting the default database for SQLPlus is OS specific. Does anyone know how this is specified under LINUX?

    Joseph,
    That was one of my guesses, as well, but it doesn't seem to behave consistently.
    The .bash_profile files for both the oracle and mdm user are the same, however, the oracle user is able to default to the correct database, whereas mdm cannot.
    Here's the profile for mdm:
    $ cat .bash_profile
    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    # User specific environment and startup programs
    DISPLAY=localhost:0.0; export DISPLAY
    ORACLE_BASE=/usr/oracle; export ORACLE_BASE
    ORACLE_HOME=/usr/oracle; export ORACLE_HOME
    ORACLE_SID=pmisbk; export ORACLE_SID
    #ORACLE_SID=oralin; export ORACLE_SID
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33
    ORAENV_ASK=NO; export ORAENV_ASK
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib; export LD_LIBRARY_PATH
    umask 022
    NLS_LANG=american_america.EE8ISO8859P2; export NLS_LANG
    #PATH=$PATH:$HOME/bin
    PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/ActivePerl-5.6/bin:$PATH:$HOME/bin:$ORACLE_HOME/bin
    BASH_ENV=$HOME/.bashrc
    USERNAME=""
    export USERNAME BASH_ENV PATH
    . /usr/local/bin/oraenv
    and behavior:
    $ echo $ORACLE_SID
    pmis
    $ sqlplus
    SQL*Plus: Release 8.1.6.0.0 - Production on Thu Apr 25 14:01:10 2002
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Enter user-name: mdm
    Enter password:
    ERROR:
    ORA-01034: ORACLE not available
    Enter user-name: mdm@pmisbk
    Enter password:
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    SQL> exit
    Disconnected from Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    and the .bash_profile for oracle:
    $ su - oracle
    Password:
    $ cat .bash_profile
    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    # User specific environment and startup programs
    DISPLAY=localhost:0.0; export DISPLAY
    ORACLE_BASE=/usr/oracle; export ORACLE_BASE
    ORACLE_HOME=/usr/oracle; export ORACLE_HOME
    ORACLE_SID=pmis; export ORACLE_SID
    #ORACLE_SID=oralin; export ORACLE_SID
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33
    ORAENV_ASK=NO; export ORAENV_ASK
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib; export LD_LIBRARY_PATH
    umask 022
    NLS_LANG=american_america.EE8ISO8859P2; export NLS_LANG
    CLASSPATH=.:$ORACLE_HOME/jdbc/lib/classes111.zip:$ORACLE_HOME/sqlj/lib/translator.zip; export CLASSPATH
    PATH=/usr/local/ActivePerl-5.6/bin:$PATH:$ORACLE_HOME/bin
    BASH_ENV=$HOME/.bashrc
    USERNAME=""
    export USERNAME BASH_ENV PATH
    . /usr/local/bin/oraenv
    and the behavior:
    $ sqlplus
    SQL*Plus: Release 8.1.6.0.0 - Production on Thu Apr 25 14:07:47 2002
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Enter user-name: mdm
    Enter password:
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    SQL> exit
    Disconnected from Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    Perhaps this is because the Home directory for the oracle user is the same as $ORACLE_HOME.
    You may have noticed the connect string for mdm was to pmisbk. That's the alias in the tnsnames.ora file, otherwise if you try using pmis you get:
    Enter user-name: mdm@pmis
    Enter password:
    ERROR:
    ORA-12154: TNS:could not resolve service name
    and have to enter:
    Enter user-name: mdm@pmisbk
    Enter password:
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    SQL> exit
    If you specify pmisbk and the ORACLE_SID in the .bash_profile file, when you log into the server it prompts you:
    ORACLE_HOME = [usr/oracle] ?
    presumably because /etc/oratab does not contain an entry for pmisbk. You can respond with RETURN and the variable contains the correct path, but all the other behavior is as described above.

  • Use of oledb database connection in input form of process

    I've created dynamic pdf form with data connection to mssql database and with script that automatically adds rows to table and fills fields.
    When I try to open this form as input form for my process in workspace it generates an error: Unable to create SOM expression. That means that sql database connection works not properly.
    How can I fix this? Is it possible to use data connection to oledb database in the input form?

    Hi,
    I have a form that includes db connection (OLDB ->Access). But in
    workspace I have an error while initiating it. The error is an Adobe Acrobat message;
    "Unable to create SOM expression $record.tablename.fieldname"
    I am using Acrobat 9 pro ext. and when I use reader then there is no problem.
    I removed enhanced security settings in preferences of Acrobat. What else i can do? Any suggestions?
    Thank in advance..

  • Need help Crystal Reports running in BO 4.1 while using Universe as database connection.

    Sorry, I may not know how to describe this in the correct technical manner, but I'll explain in as simple terms as I can.
    I open up Crystal Reports 2013 click new document
    and it begins to ask for Database Expert.
    I select Universes and log in to my Business Objects Enterprise Explorer.   I then select the Universe that I want to write my report with,
    then i save the rpt on my local machine.
    then I log into my Business Objects 4.1 CMC or BI and upload this rpt file so that I can begin to schedule the report for example...
    but the problem i have is whenever I try to run the report, 
    it asks for a prompt for my database connection...  
    it displays the Universe name, but User Name Password, I am not sure what to write,
    do I write My login for Business Objects?  do I write the user name password of the database that Universe uses?
    in CMC I see a database configuration,  I tried many combinations and still have been receiving the following error message
    The viewer could not process an event. The database logon information for this report is either incomplete or incorrect. []
    ---- Error code:0 [CRWEB00000119]
    From all I read the point of using the Universe in Crystal reports is to be automatic in such a way that it doesnt need the database conneciton, because its technically using the Universe as the database connection....
    so what am I doing wrong here?    maybe its my database configuration,    I keep reading that it doesnt need anything...   that you upload the Crystal Reports and it would just work...
    any help with this issue would be greatly appreciated..
    thanks
    -Daniel

    Hi Daniel,
    What is the reporting DB used?
    The trick with your configuration is the following:
    - Universe Designer: 32bits application that may work fine on your desktop
    - Crystal 2013: 32bits application as well
    - When you export to the repository, Web Intelligence (64bits) has to process the Universe to extract the query.
    Your server should have the drivers required for Crystal + Universe: 32bit and 64bit versions.
    See more details on this KBA:
    https://service.sap.com/sap/support/notes/1821625
    Regards,
    Julian

  • Make use of established database connection

    From within an application in the Application Navigation, I have successfully established a connection to a database which is on another host machine. The steps are:
    right-click on the name of the application > select New > Database Tier > Database Connection > Connection Name ....
    After the connection is done, I am able to see the tables, etc. in the Connection Navigation, i.e., the connection was successful.
    Under the same application, I created a web project and in the project I am writing a servlet. I figure I can make use of the established connection as described above, to create sql statement object? But I do not know how. For example, I named that connection SbConnection, and tried the statements:
      Statment stmt = null;
      stmt = SbConnection.createStatement();
    But it does not work out. I am trying this because the classical way of
      Class.forname(....).newInstance();
      Connection conn = DriverManager.getConnection(......);
    does not work no matter how I tried.
    I am just starting in doing web application, servlet and JSP etc. and would appreciate a lot for any help.

    Fantastic, dvohra! It works out! Thanks a lot for the know-how!
    Next I am going to dig out something to read about JNDI and DataSource type of connection. But the part of editing the web.xml is magic and myth to me. Any suggested books or web sites for reading? (After know-how is know-why and know what I am doing.) Many thanks!

  • Regarding using a javabean database connections file

    Hi..I have a javabean file which contains some database connections.I would like to use this file in another javabean file. However, I got this 'cannot resolve symbol' error on the following line.The two javabean files i have here are sqlBean and TransactInfoBean which are contained in the same package.
    <coding>
    public class TransactInfoBean extends sqlBean {
    </coding>

    Are you sure you've got everything right ? One big problem with Java is that there is a difference between myClass and MyClass. A simple capital can make a big difference.

  • Default Database Connection Strings

    Does anyone know if it is possible to default the database connection strings/setup?
    We are trying to rollout ADI through Citrix and would like to default or pre-install the database connection setup instead of having every user set this up individually.
    I'm assuming there are some registry entries that can be set?
    If anyone has any ideas please share.
    Thanks and Regards,
    Chris
    ([email protected])

    ADI 7.2 included a service to centrally manage database definitions. Instructions on how to setup this service can be found in any of the ADI 7.2 Rollup patches in a file called CENTRAL.TXT (root directory of the patch).

  • Using predefined JDBC database connection in runtime for BC4J

    I've created an aplication using BC4J context, however I want to have several distinct users acessing this aplication, so I create the connection to the database using stantart JDBC 2.0, and now I want my application to use this connection instead of the one defined for BC4J.
    The database user owner of the objects must be locked.
    Is this possible?
    Many thanks.
    Nuno

    In Forms I used the following code to change the user at runtime. I created 3 char fields 'u','p' and 'c' for username, password and connect string respectively.
    declare
    uname varchar2(10);
    begin
    uname := get_application_property(username);
    -- To display your current username
    message(uname);
    pause;
    logout;
    logon(:u,:p&#0124; &#0124;'@'&#0124; &#0124;:c);
    end;
    Have a nice day,
    Abhijith Unnikannan,
    Oracle Support Services

  • How to get a recordset defined by primarykeys using the LabVIEW Database Connectivity Toolset?

    Hi folks.
    I'm using LabVIEW with the LabVIEW Db Toolset and Microsoft Access. The table contains 18 columns with a growing nr of rows.Now I want to get the whole recordset containing all columns defined by my primary keys. My SQL-statement is sofar:
    SELECT ALL FROM IMPULS_STATOR WHERE FAB = [string] AND LDATE = [datestring] AND ADATE = [datestring]
    But every time I end up with an error message saying "Invalid string: specified field does not exist or contains an unsupported character". I mutated the statement several times, adding or removing spaces, colons, etc.
    What am I doing wrong?
    Thanks in advance

    Thanks, Dennis.
    Unfortunately, I`m still encountering some problems with the DateValue function. My date/time field has this format: yyyy-mm-dd hh:nn:ss . If I use DateValue, nothing will be returned. Changing the format to yyyy-mm-dd in the Access DB didn`t help and I do need the time. Combining DateValue and TimeValue let to several errors. Using only TimeValue did not help me out. LabVIEW does not indicate errors anymore, therefore the syntax should be fine. But I don`t get any information back from my database.

  • Does EntityManager use the same database connection in a transaction?

    Hi All,
    I have a MDB in which I have created a EntityManager and began a transaction. I have passed this entity manager to all my DAO's via a standard setter method. Now I am wondering if this entity manager uses the same connection all the time until it's commited?
    If not how does it work?
    Thank you,
    K.

    Hi,
    I am injecting the entitymanager into my MDB but it's throwing the JTATransaction required when I am trying to execute any native query? So I have removed the injection and created through the entitymanager factory. Now I am wondering whether it will use the same connection object during one transaction?
    Here is the code which is throwing the JTATransaction required exception...
    * entityManager.
    @PersistenceContext(unitName = "myPersistenceUnit1")
    private EntityManager entityManager;
    <persistence-unit name="myPersistenceUnit1">
    <jta-data-source>jdbc/MySessionDS
    </jta-data-source>
    <properties>
    <property name="toplink.logging.level" value="FINEST" />
    </properties>
    </persistence-unit>

  • Is it possible to use multiple heterogeneous database connection in InfoVie

    Iu2019m trying to develop a report that creates a list from one database (Oracle) and retrieves additional data from a different database server (db2) using a subreport.  Iu2019m using BusinessView to access the data and I have successfully tested the report in Crystal XI R2.  When I publish the report in to InfoView BusinessObjects XI R2 the sub-reports donu2019t retrieve the data.
    Can this be accomplished with what I have describe or do I have to move the data to a single data source?
    Thank you in advance,
    Gabe

    It is possible to have every column in a single table use a different algorithm.
    Take a look in Morgan's Library (www.morganslibrary.org/library.html) under
    Wallet
    Transparent Data Encryption
    SecureFiles
    DBMS_CRYPTO
    and perhaps a few other topics.

  • Using wildcard in database Connectivity toolkit

    I have a MS Access databese like
    I want to delete the characters begining with 'abc'
    but after running it, the characters doesn't be deleted. 
    Any mistakes in the code? Thank you.
    Attachments:
    test_cn2011.zip ‏525 KB

    Use a '%' for the wildcard.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

Maybe you are looking for

  • Acrobat 8 and Windows 7 Don't Work

    I just loaded Windows 7, now my Adobe Acrobat 8 doesn't create or combine pdfs.  Reloaded Acrobat 8 and still doesn't work.  Is there a patch to work with windows 7? Thanks, Steve

  • Macbook pro 13 inch front cover bump edge and turns white

    I accidentaly bump the edges on the front cover of the MBP and the aluminium at that part turns kinda whitish. If you dont know what do i mean, just take a plastic cover and try bending it, then you will know what i mean If u guys out there can help

  • HT1904 How to remove the payment method?

    I would like to update my apps but at the end come out with a message ask me to fill in the payment method. After I fill up the form but payment failure to do so. Then I wish to remove all the payment method but there is no a column to choose. I am c

  • Chagne in value of Serverice PR

    hi, I want to change the price of service activity in PR but system is not allowing to do so because PO has been made from that PR, what to do to change the price of service PR Regards Kalpesh

  • ...ripping DVD material and saving as full movie...

    ...i've downloaded Mac the Ripper DVD extracting software but can't quite figure out how to extract the material as a full movie file( with audio) to re-edit as a clip that will be used in a project. I imported the VTS folder into FCP but not all the