Performing database operations using EJB 3.0

I need to create a session bean that will perform operations on backend database. I am new to EJB 3.0 and need a gentle guidance to the solution
This is what I believe is suppose to be done
1. Create stateless bean interface marking operations.
2. Create bean implementation for above
3. Init stage will require me to connect to the Oracle database. Now am confused how will it get the connection details? Is there a way to extract the url username and password using resource bendle which can be accessed from within bean implementation?
4. Bean method will perform update, read oprations
5. Predestroy will close the connection
6. A client will simply call this ejb with some input parameter(s)
Please let me know if am doing anything wrong here

If you use EJB technology for which it is designed, the container (server) will manage the transaction (and also the connections to the database) for you, so no creation or cleanup of connections on your part. I advise you to read into JPA which is designed to be used in conjunction with EJB tech. The books Enterprise Javabeans 3.0 and Pro EJB 3: the Java Persistence API may help you a lot.

Similar Messages

  • Can we perform Join operation using SQLCall with Datatabae Query

    Hi,
    I am working on Toplink SQLCall query. I am performing join operation but, it is giving error.
    so please, any can tell me . we can perform join operation using SQLCall with Database Query
    Thanking You.

    You can use joining with SQLCall queries in TopLink, provided your SQL returns all of the required fields.
    What is the query you are executing and what error are you getting?

  • How to load data in plain-text file into database by using EJB?

    Hi,
    We need to develop an on-line application which requires us to load input data
    from a selected plain-text file on the Web server (iplanet server) into the backend
    oracle database. How could I use EJB to make it happen? it seems like using Entity
    EJB is not feasible.
    Really appreciate your help!
    Corona

    Hi Corona,
    "Corona Fang" <[email protected]> wrote in message
    news:3f3b0ea3$[email protected]..
    We need to develop an on-line application which requires us to load inputdata
    from a selected plain-text file on the Web server (iplanet server) intothe backend
    oracle database. How could I use EJB to make it happen? it seems likeusing Entity
    EJB is not feasible.If you are talking about loading thousands of records,
    the preferable way is using plain JDBC calls utilizing
    batch methods.
    Regards,
    Slava Imeshev

  • Create tables in different database schemas using EJB 3 Entity Persistent

    Hi All,
    I would like to find out how to get the following tasks done using EJB 3.0 Java Entity Persistent:
    ( i ) Create tables in different schemas such as STUDENT under EDUCATION schema and table PATIENT in HOSPITAL schema. We can then reference them in SQL as EDUCATION.STUDENT and HOSPITAL.PATIENT.
    ( ii ) Reference these tables uniquely once they are created.
    There are no pre-existing tables or naming conventions that needs to be adhere to in this situation.
    I have no problem creating tables on the current schema in EJB 3.0 Java Entity Persistent.
    Any suggestions would be appreciated.
    Thanks,
    Jack

    Use the schema attribute of the Table annotation:
    package javax.persistence;
    @Target({TYPE}) @Retention(RUNTIME)
    public @interface Table
       String name( ) default "";
       String catalog( ) default "";
       String schema( ) default "";
       UniqueConstraint
    uniqueConstraints( ) default {};
    }

  • How to perform merge operation using Data services designer?

    I am new here and new to Data Services Desinger as well.
    And currently, I want to do a merge operation using query transform or table comparison transform. But sadly, neither one of them is giving me what I want.
    So, wonder if you could help clarify if either one of them could achieve MERGE operation between and source and target tables?
    if positive, then how?
    PS:
    by MERGE, i mean, if data exists in target table, then only do update, else, do insert. same with the standard MERGE operation of oracle.
    If you need any more info, let me know!
    Thanks in advance.

    You can do this.
    You don't need the Tabe_Comparison transform actually.
    Just query the data you need and output the flow from your query to your target table.
    Then, you'll have to check the "Auto correct load" option: this will insert new lines and updates old ones. One checked, you can ckeck the "Auto correct load" checkbox.
    By default, BODS will know a line already exists based uppon the primary key columns of your target table. If you want to change the columns used to determine if a line should be inserted or updated, use the "Use input key" checkbox (and define some PK column in your query).
    Hope this helps
    Guillaume

  • Performing database backup using SAPDBA

    Guys could u please let me know how to take whole database backup using SAPDBA to another hard disk attached to the system (i.e rather than taking the backupto /oracle/<SID>/sapbackup on the same system i want to take the backup to another harddisk attached to the same system?)
    should i change any parameter in init<SID>.DBA?

    You dont need to change the init<SID>.dba.
    Rather you need to change init<SID>.sap.
    make a copy of init<SID>.sap and save it as for e.g. init<SID>1.sap change the value of the following entries as follows.
    backup_root_dir=your desired directory
    stage_root_dir=your desired directory
    Now use this init<SID>1.sap as the profile parameter file in sapdba and your backup will be stored in the"your desired directory".

  • How can i execute multiple database operations using multiple objects

    i have data in files which i need to read/parse and insert/update the database. can someone tell me how can i read multiple statements at a time and process using multiple objects.

    This doesn't seem like too much of a JDBC question or at least the answer as I see it isn't unique or specific to JDBC.
    If you want to run multiple processes within your single program then you need to use Java threads. I would recommend you read up on how to properly code Java threads and if you have questions unique to your multi-threaded JDBC implementation come back and ask those questions.
    You may also want tot take advantage of a transaction manager that includes a database connection pool that will handle most of the complexity for you. Depending on the flexibility of your architecture you may not have to do any thread coding at all when using a transaction manager.

  • Exponentail operations using BIGDECIMAL

    hi all
    Can u someone provide me links, notes, codes and suggestions to perform exponential operations using BigDecimal.
    Thankz in advance
    Arun :)

    If you require greater precision than double provides
    and your exponent is integer try
    Google [
    [url=http://www.google.com/search?hl=en&ie=UTF-8&q=squa
    e+and+multiply&btnG=Google+Search]square and
    multiply ]Good point. I forgot the obvious. m^2 = m * m, etc.

  • I need a clarification : Can I use EJBs instead of helper classes for better performance and less network traffic?

    My application was designed based on MVC Architecture. But I made some changes to HMV base on my requirements. Servlet invoke helper classes, helper class uses EJBs to communicate with the database. Jsps also uses EJBs to backtrack the results.
    I have two EJBs(Stateless), one Servlet, nearly 70 helperclasses, and nearly 800 jsps. Servlet acts as Controler and all database transactions done through EJBs only. Helper classes are having business logic. Based on the request relevant helper classed is invoked by the Servlet, and all database transactions are done through EJBs. Session scope is 'Page' only.
    Now I am planning to use EJBs(for business logic) instead on Helper Classes. But before going to do that I need some clarification regarding Network traffic and for better usage of Container resources.
    Please suggest me which method (is Helper classes or Using EJBs) is perferable
    1) to get better performance and.
    2) for less network traffic
    3) for better container resource utilization
    I thought if I use EJBs, then the network traffic will increase. Because every time it make a remote call to EJBs.
    Please give detailed explanation.
    thank you,
    sudheer

    <i>Please suggest me which method (is Helper classes or Using EJBs) is perferable :
    1) to get better performance</i>
    EJB's have quite a lot of overhead associated with them to support transactions and remoteability. A non-EJB helper class will almost always outperform an EJB. Often considerably. If you plan on making your 70 helper classes EJB's you should expect to see a dramatic decrease in maximum throughput.
    <i>2) for less network traffic</i>
    There should be no difference. Both architectures will probably make the exact same JDBC calls from the RDBMS's perspective. And since the EJB's and JSP's are co-located there won't be any other additional overhead there either. (You are co-locating your JSP's and EJB's, aren't you?)
    <i>3) for better container resource utilization</i>
    Again, the EJB version will consume a lot more container resources.

  • Error: the database could not be exclusively locked to perform the operation in sql server 2008 ?

    I am trying to rename the database but i am getting below exception while doing it-->
    Error: the database could not be exclusively locked to perform the operation.(Microsoft Sql Server,Error 5030)
    Thanks.

    as mentioned earlier by both these users just wait for all the connections to go and then try- it will succed
    or else if it is dev\Uat environment & you can kill the conenctions - make the changes (use this as last option)
    i was just wondering if you are connected to the same DB? If yes change your context to master(means connect to master DB ) and then issue this command.
    Sarabpreet Singh Anand
    Blog ,
    Personal website
    This posting is provided , "AS IS" with no warranties, and confers no rights.
    Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

  • Hi, I have a hard disk failure so to recover my data I am using disk utility to restore the data on an external drive while booting from a second external hard drive. When I perform the operation it gives me an input/output error and stops. Any tips?

    Hi, I have a hard disk failure so to recover my data I am using disk utility to restore the data on an external drive while booting from a second external hard drive. When I perform the operation and after having selected both my destination and source drives, the operation begins but soon fails due to input/output error. If I try to create an image of the drive it gives me the same error message. Any help would be much appreciated.

    Disk Utility only creates a image of the drive, so it's no help getting exactly what you want, which is your files. If the file structure is messed up or the drive is failing then it's no help.
    If you have a external boot drive and you can't access the internal non-booting drive though the typical Finder and windows to transfer your files via drag and drop methods, then you need to install Data Rescue on the external boot drive and it will do as best as it can to recover your files. (works on non-encrypted/non-Filevaulted drives only)
    .Create a data recovery/undelete external boot drive
    Are you sure you have hard drive failure, or that OS X isn't merely not booting?
    Because if the drive is working physically, then there is a host of fixes
    ..Step by Step to fix your Mac
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents#/

  • Problem in performing multiple Point-In-Time Database Recovery using RMAN

    Hello Experts,
    I am getting an error while performing database point in time recovery multiple times using RMAN. Details are as follows :-
    Environment:
    Oracle 11g, ASM,
    Database DiskGroups : DG_DATA (Data files), DG_ARCH(Archive logs), DG_REDO(Redo logs Control file).
    Snapshot DiskGroups :
    Snapshot1 (taken at 9 am): SNAP1_DATA, SNAP1_ARCH, +SNAP1_REDO
    Snapshot2 (taken at 10 am): SNAP2_DATA, SNAP2_ARCH, +SNAP2_REDO
    Steps performed for point in time recovery:
    1. Restore control file from snapshot 2.
         RMAN> RESTORE CONTROLFILE from '+SNAP2_REDO/orcl/CONTROLFILE/Current.256.777398261';
    2. For 2nd recovery, reset incarnation of database to snapshot 2 incarnation (Say 2).
    3. Catalog data files from snapshot 1.
    4. Catalog archive logs from snapshot 2.
    5. Perform point in time recovery till given time.
         STARTUP MOUNT;
         RUN {
              SQL "ALTER SESSION SET NLS_DATE_FORMAT = ''dd-mon-yyyy hh24:mi:ss''";
              SET UNTIL TIME "06-mar-2013 09:30:00";
              RESTORE DATABASE;
              RECOVER DATABASE;
              ALTER DATABASE OPEN RESETLOGS;
    Results:
    Recovery 1: At 10.30 am, I performed first point in time recovery till 9:30 am, it was successful. Database incarnation was raised from *2* to *3*.
    Recovery 2: At 11:10 am, I performed another point in time recovery till 9:45 am, while doing it I reset the incarnation of DB to *2*, it failed with following error :-
    Starting recover at 28-FEB-13
    using channel ORA_DISK_1
    starting media recovery
    media recovery failed
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 03/06/2013 11:10:57
    ORA-00283: recovery session canceled due to errors
    RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed
    start until time 'MAR 06 2013 09:45:00'
    ORA-00283: recovery session canceled due to errors
    ORA-00313: open failed for members of log group 1 of thread 1
    ORA-00312: online log 1 thread 1: '+DG_REDO/orcl/onlinelog/group_1.257.807150859'
    ORA-17503: ksfdopn:2 Failed to open file +DG_REDO/orcl/onlinelog/group_1.257.807150859
    ORA-15012: ASM file '+DG_REDO/orcl/onlinelog/group_1.257.807150859' does not exist
    Doubts:
    1. Why did recovery failed 2nd time, but not 1st time and why is RMAN looking for online redo log group_1.257.807150859 in 2nd recovery ?
    3. I tried restoring control file from AutoBackup, in that case both 1st and 2nd recovery succeeded.
    However for this to work, I always need to keep the AutoBackup feature enabled.
    How reliable is control file AutoBackup ? Is there any alternative to using AutoBackup, can I restore control file from snapshot backup only ?
    4. If I restore control file from AutoBackup, then from what point of time/SCN does RMAN restores the control file ?
    Please help me out in this issue.
    Thanks.

    992748 wrote:
    Hello experts,
    I'm little newbie to RMAN recovery. Please help me in these doubts:
    1. If I have datafiles, archive logs & control files backup, but current online REDO logs are lost, then can I perform incomplete database recovery ?yes, if you have backups of everything else
    2. Till what maximum time/scn can incomplete database recovery be performed ??Assuming the only thing lost is the redo logs, you can recover to the last scn in the last archivelog.
    3. What is role of online REDO logs in incomplete database recovery ? They provide the final redo changes - the ones that have not been written to archivelogs
    Are they required for incomplete recovery ?It depends on how much incomplete recovery you need to do.
    Think of all of your changes as a constant stream of redo information. As a redolog fills, it is copied to archive, then (eventually) reused. over time, your redo stream is in archivelog_1, continuing into archvivelog_2, then to 3, and eventually, when you get to the last archivelog, into the online redo. A recovery will start with the oldest necessary point in the redo stream and continue forward. Whether or not you need the online redo for a PIT recovery depends on how far forward you need to recover.
    But you should take every precaution to prevent loss of online redo logs .. starting with having multiple members in each redo group ... and keeping those multiple members on physically separate disks.

  • SQL Server Reporting Services installed on a production database server used to support JD Edwards EnterpriseOne. What performance isses can arise

    SQL Server Reporting Services installed on a production database server used to support JD Edwards EnterpriseOne. What performance isses can arise. Is it recommended. What are the pros and cons

    Hi hazelannc, 
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. Thank you for your understanding and support.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to perform DML Operations on Spatial Table Using ADF

    Hi
    I have an urgent requirement. I have a table with Spatial column. I have generated Business components based on Spatial Table.
    Now I have to perform Create,Read,Update and Delete operations using ADF Business Components on Spatial Table.
    I have written custom create(),read(),update() and delete() methods in my Application Module and i have to implement those methods.
    Can any one help me out how to acheive above four functionalities using ADF Business Components.
    Thanks in Advance

    HI,
    see this example.
    u can do like this.
    DATA: BEGIN OF seats OCCURS 0,
            carrid   TYPE sflight-carrid,
            connid   TYPE sflight-connid,
            seatsocc TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE HASHED TABLE OF seats
                   WITH UNIQUE KEY carrid connid with header line.
    SELECT carrid connid seatsocc
           FROM sflight
           INTO table seats.
    loop at seats.
      COLLECT seats INTO seats_tab.
    endloop.
    LOOP AT seats_tab.
    write:/ seats_tab-carrid,seats_tab-connid,seats_tab-seatsocc.
    ENDLOOP.
    rgds,
    bharat.

  • Error : 'The Connection can not be used to perform thsi operation

    Dear All,
    I am getting an error like 'The Connection can not be used to perform thsi operation, it is either close or Invalid in this context.
    Below is the code what am using:
    Sub Select_Query()
    Dim SQL_String As String
    Dim rs As ADODB.Recordset 'This holds the data
    Dim cn As ADODB.Connection 'Declaring Connection
    Dim cmdobj As ADODB.Command 'Declare command Object
    'Sheets("Payment").Select
    Set cn = New ADODB.Connection
    cn.Open ("Provider=MSDAORA;Data Source=MyDatabase;User ID=Prasad; Password=Prasad12;")
    Dim count_value As Long
    count_value = WorksheetFunction.CountA(Worksheets("Payments").Range("A:A"))
    For i = 4 To count_value
    SQL_String = Worksheets("Payments").Range("AA" & i).Value
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open SQL_String, cn, adOpenForwardOnly, adLockOptimistic, adCmdText
    Dim val As Integer
    val = rs.recordCount
    If val = 0 Then
    Worksheets("Payments").Range("AZ" & i).Value = "No"
    'Else
    'Worksheets("Uploaded").Range("O" & i).Value = "Yes"
    End If
    cn.Close
    Set con = Nothing
    Next
    'cn.Execute SQL_String
    'con.Close
    Set con = Nothing
    End Sub
    And select statment is picking one of the sheets, and SQL query is:
    ="SELECT sa.acct_id
    FROM ci_sa sa, ci_sp sp, ci_sa_sp ss, ci_sp_geo spg,ci_acct_char cac
    WHERE sa.sa_id = ss.sa_id
    AND ss.sp_id = sp.sp_id
    AND sp.sp_id = spg.sp_id
    AND spg.geo_type_cd LIKE '%RR%'
    AND spg.geo_val ='"&B4&"'
    and sa.ACCT_ID=cac.ACCT_ID
    AND cac.char_type_cd LIKE '%SDO%'
    AND TRIM (char_val) IN ('"&Master!G9&"')"
    Please help me in this..
    Regards,
    Prasad

    Please, this is a Oracle forum, not a VBA forum. Mark this thread as answered and post it in a VBA forum.

Maybe you are looking for