PL/SQL reuse in ADF

Is disabling the use of application module pooling good practice for intranet applications where the number of users are known in advance (although in the thousands)? This was suggested as a solution to limit the amount of recoding that will be required of existing PL/SQL programs that make extensive use of global temp tables/package variables/etc. By disabling pooling (and a few other tweaks) the user will access the db with the same session and hence database state is preserved between requests. But in my experience a lot of PLSQL code is written to fit specific use cases (mostly on Forms) without considering the need to reuse the code in any other context (although I must admit that it can easily happen in any other language). I have repeatedly tried to explain that state is better maintained and much easier to deal with if it sits on the application but perhaps I'm wrong. Any advice will be much appreciated.

Hi,
its not enough. If you want to build an ADF application that behaves like Forms, then you need to look for implementing dynamic JDBC credentials so that users have dedicated database connections (which is what Forms is doing). Note that using Application Module pooling and database connection pooling is guaranteeing you better performance so that the question is what the required changes are (global PLSQL variables need to be removed for sure) to PL/SQL so the logic can be used in ADF applications that follow best practices (which is that they run as true Java EE web applications)
Frank

Similar Messages

  • UCCX 7.01, fresh install - SQL Reuse Utility doesn't work

    I am installing a fresh copy on UCCX 7.0 on two 7845 servers. As per the uccx70ig, after installing UCCX, before reboot, you install SQL. I have an MS SQL 2K CD from 4.0(5a), I installed the SQL Reuse Utility (SQLUtilTool.exe, v2.0.3) in the appropriate directory. After the "disable CSA", etc messages, I quickly get a message that the SQL install failed, look at C:\WINNT\setup.log for messages.
    There is nothing in there to indicate the problem.
    Anyone had this issue before? Thanks.

    Thanks, Anthony. The ZIP file, v2.0.3 was downloaded and expanded into a C:\SQL2K directory as per the instructions. The C:\WINNT\setup.log file that the failure message pointed me to shows the following:
    [InstallShield Silent]
    Version=v5.00.000
    File=Log File
    [Status]
    Completed=2
    [ResponseResult]
    ResultCode=0
    The C:\SQL2KUTIL.LOG file (for the last run) shows:
    CSCO:Wed May 05 16:24:04 2010:Display_Start_Message()
    CSCO:Wed May 05 16:24:05 2010:Display_Start_Message() - nResult = 6
    CSCO:Wed May 05 16:24:05 2010:CheckInstalled()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::readValue() sValue=version
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::readValue() sData=7.0(1)_Build168
    CSCO:Wed May 05 16:24:05 2010:CheckCRSInstalled() returned =1
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted()
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted(), sDrive value =E:\
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted() returned =1
    CSCO:Wed May 05 16:24:05 2010:CheckSqlCdInserted() returned =1
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft SQL Server 2000 (CRSSQL)
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled() - exception: csco_clss::Registry::openKey() RegOpenKeyEx failed {The system cannot find the file specified: 2}
    CSCO:Wed May 05 16:24:05 2010:IsSql2KInstalled() returned =0
    CSCO:Wed May 05 16:24:05 2010:Sql_Installation()
    CSCO:Wed May 05 16:24:05 2010:RegAdd()
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::createKey() creating key SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::addValue() type=4, value={ff25f0b5-c894-45f4-a29d-1bdd0c7926cd}, data=1
    CSCO:Wed May 05 16:24:05 2010:csco_clss::Registry::addValue() value added/updated successfully
    CSCO:Wed May 05 16:24:07 2010:StopNM()
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::openKey() opening key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::readValue() sValue=version
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Registry::readValue() sData=7.0(1)_Build168
    CSCO:Wed May 05 16:24:07 2010:StopNM() in:s string from reg =7.0
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Service::Service() opening service Cisco Unified CCX Node Manager
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Service::StopServices() : Service is already stopped
    CSCO:Wed May 05 16:24:07 2010:StopNM() returned
    CSCO:Wed May 05 16:24:07 2010:LaunchSQL2K()
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Process::launch() about to launch E:\SQL2K\x86\setup\setupsql.exe -s -f1 C:\SQL2K\setupSQL2K.iss
    CSCO:Wed May 05 16:24:07 2010:csco_clss::Process::initEnv(): Set 'PATH' to C:\Program Files\HP\NCU;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\wfavvid\lib;C:\Program Files\Cisco\bin;C:\Program Files\Cisco\AlarmService;C:\Program Files\Cisco\Desktop\bin;C:\Program Files\wfavvid\;
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::launch() finished launching/waiting for process
    CSCO:Wed May 05 16:24:12 2010:LaunchSQL2K() returned successfully
    CSCO:Wed May 05 16:24:12 2010:LaunchSP4()
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::launch() about to launch C:\SQL2K\MsSql2K.sp4\x86\setup\setupsql.exe -s -f1 C:\SQL2K\setupSP4.iss
    CSCO:Wed May 05 16:24:12 2010:csco_clss::Process::initEnv(): Set 'PATH' to C:\Program Files\HP\NCU;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\wfavvid\lib;C:\Program Files\Cisco\bin;C:\Program Files\Cisco\AlarmService;C:\Program Files\Cisco\Desktop\bin;C:\Program Files\wfavvid\;;
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Process::launch() finished launching/waiting for process
    CSCO:Wed May 05 16:24:17 2010:LaunchSP4() returned successfully
    CSCO:Wed May 05 16:24:17 2010:SetStartType()
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Service::Service() opening service mssearch
    CSCO:Wed May 05 16:24:17 2010:Exception in ServiceSetStarType()csco_clss::Service::Service() unable to open service. {The specified service does not exist as an installed service: 1060}
    CSCO:Wed May 05 16:24:17 2010:RegAddCiscoSQLflag()
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::Registry() constructor begin
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::createKey() creating key SOFTWARE\Cisco Systems\CRA\CurrentVersion
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::addValue() type=1, value=SQLProvider, data=cisco
    CSCO:Wed May 05 16:24:17 2010:csco_clss::Registry::addValue() value added/updated successfully
    CSCO:Wed May 05 16:24:17 2010:RegAddCiscoSQLflag() returned successfully
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() in:sDirectory=C:\WINNTsLogFile=setup.log
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() the sFilePath: C:\WINNT\setup.log
    CSCO:Wed May 05 16:24:17 2010:csco_clss::readMSSQL2KIssLogFile() the nResultCode: 0
    CSCO:Wed May 05 16:24:17 2010:csco_clss::readMSSQL2KIssLogFile() the nCompleted: 2
    CSCO:Wed May 05 16:24:17 2010:ReadMSSQL2KIssLogFile() found error in the Iss log file C:\WINNT\setup.log bError:1

  • Replace sql.. using ADF

    Hi,
    How can I use ADF to insert data into table instead of <sql:update...>statements?
    <sql:update var="newTable">
    create table mytable(
    nameid int primary key,
    name varchar(80)
    </sql:update>
    <Inserting three rows into table
    <sql:update var="updateCount">
    insert into mytable values(1,'Paul')
    </sql:update>
    is there tutorial available for this particular case?
    thanks in advance

    If you are using ADF Business Components you can just issue commands to the database using the connection of the AM and using a separate transaction.
    There is an example as part of the Coding Tips for ADF BC here:
    http://www.oracle.com/technology/products/jdev/tips/muench/techniques/index.html

  • Forms pl/sql in oracle adf

    hi how can i re use this oracle forms pl/sql
    {PROCEDURE perform_logon IS
    error_message varchar2(100);
    usr_id integer;
    fail_cnt integer;
    fail_limit integer;
    pwd sms_users.pwd%type;
    pwd_dt date;
    pwd_dt_period integer;
    sysdt date;
    msg_lvl varchar2(20) := :system.message_level;
    cursor usr is
      select id,pwd_change_dt,sysdate,pwd,login_failure_count
      from sms_users
      where user_id = :logon.usr_id
    --  and   pwd     = sms_secure.crypt('USR',id,:logon.pwd)
    BEGIN
    set_clnt_details;
      if :logon.usr_id is null then
            error_message := 'User id must be specified';
         sms_code.error_message('SMS-'||to_char(0000001)||': '||error_message,'', 'E', 'SMS');
      end if;
      if :logon.pwd is null then
            error_message := 'Password must be specified';
         sms_code.error_message('SMS-'||to_char(0000002)||': '||error_message,'', 'E', 'SMS');
      end if;
      pwd_dt_period := sms_global.ref_code('SMS','PWD_PERIOD',30,1);
      fail_limit    := sms_global.ref_code('SMS','PWD_FAIL_LIMIT',3,1);
      open usr;
      fetch usr into  usr_id,pwd_dt,sysdt,pwd,fail_cnt;
      if usr%NOTFOUND then
         close usr;
                 sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon'
                         ,:logon.usr_id
                         ,'Not SMS User'
                         ,:logon.usr_id
                         ,'sms0000');
            error_message := 'Logon to SMS Denied';
         sms_code.error_message('SMS-'||to_char(0000003)||': '||error_message,'', 'E', 'SMS');
      end if;
      close usr;
      if fail_cnt > fail_limit then
                       sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon - PWD'
                         ,:logon.usr_id ||':'||fail_cnt||':'||fail_limit
                         ,'Password retry limit exceeded'
                         ,:logon.usr_id
                         ,'sms0000');
            error_message := 'Password error limit have been exceeded contact the Administrator';
         sms_code.error_message('SMS-'||to_char(0000014)||': '||error_message,'', 'E', 'SMS');
      end if;       
      if pwd <> sms_secure.crypt('USR',usr_id,:logon.pwd) then
       sms_global.set_user_id(:logon.usr_id);
            update sms_users
              set login_failure_count = nvl(login_failure_count,0) + 1
              where id = usr_id
              :system.message_level := 15;
                          sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon - PWD Error'
                         ,:logon.usr_id ||':'||:logon.pwd
                         ,'Wrong user Password'
                         ,:logon.usr_id
                         ,'sms0000');
              commit;
              :system.message_level := msg_lvl;
            error_message := 'Logon to SMS Denied';
         sms_code.error_message('SMS-'||to_char(0000003)||': '||error_message,'', 'E', 'SMS');
      else
           if fail_cnt > 0 then
            update sms_users
              set login_failure_count = 0
              where id = usr_id
                          sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon - PWD Correct'
                         ,:logon.usr_id
                         ,'Reset Failed count'
                         ,:logon.usr_id
                         ,'sms0000');
              :system.message_level := 15;
              commit;
              :system.message_level := msg_lvl;
        end if;            
                          sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon - PWD Correct'
                         ,:logon.usr_id
                         ,'Success'
                         ,:logon.usr_id
                         ,'sms0000');
      end if; 
      if trunc(pwd_dt + pwd_dt_period) < sysdt then
            login_pwd_title;
         hide_an_item('logon.new_pwd1',1);
         hide_an_item('logon.new_pwd2',1);
                               sms_alog.record(:global.clnt_user    
                         ,:global.clnt_host_name ||':'||:global.clnt_ip_addr
                         ,'Logon - PWD Expired'
                         ,:logon.usr_id
                         ,'Password use Expired'
                         ,:logon.usr_id
                         ,'sms0000');
            error_message := 'Password Expired. Please change password.';
         sms_code.error_message('SMS-'||to_char(0000004)||': '||error_message,'', 'E', 'SMS');
      end if;       
       sms_global.set_user_id(:logon.usr_id);
       :global.User := :logon.usr_id;
       validate_usr_profiles (:logon.usr_id);
    END;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi.
    you can call procedures or functions without problems, and thus reuse
    see the doc http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvgen.htm#sm0297

  • How to use SQL query in ADF

    Hi Team,
    I want to fire one sql query to retrive some data. I cant make VO of that query as its from many DB link.
    Query is like SELECT query.
    Can anyone suggest me
    My Jdev :- 11.1.1.6.0
    Thanks In Advance
    Ramit

    I mean to say that the query is made by one or more than one schema .
    something like this:-
    Select hcsua.location , msib.description,
    hl.address1,hl.address2,hl.city,hl.state, hl.postal_code,hl.country, xmnd.part_number
    from hz_party_sites hps, hz_cust_acct_sites_all hcasa, hz_cust_site_uses_all hcsua, hz_locations hl, xxnin_moca_nmi_display xmnd, mtl_system_items_b msib
    Where hps.party_id = 176220
    And hps.party_site_id=hcasa.party_site_id
    And hcasa.cust_acct_site_id=hcsua.cust_acct_site_id
    And hcsua.site_use_code='SHIP_TO'
    And hps.location_id=hl.location_id
    and hcsua.location=xmnd.location_acct_num
    and msib.segment1=xmnd.part_number;
    when I am making SQL VO then its saying cant make attribute of this query.
    Please guide me on this.

  • Modifying SQL used by ADF Business components

    How can we modify the query used by ADF Business components that are generated from database tables by dnd in JDeveloper?

    I would like to change the where clause at runtime based on some configuration that can be changed while application is up and running. Can I just over ride the getWhereClause of the ViewObjetcImpl for that?

  • Future support for using PL/SQL core business logic with ADF BC

    We want to migrate our large Forms client/server (6i) application to ADF, possibly using a migration tool like Ciphersoft Exodus.
    One scenario could be to use ADF BC and ADF-Faces or a different JSF-Implementation for presentation and business layer but keep our heavy PL/SQL-businesslogic inside the Oracle database in packages, triggers, functions and procedures.
    This scenario could be chosen due to the huge amount of interconnected logic inside the database (10 years of development; no technical components; any package may access any table and more of this kind of dependencies). The business logic nowadays held in Forms client will be moved mainly into the database as a prerequisite to this scenario.
    Choosing this "keep-logic-in-DB"-scenario we need a good support by ADF BC to do so. We know and prototyped that it is possible to call some PL/SQL via JDBC from ADF BC and it is possible to use stored procedure calls for standard business entity data access (ins, del, upd, ..). But this does not solve our problems. We want to reuse core business logic coded in PL/SQL. This is much more than change the ADF standard behavior for an update with an own PL/SQL-call.
    Now my question:
    Will there be a kind of sophisticated support to use ADF BC in combination with database-kept logic?
    If so, when will this happen and how will the common problems of transactional state inside the database and inside the ADF BC be solved? Any plans or ideas yet?
    Many other clients do have similar applications built in Forms and PL/SQL and would be glad to hear about a path of direction.
    I've read the technical article 'understanding the ADF BC state management feature' which you have contributed to. One current limitation is pointed out there: Using PL/SQL with ADF BC limits ADF AM pooling to 'restricted level' which reduces scalability.
    Are you aware of additional main problems/tasks to solve when using PL/SQL heavily with ADF BC, which we have to think about?
    Thank you for any response.
    Ingmar

    My main problem is two 'concurrent' areas holding state in an application system based on DB-stored PL/SQL-logic in combination with ADF BC.
    For a new System everything can be made ok:
    Sure, it is possible to build a new system with the business logic included in ADF BC only. All long-living state will be handled in the BC layer ( including support for UnitsOfWork longer than the webside short HTTP-requests and HTTP-sessions and longer than the database transactions.
    For an old system these problems arise:
    1. DB data changes not reflected in BC layer:
    Our PL/SQL-logic changes data in tables without notifying the ADF BC layer (and its cache). To keep the data in ADF BC entity objects identical to the changed database content a synchronization is needed. BC does not know which part of the application data has been changed because it has not initiated the changes through its entity objects. Therefore a full refresh is needed. In a Forms4GL environment the behavior is similar: We do frequently requeries of all relevant (base)tables after calling database stored logic to be sure to get the changed data to display and to operate on it.
    -> Reengineering of the PL/SQL-logic to make the ADF BC layer aware of the changes is a big effort (notifying BC about any change)
    2. longer living database transactions
    Our PL/SQL-logic in some areas makes use of lengthy database transactions. The technical DB-transaction is similar to the UnitOfWork. If we call this existing logic from ADF BC, database state is produced which will not be DB-committed in the same cycle.
    This reduces scalability of ADF BC AM pooling.
    Example:
    a) Call a DB-stored logic to check if some business data is consistent and prepare some data for versioning. This starts a DB-transaction but does not commit it.
    b) Control is handed back to the user interface. Successful result of step a) is displayed
    c) User now executes the versioning operation
    d) Call another DB-stored logic to execute the versioning. DB-transaction is still open
    e) Business layer commits the transaction automatically after successful finishing step d). Otherwise everything from a) to e) is rolled back.
    -> redesign of this behavior (= cutting the 1to1 relation between LogicalUnitOfWork and the technicalDatabaseTransaction is a big effort due to the big amount of code.

  • ADF BC VO based on PL/SQL-API

    Hi,
    We have the following scenario.
    It exists a PL/SQL-API in the database which return a rowtype (the function must not be modified). These data are displayed in the GUI.
    FUNCTION get_rec(p_parm IN table.column%type) RETURN table%rowtype;We found no declarative solution to create a ADF VO or ADF EO on a PL/SQL-API.
    In the documentation "38.5 Basing an Entity Object on a PL/SQL Package API" the combine a db-view for reading (R) and pl/sql-api for the DML (CUD).
    On solution would be to define a SQL Type for this scenario, and add a new PL/SQL-function (because the orginal function must not be modified) which returns the type.
    FUNCTION get_rec(p_parm IN table.column%type) RETURN OUR_SQL_TYPE;Then we can use a statment like SELECT * FROM TABLE(pkg_x.get_rec(:param)) in the ADF BC VO.
    Note:
    We found [url https://database-api-based-adf-bc.samplecode.oracle.com/]database-api-based-adf-bc. but "Last Updated: Nov. 10, 2009 and Current Version:     0.2b" does not sound very encouraging.
    And [url http://technology.amis.nl/blog/3315/creating-an-adf-application-based-on-plsql-api-part-one-reading-data-as-a-collection-of-sql-type-objects]adf-application-based-on-plsql-api. is a good blog-post too but adjustments in the database (SQL_TYPE, ...) must also be made.
    Technologie: ADF 11g (Fusion Stack: ADF BC, ADF Faces)
    Question: Is there a more elegant (declarative) solution for this problem without making the request to change the code DB?
    Best Regards
    Martin

    Martin, I've tried several of the strategies that you've mentioned, and the one I liked best was to write a new function to translate the rowtype to a nested table of object type so that you can create a VO that is a SELECT from TABLE. More work on the database side, but the VO is declarative. There really isn't much better because a PL/SQL record is only usable within PL/SQL.
    John, I have used JPublisher which works well to create POJOs that execute PL/SQL functions and that represent database objects created with CREATE TYPE. It even generates the DDL and PL/SQL code that would be needed to create the object types to mirror PL/SQL record types. But you still have to write some code to integrate the generated code into ADF BC. In particular, the constructors for the POJOs take a Connection as an argument - obviously, you can't run PL/SQL without a connection to an Oracle RDBMS. So you usually want to instantiate the objects in an AM, which can provide a Connection. Not a bad tool - pretty useful for some scenarios, but still not as declarative as Martin (or I) would like.

  • Not able to read sql script file in ADF mobile

    hi,
    i am trying to create some DB tables in SQLLite DB (similar to the HR sample app where it creates bunch of DB objects using hr.sql file in .adf/META-INF)..
    but i am getting following error at runtime. i placed the file in .adf/META-INF directory in my application.
    "sqllite returned: error code=14, msg = cannot open file at source...."
    what am i missing here?
    please help.
    regards,
    ad

    This how I have done it.
    This is the start method from my Listener:
      public void start()
          String databaseName = "mydatabase";
          File dbFile = new File(AdfmfJavaUtilities.getDirectoryPathRoot(AdfmfJavaUtilities.ApplicationDirectory)+"/"+databaseName+".db");
          if(!dbFile.exists())
                try {
                    this.initializeDatabase(databaseName);
                } catch (Exception e) {
                    System.out.println(e.getMessage());
      }And this is a custom method also in the listener class
      private static void initializeDatabase(String databaseName) throws Exception
          List stmts = null;
          try {
              ClassLoader cl = Thread.currentThread().getContextClassLoader();
              InputStream is = cl.getResourceAsStream(".adf/META-INF/"+databaseName+".sql");
              if (is == null) {
                  // .sql script not found
              BufferedReader bReader = new BufferedReader(new InputStreamReader(is));
              stmts = new ArrayList();
              String strstmt = "";
              String ln = bReader.readLine();
              while (ln != null) {
                  if (ln.startsWith("REM") || ln.startsWith("COMMIT")) {
                      ln = bReader.readLine();
                      continue;
                  strstmt = strstmt + ln;
                  if (strstmt.endsWith(";")) {
                      System.out.println(strstmt);
                      stmts.add(strstmt);
                      strstmt = "";
                      ln = bReader.readLine();
                      continue;
                  ln = bReader.readLine();
              String Dir = AdfmfJavaUtilities.getDirectoryPathRoot(AdfmfJavaUtilities.ApplicationDirectory);
              String connStr = "jdbc:sqlite:" + Dir + "/"+databaseName+".db";
              Connection conn = null;
              conn = new SQLite.JDBCDataSource(connStr).getConnection();
              conn.setAutoCommit(false);
              for (int i = 0; i < stmts.size(); i++)
                  Statement pStmt = conn.createStatement();
                  pStmt.executeUpdate((String)stmts.get(i));
              conn.commit();
              conn.close();
          } catch (Exception ex)
              ex.printStackTrace();
          }My .sql scrip named "mydatabase.sql" located in the ADF META-INF folder.
    See this picture :
    http://upload.wiim.be/img/Screenshot%20at%20jan.%2019%2011-39-30.pngDon't forget the register your Listener class to the adfmf-application.xml file!
    http://upload.wiim.be/img/Screenshot%20at%20jan.%2019%2011-42-24.png

  • ADF 11g : Calling PL Sql Function

    Hi there..
    I am trying to call a PL/SQL Function from my application module in ADF 11g.
    The code looks something like this
        public void getName(int relationNumber) {
            DBTransaction tc = getDBTransaction();
            StringBuffer statement = new StringBuffer("begin ");
            statement.append("? := COMP_RLE.RLE_GET_NAME(?);");
            statement.append("end;");
            OracleCallableStatement cs = (OracleCallableStatement)tc.createCallableStatement(statement.toString(), 0);
            try {
                cs.registerOutParameter(1, Types.VARCHAR);
                cs.setInt(2, relationNumber);
                cs.execute();
                String retValue = cs.getString(1);
                System.out.println(retValue);
            } catch (SQLException e) {
                System.err.println("Something went wrong: " + e.getMessage());
        }When I run this in TOAD I get a result back in the form of a String.
    However when I run the code above in a Unit Test I get back "null".
    Does anybody know what I am doing wrong here?
    Hope someone can help me out here.
    Thanks in advance,
    Gideon

    I think it will probably work that way.. but the thing is.. I have been going over examples.. and they work with the CallableStatement.
    I just want to know how come this isn't working the way it should.
    Did I miss something?
    Examples that I was looking at are:
    <li>http://www.experts-exchange.com/Programming/Languages/Java/Q_24106340.html
    <li>http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/varray/index.html
    <li>Re: Returning a value from PL/SQL Function in ADF BC
    and
    <li>http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#sm0457
    They all work with the (Oracle)CallableStatement
    Edited by: Gideon Liem on Dec 4, 2009 12:27 AM

  • Writing sql in adf bc

    hi,
    Now i'm doing my final year project(6 months) and currntly i'm doing project in adf faces business components with jsf . here i want full demo to create jsf page using adf faces upto database linking includes dml options behind the adf button(any) component. how do i write sql query in adf faces. please reply me soon.
    With regards
    SAN

    Create a new fusion web application
    Connect to a database (View menu - Database Navigator)
    In the model project you can create view objects using sql query
    In the view controller project create jsf pages (just to learn you can use task flows for navigation)
    From the Data Controls palette drag n drop as forms, multiple selections, single selections, table or tree component.
    First of all I would go through tutorials. Good luck!

  • Problem with range page with SQL Server

    Please help
    JDev version JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
    I am using range paging for one of the VOs. The VO is based on single table. The VO is bounded to af:table. We need to support both Oracle and SQL server.
    When database is Oracle , the range paging works fine.
    But when database is SQLServer only first page is fetched properly, all the other pages are just copy of first page. The pagesize is default (25).
    Did I miss anything ?
    With accessMode=Scrollable the table show correct data for both Oracle and SQLServer.
    This is my VO XML
    <?xml version="1.0" encoding="windows-1252" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="MessagesROVO"
      Version="11.1.1.64.93"
      InheritPersonalization="true"
      OrderBy='"TIMESTAMP" desc'
      BindingStyle="JDBC"
      CustomQuery="true"
      RowClass="model.bc4j.queries.admin.MessagesROVORowImpl"
      ComponentClass="model.bc4j.queries.admin.MessagesROVOImpl"
      FetchMode="FETCH_AS_NEEDED"
      PageIterMode="Full"
      UseGlueCode="false"
      Passivate="All"
      AccessMode="RANGE_PAGING">
      <DesignTime>
        <Attr Name="_codeGenFlag2" Value="Access|Coll|VarAccess"/>
        <Attr Name="_isExpertMode" Value="true"/>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <Properties>
        <SchemaBasedProperties>
          <LABEL
            ResId="model.bc4j.queries.admin.MessagesROVO_LABEL"/>
        </SchemaBasedProperties>
      </Properties>
      <Variable
        Name="BINDApplicationName"
        Kind="viewcriteria"
        Type="java.lang.String">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="0"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDServerName"
        Kind="viewcriteria"
        Type="java.lang.String">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="1"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDStartTimestamp"
        Kind="viewcriteria"
        Type="java.lang.Float">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="3"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDEndTimestamp"
        Kind="viewcriteria"
        Type="java.lang.Float">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="4"/>
        </AttrArray>
      </Variable>
      <SQLQuery>
        <![CDATA[SELECT
        ERRORLOG.SGUID GUID,
        ERRORLOG.LLOGTYPE LOGTYPE,
        ERRORLOG.DTIMESTAMP TIMESTAMP,
        ERRORLOG.SSERVERNAME SERVERNAME,
        ERRORLOG.SAPPNAME APPNAME,
        ERRORLOG.SXMLERROR XMLERROR
    FROM
        ERRORLOG ERRORLOG]]>
      </SQLQuery>
      <ViewAttribute
        Name="Guid"
        IsUpdateable="false"
        IsPersistent="false"
        IsNotNull="true"
        PrecisionRule="true"
        Precision="40"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="GUID"
        Expression="GUID"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="40"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="LogType"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="6"
        Scale="0"
        Type="java.lang.Integer"
        ColumnType="NUMBER"
        AliasName="LOGTYPE"
        Expression="LOGTYPE"
        SQLType="INTEGER">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="7"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="Timestamp"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="54"
        Scale="0"
        Type="java.lang.Float"
        ColumnType="FLOAT"
        AliasName="TIMESTAMP"
        Expression="TIMESTAMP"
        SQLType="FLOAT">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="18"/>
        </DesignTime>
        <Dependencies>
          <Item
            Value="OccuredAt"/>
        </Dependencies>
      </ViewAttribute>
      <ViewAttribute
        Name="ServerName"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="64"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="SERVERNAME"
        Expression="SERVERNAME"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="64"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="AppName"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="10"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="APPNAME"
        Expression="APPNAME"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="10"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="XmlError"
        IsUpdateable="false"
        IsQueriable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="LONGVARCHAR"
        AliasName="XMLERROR"
        Expression="XMLERROR"
        SQLType="VARCHAR"/>
      <ViewAttribute
        Name="OccuredAt"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.sql.Date"
        ColumnType="DATE"
        AliasName="VIEW_ATTR"
        SQLType="DATE"/>
      <ViewAttribute
        Name="Summary"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="VARCHAR2"
        AliasName="VIEW_ATTR"
        SQLType="VARCHAR"/>
      <ViewAttribute
        Name="TechnicalError"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="VARCHAR2"
        AliasName="VIEW_ATTR"
        SQLType="VARCHAR"/>
      <ViewCriteria
        Name="MessagesROVOCriteria"
        ViewObjectName="model.bc4j.queries.admin.MessagesROVO"
        Conjunction="AND">
        <Properties>
          <CustomProperties>
            <Property
              Name="displayOperators"
              Value="InAdvancedMode"/>
            <Property
              Name="autoExecute"
              Value="false"/>
            <Property
              Name="allowConjunctionOverride"
              Value="true"/>
            <Property
              Name="showInList"
              Value="false"/>
            <Property
              Name="mode"
              Value="Basic"/>
          </CustomProperties>
        </Properties>
        <ViewCriteriaRow
          Name="vcrow6"
          UpperColumns="1">
          <ViewCriteriaItem
            Name="Timestamp"
            ViewAttribute="Timestamp"
            Operator="BETWEEN"
            Conjunction="AND"
            Required="Optional">
            <ViewCriteriaItemValue
              Name="MessagesROVOCriteria_vcrow6_Timestamp_vcval0"
              Value=":BINDStartTimestamp"
              IsBindVarValue="true"/>
            <ViewCriteriaItemValue
              Name="MessagesROVOCriteria_vcrow6_Timestamp_vcval1"
              Value=":BINDEndTimestamp"
              IsBindVarValue="true"/>
          </ViewCriteriaItem>
          <ViewCriteriaItem
            Name="ServerName"
            ViewAttribute="ServerName"
            Operator="="
            Conjunction="AND"
            Value=":BINDServerName"
            IsBindVarValue="true"
            Required="Optional"/>
          <ViewCriteriaItem
            Name="MessagesROVOCriteria_vcrow6_AppName"
            ViewAttribute="AppName"
            Operator="="
            Conjunction="AND"
            Value=":BINDApplicationName"
            IsBindVarValue="true"
            Required="Optional"/>
        </ViewCriteriaRow>
      </ViewCriteria>
      <AttrArray Name="KeyAttributes">
        <Item Value="Guid"/>
      </AttrArray>
      <ResourceBundle>
        <XliffBundle
          id="model.resource.ViewObjectsBundle_en"/>
      </ResourceBundle>
    </ViewObject>

    ADF does not support VO Range Paging with MS SQL Server. ADF supports VO Range Paging only with Oracle DB:
    Oracle ADF Business Components with Multiple Databases
    As far as the document above is not quite clear, I took a look inside the source code of the methods buildRangePagingQuery(...) of classes oracle.jbo.server.ViewObjectImpl, oracle.jbo.server.BaseSQLBuildeImpl, oracle.jbo.server.SQLServerSQLBuilderImpl and oracle.jbo.server.OracleSQLBuilderImpl (ADF 11.1.1.7) in order to confirm my statement.
    In my opinion, it is possible to add Range Paging support for a SQLServer-backed VO by implementing a custom VO class and overriding the method ViewObjectImpl.buildRangePagingQuery(...). Your method implementation should take into account the specifics of MS SQL Server and its SQL syntax.
    Dimitar
    Message was edited by: DimitarDimitrov
    P.S. The oracle.jbo.server.SQLServerSQLBuilderImpl class does not implement its own buildRangePagingQuery() method and uses the method implementation from its base class oracle.jbo.server.BaseSQLBuilderImpl, The base implementation just returns the original VO query intact. This is the reason you get the same rows as from the 1st page when you try to navigate through the pages.

  • Got an error while creating bind variables using sql database.

    iam going to use sql database for ADF-BC .
    i created the bind variable and apply the bind position for the corresponding variable in the view object editor.when i click test it shows me "query is valid". when i tried to run that it gives me two errors.
    1) sql error during statement preparation.(ie) select empid ,empname......from the emptable where empid like :'emp' and
    2) [Microsoft][SQl server  2000 driver  for jDBC] invalid parameter bindings
    i need help to know the solution for this...(or) is there any other way to create bind variable ......

    The 3 binding styles supported by JDev:
    Oracle Named - ie. SELECT xxxx FROM xxxx WHERE emp_id = :vEmp (note colon and variable name)
    Oracle Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = :1 (note colon)
    JDBC Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = ?
    Literally this query is sent to the database to execute, then the bind variables values are applied as a separate database operation. If SQL Server doesn't suport any of these binding styles, it's not going to work. As Chris Noonan suggests, try the JDBC Positional style though as you're using a JDBC driver to connect to SQL Server and it should support that style (the others are Oracle styles), and make sure you've switched the binding style on the VO query page to "JDBC Positional" too.
    You must also on the VO bind variable page define your bind variables.
    Also read the 10.1.3 JDev guide on ADF Business Components and View Object bind variables.
    CM.

  • Creating/calling stored procedure in ADF

    Hi,
    I'm new to Jdev and trying to create and call a database procedure in ADF. I simply want to call a database procedure which will populate an attribute. I've seen examples of stored procedures in for ADF by can't seem to put it all together. I know that you can create a method which calls a stored procedure, but exactly where is this method placed and how do I execute it at runtime..ie how is the method called?
    Thanks

    If what your PL/SQL code is a function (not a procedure) you can call it as part of the SQL for an ADF BC View object.
    Something like : Select ename,myFunc(sal) from emp;

  • Error using bind variables with SQL server with SQL92 mode

    I am using 2 bind variable in my VO (JDBC positional) . The mode is SQL 92 for ADF BC. I do not use the bind variable directly but in a view criteria. I see following error in the logs.
    The logs show the query executed and error.  I tried both ways - making bind variable required and not required. I have set -Djbo.SQLBuilder=SQLServer property. My other page works which has an updatable VO.
    JDEV version is - JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
    <ViewObjectImpl> <getQueryHitCount> [4567] Estimated Row Count for ViewObject: [oracle.epm.fm.bc4j.queries.admin.UserOnSystemROVO]AdministrationAM.UserOnSystemROVO1, Query Statement:
    <ViewObjectImpl> <getQueryHitCount> [4568] "SELECT count(1) FROM (SELECT * FROM (SELECT
        TABLE1.SUSERNAME USERNAME,
        TABLE2.SMODULENAME MODULENAME,
        TABLE2.LACTIVITYCODE ACTIVITYCODE,
        TABLE2.DSTARTTIME STARTTIME,
        TABLE2.SSERVERNAME SERVERNAME,
        TABLE2.SAPPNAME APPNAME,
        TABLE2.LSESSIONID SESSIONID,
        TABLE2.LSESSIONSTATUS SESSIONSTATUS,
        TABLE2.LUSERID USERID,
        TABLE2.DSTILLALIVETS STILLALIVETS,
        TABLE2.LTASKID TASKID,
        TABLE2.SACTIVITYDESC ACTIVITYDESC,
        TABLE1.LUSERID USERID1,
        TABLE1.SUSERDESC USERDESC
    FROM
        TABLE2 TABLE2,
        TABLE1 TABLE1
    WHERE
        TABLE2.LUSERID = TABLE1.LUSERID) QRSLT  WHERE ( ( ( ( UPPER(SERVERNAME) = UPPER(?)  )  OR  ( ? IS NULL ) ) AND ( ( UPPER(APPNAME) = UPPER(?)  )  OR  ( ? IS NULL ) ) ) )) ESTCOUNT"
    <ViewObjectImpl> <getQueryHitCount> [4569] Bind params for ViewObject.getQueryHitCount: UserOnSystemROVO1
    <ViewRowSetImpl> <doSetWhereClauseParam> [4570] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(0, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4571] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(1, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4572] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(4, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4573] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(5, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4574] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(2, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4575] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(3, null, null)
    <ADFLogger> <addContextData> Estimated row count
    <BaseSQLBuilderImpl> <bindParamValue> [4576] Binding null of type 12 for 1
    <BaseSQLBuilderImpl> <bindParamValue> [4577] Binding null of type 12 for 2
    <BaseSQLBuilderImpl> <bindParamValue> [4578] Binding null of type 12 for 3
    <BaseSQLBuilderImpl> <bindParamValue> [4579] Binding null of type 12 for 4
    <BaseSQLBuilderImpl> <bindParamValue> [4580] Binding null of type 12 for 5
    <ViewObjectImpl> <getQueryHitCount> [4581] ViewObjectImpl.getQueryHitCount failed...
    <ViewObjectImpl> <getQueryHitCount> [4582] java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver]Invalid parameter binding(s).
      at weblogic.jdbc.sqlserverbase.dda4.b(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda4.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda3.b(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda3.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb8.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb9.setNull(Unknown Source)
      at weblogic.jdbc.wrapper.PreparedStatement.setNull(PreparedStatement.java:622)
      at oracle.jbo.server.BaseSQLBuilderImpl.bindParamValue(BaseSQLBuilderImpl.java:2215)
      at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3687)
      at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:22684)
      at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4944)
      at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4857)
      at oracle.jbo.server.QueryCollection.getEstimatedRowCount(QueryCollection.java:4204)
      at oracle.jbo.server.ViewRowSetImpl.getEstimatedRowCount(ViewRowSetImpl.java:2677)
      at oracle.jbo.server.ViewObjectImpl.getEstimatedRowCount(ViewObjectImpl.java:10632)

    After making all the bind variables not required, the error is no longer coming.

Maybe you are looking for