Best practise for returning data from EJB's

I have an EJB that runs a query on a backend database and i want to return the data back to my Java GUI. Ideally i would like to pass a ResultSet back but i don't think they are serialisable so this isn't an option.
What's considered the best way to pass database results back from EJB's to a front end Java application ?
Thanks for any ideas you guys have

If you want type-safety, define a VO (value object) that maps to your result-set, extract the data from the result set into the VO, and return an array of the data. Yes, it's extra work on the "back-end," but that's what the back-end is for. Just make sure your client.jar has the VO in it, as well as the Home and Remote interfaces.

Similar Messages

  • Best method for transferring data from one database to another?

    There is an 8i database I have to deal with on a regular basis. Besides being completely outdated and unsupported, in my opinion the database has not been well-maintained--for a table with 25 million records, should ‘select count(*) from table;’ take 5 minutes to run? I don’t really know, but that seems long to me. Many complex queries (most including only tables with less than a million records) take a ridiculously long time to run, to the point that I can’t even run some of them.
    I am not the DBA; I don't have the authority to fiddle with the database (nor would I feel comfortable doing that), and the powers that be will not put effort into improving functionality of this database due to an alleged plan to update/replace it within the next year. However, in the mean time, I still have to get data out of this database on a regular basis.
    I have XE 10g installed on my local machine, and I have set up a database link in it to the 8i database. I have found that I can pull in basic data (simple queries) from the 8i database into tables in my XE database (e.g. create table tbl1 as select data from tbl1@8idb) and then query those tables to get the information I need much, much faster (including creation of the tables). While this option does not allow me to create queries/reports that other people can run, it makes work I’m doing only for myself much faster.
    What I’m wondering is, what is the best way to bring the information I need over to my database? I usually don’t need entire tables, and I can probably identify a number of key tables (or parts of tables) I need. What I’ve been doing up until now is writing CREATE TABLE statements on the fly, but then I end up forgetting what all I’ve done, and each time I want up-to-date data, I have to drop the tables and re-create them. It seems to me that there should be an easier way to do this than to copy and paste from a text document into SQL*Plus.
    Does anyone have any suggestions for me on how best to do this?

    Sorry, I guess I posted this in the wrong forum. I re-posted in the database-general forum.

  • How to return data from Ejb as collection to Front End application.

    Hi,
    I am creating a J2ee application. Here i am accessing BAPIs using stateless session bean through JCO connection. Now the BAPI is returning a return Table and return Structure to the EJB.
    I have coded the following code in one of the Ejb Method as follows:
    JCO.Table returnTable = null;
    JCO.Structure returnStructure = null;
    JCO.ParameterList paramList = siteBAPI.getExportParameterList();
    JCO.ParameterList paramList2 = siteBAPI.getTableParameterList();
    returnTable = paramList2.getTable("SITE_SUBSITE_INSTL");
    returnStructure = paramList.getStructure("BAPIRET2");
    Now i want to sent this data( returnTable & returnStructure) to front end application where front end developer accessing this returned data using Jsp.
    My scenario is that , first i want to convert this returnTable & returnStructure in a single collection and then sent this collection to Front end.
    My aim is that , the front end the application should not receive the Data, using JCO.table Variable but as a single Collection.
    I am using NWDI-2004s sps10.
    i need urgent help on this issue and i would really appreciate if somebody can put the answer with some sample code on how to return the data as Collection.

    if you want to return a result, then you probably shouldn't be using a message bean. message beans for for asynchronous tasks. session beans for for synchronous tasks. thus it would make much more sense to have your jsp call the session bean directly.

  • Best Practise for loading data into BW CSV vs XML ?

    Hi Everyone,
    I would like to get some of your thoughts on what file format would be best or most efficient to push data into BW. CSV or XML ?
    Also what are the advantages / Disadvantages?
    Appreciate your thoughts.

    XML is used only for small data fields - more like it is easier to do it by XML rather than build an application for the same - provided the usage is less.
    Flat files are used for HUGE data loads ( non SAP ) and definitely the choice of data formats would be flat files.
    Also XML files are transformed into a flat file type format with each tag referring to the field and the size of the XML file grows to a high value depending on the number of fields.
    Arun

  • Dynamic implementation download for return values from EJB

    I try the following exemplary scenario regarding dynamic implementation download. Let's say there is a statless EJB deployed (e.g. OrderHandler) with a method getSomeOrder() returning Order object; where Order is actually an interface extending java.io.Serializable. For Order there is implementation class OrderImpl. Within the getSomeOrder() the EJB creates a new OrderImpl, populates it and returns as interface. The client looks up OrderHandler and calls getSomeOrder() method. Then, on Order a dummy: String getName() method is called.
    Now, the problem is various behavior with implementation dynamic download. I receive different behavior from 2 clients (1st being launched from within LAN with the server, 2nd from outside server's LAN). When I put OrderImpl in clients' classpaths, obviously they both work the same. When I leave only Order interface (!!the very goal of the test - dynamic impl. download!!), only the 1st client still works. I measured times in milis, and it looks that the OrderImpl is really downloaded, as the first getSomeOrder() call lasts around 10 times as long as further calls.
    The 2nd client hangs a while on the getSomeOrder() call and then throws UnmarshallException, stating that it has failed to unmarshal the returned object, which basically means no implementation got downloaded.
    Can anyone help?

    You can try putting the Impl classes on a webserver.
    while starting the server set the property
    -Djava.rmi.server.codebase=http://mywebserver:8080
    While running the client if the impl classes are not available in the classpath, it would download it from the webserver

  • Best practice for linking fields from multiple entity objects

    I am currently transitioning from PHP to ADF. I'm looking for the best practice for linking data from multiple entity objects.
    Example:
    EO 'REQUESTS' has fields: req_id, name, dt, his_stat_id, her_stat_id
    EO 'STATUSES' has fields: stat_id, short_txt_descr
    'REQUESTS' is linked to EO 'STATUSES' on: STATUSES.stat_id = REQUESTS.his_status_id
    'REQUESTS' is also linked to EO 'STATUSES' on: STATUSES.stat_id = REQUESTS.her_status_id
    REQUESTS.his_status_id is independent of REQUESTS.her_status_id
    When I create a VO for REQUESTS, I want to display: REQUESTS.name, REQUESTS.dt, STATUSES.short_txt_descr (for his_stat_id), STATUS.short_txt_descr (for her_stat_id)
    What is the best practice for accomplishing this? It appears I could do it a few different ways:
    1. Create the REQUESTS VO with a LOV for his_stat_id and her_stat_id
    2. Create the REQUESTS VO with the join to STATUSES performed within the query for the VO. This would require joining on the STATUSES EO twice (his_stat_id, her_stat_id)
    3. I just started reading about View Links - would that somehow do what I'm looking for?
    I also need to be able to update his_status_id and her_status_id through the by selecting a STATUSES.short_txt_descr from a dropdown.
    Any suggestions on how to approach such a stupidly simple task?
    Using jDeveloper 11.1.2.2.0 if that makes a difference in the solution.
    Thanks ahead of time,
    CJ

    CJ,
    I vote for solution 1 as it's just your use case. As you said you what to update the his_status_id and her_status_id through the by selecting a STATUSES.short_txt_descr by a drop down. This is exactly the LOV solution.
    ViewLinks are used fro master detail navigation (which you don't do here) and Joining the data make it difficult to update (and you still need a LOV for the drop down box.
    Timo

  • Best Practice on querying Data from Database

    Hello and I was wondering what is the preferred and best practice for querying data from an SQL database inside a JSP page. Is it using the JSTL library or another method? Thanks

    It depends on the size of the application really.
    The "correct and preferred" approach in a large MVC app would be to have a seperate class that does all the database access, retrieving the data into java objects.
    Check out [url http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html] DAO pattern
    You then "save" the data into request/session attributes, and forward to a jsp page to render the result.
    Most approaches recommend a separation between JSP (the view) and SQL code.
    The JSTL sql tags are provided more for "quick and dirty" code applicable in small applications, or for fast prototyping. That approach is not really robust for large scale applications.
    Cheers,
    evnafets

  • Best choice for a date column in forms

    Hello,
    I want to know what is the best choice for a date field that the user have to enter manually. I read on a other post that a calender control is not directly implemented in forms 9i. So what is the best choice to be "user friendly" with a date field in a form?
    thanks in advance.

    Hi
    Don't know if this would be much use to you, but I wrote this function 'Check_Date' a while back to check whether the user had typed something which could be interpreted as a date. You'd make your date field into a Text Item, and include a call to this function (which could be in your form, or in a library) in the WHEN-VALIDATE-ITEM trigger on the item, ie:
    IF NOT check_date(:ITEMS.date_item1, NULL, NULL) THEN
        RAISE FORM_TRIGGER_FAILURE;
    END IF;This would mean that the user could type 'T' or '*' for today, '+1' for tomorrow, '-7' for one week ago, or the date in a variety of formats. When they leave the field, the function tries to resolve what they've typed into a date, and sets the field to a date in the correct format.
    ('Display_Alert' is just a function to display a named alert with a message.) It can also be used to check that the date entered doesn't fall outside upper and lower bounds. Code follows:
    FUNCTION Check_Date (text_in        IN OUT VARCHAR2,
                         lower_bound_in IN DATE,
                         upper_bound_in IN DATE)
    RETURN BOOLEAN IS
    first_letter      VARCHAR2(1)  := SUBSTR(text_in, 1, 1);
    date_ok           BOOLEAN;
    this_date         DATE;
    date_diff         NUMBER(8);
    output_format     VARCHAR2(12) := Get_Application_Property(BUILTIN_DATE_FORMAT);
    TYPE date_format_table_type IS TABLE OF VARCHAR2(12)
    INDEX BY BINARY_INTEGER;
    date_format_table    date_format_table_type;
    BEGIN
        --Set up table of date formats in order they'll be tested for
        date_format_table(1)  := 'DD-MON-RRRR';
        date_format_table(2)  := 'DD-MM-RRRR';
        date_format_table(3)  := 'DD-MM';
        date_format_table(4)  := 'DD-MON';
        date_format_table(5)  := 'YYYY-MM-DD';
        date_format_table(6)  := 'YYYY-MON-DD';
        --Use of T, or * for today's date...
        IF UPPER(text_in) IN ('T', '*') THEN
               this_date := SYSDATE;
               date_ok := TRUE;
        --Look for use of +x/-x for number of days different from today
        ELSIF first_letter IN ('+', '-') THEN
               BEGIN
                   date_diff := TO_NUMBER(SUBSTR(text_in, 2));
                   IF first_letter = '+' THEN
                       this_date := SYSDATE + date_diff;
                   ELSE
                          this_date := SYSDATE - date_diff;
                   END IF;
                   date_ok := TRUE;              
               EXCEPTION
                      WHEN VALUE_ERROR THEN
                          --User has entered something like '+X', so not valid
                          date_ok := FALSE;
               END;
        ELSE
            --Go through all the possible formats for date entry,
            --if any give a valid date, then return that.
            FOR ix IN date_format_table.FIRST..date_format_table.LAST LOOP
                   EXIT WHEN date_ok;
                BEGIN
                       --Try creating a date using the format masks in the local
                       --table.  If no good, this will throw an INVALID_DATE exception
                       this_date := TO_DATE(text_in, date_format_table(ix));
                       date_ok := TRUE;
                   EXCEPTION
                       WHEN OTHERS THEN
                           date_ok := FALSE;
                   END;
            END LOOP;
        END IF;
        IF date_ok THEN         
               --Check for violation of lower/upper bounds on date
               IF (lower_bound_in IS NOT NULL AND this_date < lower_bound_in) THEN
                   Display_Alert('info_alert', 'Date cannot be before '||TO_CHAR(lower_bound_in, output_format));
                   date_ok := FALSE;
               ELSIF (upper_bound_in IS NOT NULL AND this_date > upper_bound_in) THEN
                   Display_Alert('info_alert', 'Date cannot be after '||TO_CHAR(upper_bound_in, output_format));
                   date_ok := FALSE;
               ELSE
                      text_in := TO_CHAR(this_date, output_format);
               END IF;
        ELSE
            Display_Alert('INFO_ALERT', text_in||' is not a valid date !!');
        END IF;
        RETURN date_ok;
    END;Hope this is useful.
    regards
    Andrew
    UK

  • Best practices for accessing data in subviews

    I've got two iPhone projects which share most of their code base. I'm trying to figure out the best way to load data from some plist files and store them in a common container UIView and provide access to the data for subviews and subviews of the subviews, etc. Right now I've got the data being passed from the container view to the subviews it creates and then the subview themselves pass it further, basically a bucket brigade to get the data to where it needs to go which could be 3 or 4 views down in the hierarchy.
    Is there a better approach? I've looked at delegates & protocols but I'm having a hard time understanding how they work and whether they are appropriate in this situation. Originally I had the app delegate holding the data and any class anywhere could invoke the app delegate and get the data. However this approach fails with 2 projects because the app delegates have different names and the classes that need to access it are common to both projects. Can the app delegate be renamed without significant impact? Or is there a way a UIView can be set up as a delegate in much the same way?
    Thanks for any advice!
    Greg

    Hi Greg - You can rename the app delegate class to whatever you want, just remember to change it in IB, and make sure you catch any place it already appears in your code. I guess there's no need to change the app delegate class file names unless you want to.
    However there are lots of other solutions to your problem. A case could be made for declaring a global pointer to this data, for example. Or, you could encapsulate the data wherever you want and make an extern (globally visible) C function to access it.
    Another solution would be to put the data in a shared object which would be accessed just like the shared app object, e.g.
    #include "MyObject.h"
    NSDictionary *myPlistData = [MyObject sharedObject].plistData;
    I just got done looking at "how to make a shared object" in the Cocoa docs and can't seem to find it atm. Anyway it's in there somewhere, either in an Obj-C doc or one of the top level guides. The job just wants a class method that returns the pointer stored in a static C var; if the var is nil, the object is first created and its addy is stored in the var.
    Hope that helps!
    - Ray

  • What is the best practise for setting dirty flag of a page/view?

    For a page/view, normaylly there are 2 things to do for diry data:
    1. when it's clean, Save button is disabled, when it's dirty, save button is enabled.
    2. when it's dirty and the window is closed, a popup says "you have unsaved data, close will lose the data".
    My thought is: it must be handled at client side, because not all valuechange is auto submitted. E.g., you type the 1st letter of a string in a input box, the server side does not know it, but save button should be enabled immediately.
    Is it possible to capture all valueChange events in a page or a view at client side?
    I'm not sure what is the best practise for setting dirty flag? If there is better solution? Does ADF provide facility for this?

    public void save(ActionEvent event){
    boolean formValid = isFormValid();
       if (formValid) {
      save button is enabled.
        private boolean isFormValid() {
            boolean valid = true;
            if (Check Condition 1) {
                valid = false;
               showErrorMessage1();
            if (Check Condition 2) {
                valid = false;
               showErrorMessage1();
            return valid;
        private void showErrorMessage1() {
                    when it's dirty and the window is closed, a popup says "you have unsaved data, close will lose the data".

  • Best practises for replication

    Hi,
    I want to know what is best practise for duration of replicaation of database between two Cisco ACS.
    Regards,
    Atif.

    Hi Atif,
    The replication time interval should always be higher.
    Reason: Everytime you replicate the data it requires ACS services to restart so doing this frequently may affect your production enviroment.
    However, if you want to replicate internal user's password then there is an option to replicate password changes right awayvwithout a full replication.  You can enable this option under System Configuration -> Local Password Management.  With this enabled you could potentially set the replications to a larger interval.
    It also depend how often you do changes in your ACS. If its normal then I would say set it to every sunday 12:00 PM.
    This is how replication happens:
    The primary ACS stops its authentication and creates a copy of the ACSinternal database components that it is configured to replicate. During this
    step, if AAA clients are configured properly, those that usually use the primary ACS fail over to another ACS. The primary ACS resumes its authentication service.
    After the preceding events on the primary ACS, the database replication process continues on the secondary ACS. The secondary ACS stops its authentication service and replaces its database components with the database components that it received from the primary ACS. During this step, if AAA clients are configured properly, those that usually use the secondary ACS fail over to another ACS. The secondary ACS resumes its authentication service.
    HTH
    Regards,
    JK
    Plz rate helpful posts-

  • I want to return data from TreeMap in order from DB

    i want to return data from treemap in the order from the db... but it returns it in alphabetical order...

    You do realise of course that a TreeMap is a SORTED Map.
    It will sort whatever you put into it as you put items into it.
    If you don't want the items sorted, don't use a TreeMap.
    As suggested, a LinkedHashMap gives you the best of both worlds
    I often use a LinkedHashMap, indexed by primary key id, but ordered by something else (name for instance)
    - Retains insertion order (by default) for iteration
    - Provides the quick access of the Map - by id

  • Return data from all columns apart from a certain data type.

    Bit stuck on something, hope somebody here can help:
    I want to do a 'select * from ' a table, to return all columns except ones of a certain datatype. ie. I want to return data from all columns, excluding columns of datatype 'SDO_GEOMETRY'.
    This gives me the list of columns:
    SELECT COLUMN_NAME
    FROM   USER_TAB_COLUMNS
    WHERE TABLE_NAME = 'ORDER_ITEM'
    AND   DATA_TYPE <> 'SDO_GEOMETRY'; But I can't seem to take it any further...
    Now if I knew the columns beforehand, then of course I could just list them, excluding the geometry column, but this is to be used for a plug-in for MS Word, where a user can pick database columns to dynamically fill a report from - but I don't want the geometry columns as these can't be handled in this way.

    Hi Reggie,
    > connects to the database and presents a list of tables
    My guess is that this macro is written so it selects from all_tab_cols.
    Change that plugin and let it select from a view like the one above. That way, the users won't be able to see/pick anything that you are not able/willing to present for them.
    Edit:
    You could even tease your users, and let them see the columns, but not being able to pick them.
    create or replace view available_tab_columns
    as
       select decode(pickable.data_type, null, 0, 1) pickable
             ,atc.* -- narrow down yourself
         from all_tab_cols atc  -- or maybe user_tab_cols
             ,(select 'CHAR' data_type from dual union all
               select 'DATE' from dual union all
            select 'NUMBER' from dual
               -- complete positive list, yourself
              ) pickable
        where atc.data_type = pickable.data_type(+);Regards
    Peter
    Message was edited by:
    Peter Gjelstrup

  • Best practice for sharing data with model window

    Hi team,
    what would the best practice for sharing data with a modal
    window be ? I use a modal window to display record details from a
    record list, but i am not quite sure how to access the data from
    the components in the main application in the modal window.
    Any hints would be welcome
    Best
    Frank

    Pass a reference to the parent into the modal popup. Then you
    can reference anything in the parent scope.
    I haven't done this i 2.0 yet so I can't give you code. I'll
    post if I do.
    Oh, also, you can reference the parent using parentDocument.
    So in the popup you could do:
    parentDocument.myPublicVariable = "whatever";
    Tracy

  • What could be the best way to Export data from 11.5.8 instance to 12.1.2?

    Hi All
    What could be the best way to Export data from 11.5.8 instance to 12.1.2?
    Release: 11.5.8
    OS: Oracle Solaris on SPARC (32-bit) verison 9
    DB: 9.2.0.1
    Thanks in advance

    What kind of data you are looking to move?
    Database export/import is only supported for full database export/import and the application release should be the same on the source/target nodes.
    You can move the setup using iSetup or FNDLOAD.
    Thanks,
    Hussein

Maybe you are looking for