Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert data usinstateless sessionbean

 
ranga shreya
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
I am trying to insert data in a tabel using a stateless session bean .
What are the steps involved here please let me know.
Thanks.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranga,

In a nutshell is like this:
inside your business method:
  • Get a reference to the DataSource using JNDI (this might be cached).
  • Get a connection from the pool (don�t even thing to cache it).
  • If you choose BMT, start your transaction; otherwise let the container handle it.
  • Update the database.
  • If BMT then commit the transaction; otherwise let the container handle it.
  • Close the connection, ideally inside of the finally block (this will return the connection back to the pool).


  • As you can see, every step in turn needs more explanations. Please let me know if I can be of any more help.
    Regards.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic