How to handle Connection in a SLSB

I am reading EJB in j2ee tutorial 1.4 and in the Bank example I saw that for each private method, first a connection is obtained then work is completed and then the connection is closed.
    private void updateChecking(double amount) throws SQLException {
        makeConnection();
        releaseConnection();
    private void updateSaving(double amount) throws SQLException {
        makeConnection();
        releaseConnection();
    public void transferToSaving(double amount)
        throws InsufficientBalanceException {
        checkingBalance -= amount;
        savingBalance += amount;
        try {
            updateChecking(checkingBalance);
            if (checkingBalance < 0.00) {
                context.setRollbackOnly();
                throw new InsufficientBalanceException();
            updateSaving(savingBalance);
        } catch (SQLException ex) {
            throw new EJBException("Transaction failed due to SQLException: " +
                ex.getMessage());
    }Is this the recommended approach? I find it problemetic that one Logical Unit of Work "the transferToSaving() method" is opening and closing Connection twice.
I am thinking that a better approach would be to get Connection in transferToSaving() method then pass Connection as an argument to both updateChecking() and updateSaving() methods.
    private void updateChecking(Connection conn, double amount) throws SQLException {
    private void updateSaving(Connection conn, double amount) throws SQLException {
    public void transferToSaving(double amount)
        throws InsufficientBalanceException {
        checkingBalance -= amount;
        savingBalance += amount;
        try {
            makeConnection();
            updateChecking(checkingBalance);
            if (checkingBalance < 0.00) {
                context.setRollbackOnly();
                throw new InsufficientBalanceException();
            updateSaving(savingBalance);
        } catch (SQLException ex) {
            throw new EJBException("Transaction failed due to SQLException: " +
                ex.getMessage());
        } finally {
        releaseConnection();
    }Am i right? If yes then how come the guys at Sun are recommending a wrong approach?
Thanks

What is your question really about? You seem to be
going in circles.
Ok. Here is my question refined:
I am reading SLSB EJB in j2ee tutorial 1.4 and in the Bank example I saw that for each business private method, first a connection is obtained then work is completed and then the connection is closed. For example:
public class BankBean implements SessionBean, SessionSynchronization {
    private Connection con;
    public void transferToSaving(double amount) throws InsufficientBalanceException {
        checkingBalance -= amount;
        savingBalance += amount;
        try {
            updateChecking(checkingBalance);
            if (checkingBalance < 0.00) {
                context.setRollbackOnly();
                throw new InsufficientBalanceException();
            updateSaving(savingBalance);
        } catch (SQLException ex) {
            throw new EJBException("Transaction failed due to SQLException: " +
                ex.getMessage());
    private void updateChecking(double amount) throws SQLException {
        makeConnection();
        String updateStatement =
            "update checking set balance =  ? " + "where id = ?";
        PreparedStatement prepStmt = con.prepareStatement(updateStatement);
        prepStmt.setDouble(1, amount);
        prepStmt.setString(2, customerId);
        prepStmt.executeUpdate();
        prepStmt.close();
        releaseConnection();
    private void updateSaving(double amount) throws SQLException {
        makeConnection();
        String updateStatement =
            "update saving set balance =  ? " + "where id = ?";
        PreparedStatement prepStmt = con.prepareStatement(updateStatement);
        prepStmt.setDouble(1, amount);
        prepStmt.setString(2, customerId);
        prepStmt.executeUpdate();
        prepStmt.close();
        releaseConnection();
    private void makeConnection() {
        try {
            InitialContext ic = new InitialContext();
            DataSource ds = (DataSource) ic.lookup(dbName);
            con = ds.getConnection();
        } catch (Exception ex) {
            throw new EJBException("Unable to connect to database. " +
                ex.getMessage());
    private void releaseConnection() {
        try {
            con.close();
        } catch (SQLException ex) {
            throw new EJBException("releaseConnection: " + ex.getMessage());
}Is this the recommended approach? I find it problemetic that one Logical Unit of Work "the transferToSaving() method" is opening and closing Connection twice.
I am thinking that a better approach would be to first get Connection in transferToSaving() method then call both updateChecking() and updateSaving() methods and then close Connection in transferToSaving() method.
So I would make following changes in the above code:
public void transferToSaving(double amount) throws InsufficientBalanceException {
        checkingBalance -= amount;
        savingBalance += amount;
        try {
            makeConnection();
            updateChecking(checkingBalance);
            if (checkingBalance < 0.00) {
                context.setRollbackOnly();
                throw new InsufficientBalanceException();
            updateSaving(savingBalance);
        } catch (SQLException ex) {
            throw new EJBException("Transaction failed due to SQLException: " +
                ex.getMessage());
        } finally {
            releaseConnection();
    private void updateChecking(double amount) throws SQLException {
        String updateStatement =
            "update checking set balance =  ? " + "where id = ?";
        PreparedStatement prepStmt = con.prepareStatement(updateStatement);
        prepStmt.setDouble(1, amount);
        prepStmt.setString(2, customerId);
        prepStmt.executeUpdate();
        prepStmt.close();
    private void updateSaving(double amount) throws SQLException {
        String updateStatement =
            "update saving set balance =  ? " + "where id = ?";
        PreparedStatement prepStmt = con.prepareStatement(updateStatement);
        prepStmt.setDouble(1, amount);
        prepStmt.setString(2, customerId);
        prepStmt.executeUpdate();
        prepStmt.close();
    }Am i right? If yes then how come the guys at Sun are recommending a wrong approach?
Thanks

Similar Messages

  • How to handle connection to db problems using toplink

    Hi,
    We need to handle loss of db connection in our application. We use glassfish and toplink essentials (0.22). I suspect that a java RuntimeException is thrown by toplink. This is the code we use to access the db (mysql). The MyServiceImpl class is where I have my EntityManager to access my persistence entities. Is this the place to catch the RuntimeException? How can I handle it. Is it a reconnect I shall add to the code?
    //mike
    @Stateless
    public class MyServiceImpl implements MyService {
    private Logger log = Logger.getLogger(this.getClass().getName());
    @PersistenceContext(unitName = "myservice")
    private EntityManager manager;
    * For unit test, not exposed as a remote method
    * @param entitymanager
    * to use instead of default JTA manager
    public void changeEntityManager(EntityManager em) {
    log.finest("Changing entitymanager for unit test outside EJB container");
    this.manager = em;
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public User loginUser(String address, String password) throws LoginFailedException {
    log.finest("Login user " + address);
    return new UserDao(manager).loginUser(address, password);
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public String getSystemSetting(Setting setting) throws SettingNotFoundException {
    return new SettingDao(manager).getSystemSetting(setting).getValue();
    }

    I forgot to provide the code we are using to connect.
    @Stateless
    public class MyServiceImpl implements MyService {
    private Logger log = Logger.getLogger(this.getClass().getName());
    @PersistenceContext(unitName = "myservice")
    private EntityManager manager;
    * For unit test, not exposed as a remote method
    * @param entitymanager
    * to use instead of default JTA manager
    public void changeEntityManager(EntityManager em) {
    log.finest("Changing entitymanager for unit test outside EJB container");
    this.manager = em;
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public User loginUser(String address, String password) throws LoginFailedException {
    log.finest("Login user " + address);
    return new UserDao(manager).loginUser(address, password);
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public String getSystemSetting(Setting setting) throws SettingNotFoundException {
    return new SettingDao(manager).getSystemSetting(setting).getValue();
    }

  • How to Handle Connection Informatin in a Multi-User Environment

    Hello,
    I am trying to setup SQL Developer on a Terminal Services box where multiple users will have access to use this tool. However, I have noticed that conenction details are shown globally on a Terminal Services box to anyone who has access to use SQL Developer.
    Is there a way to force these connection details to be stored in a user's Documents and Settings directory?
    Thanks in advance...
    Tom

    After digging through the forum a bit, I have found that I can use the following switch in my shortcut to SQLDeveloper to achive this.
    C:\oracle\sqldeveloper\sqldeveloper.exe -J-Dide.user.dir="%USERPROFILE%\.SQLdeveloper"
    I tried to modify the SQLDeveloper.boot but that did not seem to work correctly. The above mentioned switch updates the "c:\documents and settings\%username%\.sqrdeveloper" with all password related information and SQL history that was important to meet our security requirements. We updated the shortcut in the AllUsers profile and this seems to work globally.
    The only bad thing about this approach is that anyone can go into %AppData%\sqldeveloper.exe and run it without using the shortcuts. This would bypass the security precaution.
    Is there a better way to approach this?
    Regards,
    Tom

  • How to handle multiple connection or user with l2cap

    hi friends,
    I need your help please a.s.a.p
    how to handle multiple connection with l2cap protocol in j2me
    sorry,
    I'm a new programmer in j2me
    thanks all...

    Please stick with the original thread http://forum.java.sun.com/thread.jspa?threadID=5200413&tstart=0
    Cross-posting is very rude, and JSch has nothing to do with JSSE, directly. It is an SSH2 API. It does (AFAIK) use some parts of JSSE, but those parts are definately not your problem.
    You already have answers in the other thread.

  • How to handle SQL connection if password Active directory always change? (Connection using Active directory via network SQL 2012 )

    I have 3 server (Web server, database sql 2012 server and Active directory). I'm using sqlsvr version 3.0,  PHP version 5.3 ,IIS version 7 and windows server 2008.
    Right now my php connection to SQL 2012 using AD id, so How to handle if password on active directory change?

    Solved : Using Kaberos

  • How many concurrent connections can ACS handle at once?

    Hi Experts,
    Could you please let me know how many concurrent connections ACS can handle at once?
    Is there any limitation on it?
    Our ACS version is 4.0 (1) build 27.
    Thanks in advance for your help and have a nice day!
    Regards,
    Gabor

    It depends on many other factors but as far as I know ACS can handle upto 40 Auth request per second*
    *Condition Apply
    Regards,
    ~JG
    Do rate helpful posts

  • How many concurrent connections that an ACS server version 4.2 latest patch can handle?

    I have about 50 routers and layer-3 switches that autheticate via tacacs+.  The AAA server used to be on a Linux machine running open-source tacacs+ built by me.  I have a perl script that will log into all 50 devices at the same time to collect statistics.  This script is multi-threaded.  Everything is working fine so far.
    I recently out-sourced the AAA function to a 3rd party company, not by my choice.  The 3rd party uses Cisco ACS version 4.2 with the latest patch running on Windows 2003 Enterprise Server with 16GB RAM and quad processors with quad-cores, IBM x3650-M2 hardware. The connectivity between the 3rd party and my company is through a DS-3 connection.  Maximum bandwidth over this DS-3 connection is less than 10Mbps at most.
    I noticed that for the past 3 months I have multiple failures with this perl script due to authentication failure with the ACS server.  If I just run the script again a few routers/switches, there are no issues; however, whenever I started the script to log into 50 devices all at the same time, it will fail.  If I made the configuration on all routers/switches to point back to the old open-source tacacs+ server, the issue goes away.  The minute I switched back to the
    new ACS server, the issue came back.  If I modified the script to hit one device at a time, it works fine.  I think it is the ACS server can not handle a lot
    of AAA requests at the same time.
    Does anyone know how many concurrent connections that an ACS 4.2, with latest patches on Windows 2003 Enterprise Server with lot of memory and CPU power, can handle?  I can't seem to find this anywhere on Cisco website.
    Thanks in advance.

    No, Im not saying ACS cannot cope.
    Concurrency and latency are very different things. ACS CSTacacs can handle many 100s of simple authentications/authorisations per second with users in the internal database. If 1000s of devices all send traffic in the same instant it would take some seconds to work through the backlog of traffic.
    Also, worth considering that a limited number of tasks within ACS (or threads) can actually handle a much greater number of "logins" because they are generally multi-message allowing ACS to keep lots of plates spinning.
    If users are in an external databases the latency (per authentication) can increase depending on where the users are (eg Windows AD) and if bad enough can have a serious effect on the overall authentication rate. At which point customers normally turn to load balancing.
    If your device timeouts are 20 seconds (totally reasonable) I suggest the issue is more likely to be something else... a bug, perhaps specific to v4.2?

  • How to handle exception CX_SY_REF_IS_INITIAL

    hi experts,
    im working on a test scenario for abap mapping in SAP XI im getting this error
    An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause Dereferencing of the NULL reference
    i understand that i need to catch this exception in the abap coding but i'm not familiar with oops concepts
    can any one please suggest me how to handle this exception for the following code...
    method IF_MAPPING~EXECUTE.
      break x1149.
    * initialize iXML
      TYPE-POOLS: ixml.
      class cl_ixml definition load.
    ** Instances & Variable declaration =======================
    * instance main factory
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA: l_ixml TYPE REF TO if_ixml,
    * instance input stream factory
       l_streamfactory TYPE REF TO if_ixml_stream_factory,
    * instance input stream
      l_istream  TYPE REF TO if_ixml_istream,
    * instance input document
      l_document TYPE REF TO if_ixml_document,
    * instance parse input document
      l_parser TYPE REF TO if_ixml_parser,
    * instance for elements within the nodes
      node      TYPE REF TO if_ixml_node,
    *instance of nodemap
      nodemap   TYPE REF TO if_ixml_named_node_map,
    * instance for iterator
      iterator  TYPE REF TO if_ixml_node_iterator,
      name      TYPE string,
      value     TYPE string,
    * instance main factory
       o_ixml   TYPE REF TO if_ixml,
    * instance output document
       o_document TYPE REF TO if_ixml_document,
    * instance output stream
      o_istream  TYPE REF TO if_ixml_ostream,
    * instance parse output document
      o_parser  TYPE REF TO if_ixml_parser,
    * instance fot renderer
      renderer type ref to if_ixml_renderer,
      irc type i,
      l_xml_size   TYPE i,
    *ROOT ELEMENT
    l_element_MT_DEMANDTEC_COST TYPE REF TO if_ixml_element,
    *NEXT CHILD ELEMENT FROM THE ABOVE PARENT
    l_element_DT_DEMANDTEC TYPE REF TO if_ixml_element,
    *CHILDREN1 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_WHSE  TYPE REF TO if_ixml_element,
    *CHILDREN2 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_DC    TYPE REF TO if_ixml_element,
    *CHILDREN3 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_PLANT    TYPE REF TO if_ixml_element,
    *CHILDREN4 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_QTY    TYPE REF TO if_ixml_element.
    *saving the xml document
      DATA: l_xml_table       TYPE TABLE OF t_xml_line.
      types: begin of t_source,
              whse(5),
              dc(4) ,
              plant(4),
              qty    type i,
             end of t_source.
      types: tt_source TYPE STANDARD TABLE OF t_source.
      data:  wa_source type t_source.
      data: it_source TYPE  tt_source,
            ivalue type string.
    * Procedures and business logic =======================================
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    * how do i catch the exception for type CX_SY_REF_IS_INITIAL ...?
    endmethod.
    full reward points for answers.
    Thanks & Regards,
    Uday Kumar.
    Edited by: UDAY on May 6, 2008 9:32 PM

    Hi Uday,
    Its occurs because you're trying to access a objects with null reference. Or you forgot to create an instance or an error occurs during the instance creation. So You should put all your "Procedures and business logic" inside a Try/catch block. as follow.
    " Define a class exception object to get error message......
    DATA o_exception TYPE REF TO cx_sy_ref_is_initial.
    "// Use the statment Try block to catch the error.
    TRY.
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    "   The Statement CATCH define a block that catches the exceptions of the
    "   exception class cx_sy_ref_is_initial
        CATCH cx_sy_ref_is_initial INTO o_exception.
    " If you need to get the error message text do as follow
    DATA errorMsg type string.
    " Get the message text
      errorMsg = o_exception->GET_TEXT( ).
    " Display the error information
      MESSAGE errorMsg TYPE 'I'.
      ENDTRY.
    The TRY block defines a guarded area whose class-based exceptions can be caught in the subsequent CATCH blocks. If no exception occurs in the TRY block and it reaches its end, the system continues the processing after ENDTRY. If a class-based exception occurs in the TRY block, the system searches for an exception handler in the same or an external TRY control structure.
    Font: SAP Help
    You can see a how to create and use an exception in this example [ ABAP Objects - Defining a Class-based exceptions|https://wiki.sdn.sap.com/wiki/x/19w] .
    Best Regards.
    Marcelo Ramos

  • I have a new Epson wireless printer connected and the iPad recognizes it but it won't print. What is AirPrint and how do I connect it?

    I have a new Epson wireless printer connected and the iPad recognizes it but it still won't print.  What is AirPrint &amp; how do I connect to it?

    Patti-
    Is your Epson printer on Apple's list of AirPrint capable printers?  See <http://support.apple.com/kb/ht4356>.
    If it is an AirPrint printer, then your WiFi router may not correctly handle Bonjour data required by AirPrint.  Contact the router's manufacturer to see if there is a change to its setup or a firmware update, that will make it work.
    One other possibility is that there could be a print job stuck in the iPad's print queue.  Double click the iPad's Home button and a row of recent Apps will appear along the bottom of the screen.  Scroll across and see if the Print Center is there.
    Fred

  • How can I connect to a UNIX server to execute a command?

    How can I connect to a UNIX server and execute a command using PowerShell? My shell script is sitting on one server, while the UNIX box is on another.
    also, I don't like the idea of hardcoding a username/password within the script file in order to do so.
    -Nothing to see. Move along.

    You will need a library to handle SSH connections.
    I'm using SSH.NET, you can find info on it here : http://www.powershelladmin.com/wiki/SSH_from_PowerShell_using_the_SSH.NET_library
    It has a bit of a learning curve but the web site has some fairly good tutorials.

  • How to handle multiple datasources in a web application?

    I have a J2EE Web application with Servlets and Java ServerPages. Beside this I have a in-house developed API for certain services built using Hibernate and Spring with POJO's and some EJB.
    There are 8 databases which will be used by the web application. I have heard that multiple datasources with Spring is hard to design around. Considering that I have no choice not to use Spring or Hibernate as the API's are using it.
    Anyone have a good design spesification for how to handle multiple datasources. The datasource(database) will be chosen by the user in the web application.

    Let me get this straight. You have a web application that uses spring framework and hibernate to access the database. You want the user to be able to select the database that he wants to access using spring and hibernate.
    Hopefully you are using the Spring Framework Hibernate DAO. I know you can have more that one spring application context. You can then trying to load a seperate spring application context for each database. Each application context would have it's own configuration files with the connection parameters for each datasource. You could still use JNDi entries in the web.xml for each datasource.
    Then you would need a service locater so that when a user selected a datasource he would get the application context for that datasource which he would use for the rest of his session.
    I think it is doable. It means a long load time. And you'll need to keep the application contexts as small as possible to conserve resources.

  • How to handle multiple site to site IPsec vpn on ASA, any best practice to to manage multiple ipsec vpn configrations

    how to handle multiple site to site IPsec vpn on ASA, any best practice to to manage multiple ipsec vpn configurations
    before ver 8.3 and after version 8.3 ...8.4.. 9 versions..

    Hi,
    To my understanding you should be able to attach the same cryptomap to the other "outside" interface or perhaps alternatively create a new crypto map that you attach only to your new "outside" interface.
    Also I think you will probably need to route the remote peer ip of the VPN connection towards the gateway IP address of that new "outside" and also the remote network found behind the VPN connection.
    If you attempt to use VPN Client connection instead of L2L VPN connection with the new "outside" interface then you will run into routing problems as naturally you can have 2 default routes active at the sametime (default route would be required on the new "outside" interface if VPN Client was used since you DONT KNOW where the VPN Clients are connecting to your ASA)
    Hope this helps
    - Jouni

  • Need help on how to handle zip & text/csv as a resposne payload from Concur RestWebservice

    Hi All,
    We are getting zip(if there are multiple files) and test/csv(single file) as a response payload from the concur rest API and need your help on how to handle in NWBPM and SAP PO.
    Zip response coming in response looks like below -
    PKÀ˜F7extract_attendee_detail_p0600908soav_20150424022159.txts� rt©1204Õ50Ñ52©1¨áåPKzà@ÆPKÀ˜F2extract_CES_SAE_v3_p0600908soav_20150424022148.txts� rt©1204Õ50Ñ52©1¨©1ãåPKå늟PKÀ˜Fzà
    Text/csv response looks like below -
    Extract|2015-24-40|20|0
    Need you help on how to handle the zip content response.
    Also need help on how to handle when text/csv response comes and when zip response comes.
    As per the scenario, there are 4 calls to be made and we are using NWBPM and in the last call the actual respons (text/csv or zip) will come.
    Please provide your inputs.
    Thanks
    Narayanareddy B

    Hi Aaron,
    Thanks for your reply.
    I tried with Payload zip bean and the java mapping as mentioned in the response mapping of OM.
    Payload zip bean - Zip  zip.mode  unzip
    I am getting the error below in the receiver rest channel -
    "Transmitting the message using connection JPR failed, due to: com.sap.aii.af.lib.mp.module.ModuleException: Zip: error occured during processing: java.util.zip.ZipException: invalid stored block lengths"
    Java Mapping - used the java mapping in the response of Operation mapping
    Here also i am seeing the same error in the channel log as it is synchronous step and the message got cancelled.
    "Transmitting the message using connection JPR failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error encountered while executing mapping: com.sap.aii.af.service.mapping.MappingException: Mapping failed in runtimeApplication mapping program com/equalize/xpi/esr/mapping/java/UnzipAndAttach throws a stream transformation exception: Exception: invalid stored block lengths"
    The below is the response i am seeing and is it proper zip response payload(any encryption) , kindly advise.
    PKâE�F:ws_extract_attendee_detail_p0600908soav_20150424083413.txts� rt©1204Õ50Ñ52©1¨áåPKzà@ÆPKâE�F5ws_extract_CES_SAE_v3_p0600908soav_20150424084014.txtíTß��@~oÒÿ�÷Fº»ìV}ëòCÏz Qljß8ÜöL�`N�ùão8�Ò«�´M�Ü@�awvçûfgÇùâϤå#Ttï0Ø�B�²·olÇ�£[4Ï](L�]«�ÑbÀôÁÒc�0ÀÏdAªÙТ¨Ìû�Êv¡�b¤eJA%��=Þ7Í>PÚ=í2��7ò[�¼¡=q/°¶�*ø)
    K|<`BgÉÔºÜWs[§J�&Ñ:Ìá:´�ç«�RÐv�ÚÅAD'\�ÁtR²*DP3gî:B@JëhU�Ò'¬�ùQ\�È\D{·O×±JS\ï�-ò�¸�Þ²êó�{Å¡2®â,MmÉù XAzßüBn&®Sl-§�l¶A�×ú½³ÙFI®0¿©Ú¯¤�oT�iV²RÀJ��¼«`õ»�í Ûéwa#�àpY�««óq)U°JaøÁA�ûì>Ù³üHåÒe¾�7��Ð/§£u°Nzã÷ç4×·èãþ�¾}õ0ÙµYÄ�+J��eX\�E±ïsR%®yÜÕðsªáÚ$qÚÎÇ�Û$^%1¸AF*ý¶VÑêxÏZÏ¢U½T~Ñ®ØkW5ç×®õ¿w5¬zò:oN»�ô���íø÷úÛÙ=¬å�[ôÚ�þmczPKhÏ��i PKâE�Fzà@Æ:ws_extract_attendee_detail_p0600908soav_20150424083413.txtPKâE�FhÏ��i 5�ws_extract_CES_SAE_v3_p0600908soav_20150424084014.txtPKËö
    Thanks
    Narayanareddy B

  • How to handle the java.policy file ?

    Can somebody tell me how to handle the java.policy file?
    I always get java.net.SocketExceptions and java.security.AccessControlExceptions while connecting to an appserver from an applet.
    What do I have to write in the java.policy file, where do I have to place it and do I have to call it in some way form my applet?
    Thanks in advance.
    don call

    The java.policy file goes in your jre installation directory in .../jre/lib/security (there should be one there already).
    I used it to allow otherwise restricted permissions for an applet using javax.comm. Add something like the following to the file:
    grant codeBase "URL:http://yourDomainName/rootDirectoryOfYourApp/*" {
         permission java.security.AllPermission;
    This will give the applet downloaded from your site all permissions. You might want to give only certain permissions, I don't know.
    Teri

  • What do you suggest how to handle images?

    Hello,
    I would like to develop a book administration program in web dynpro but I have no clue how to handle the images. There are several points I would like to take care about. The frontend is wd4a and the backend is abap. There will also be an iPhone App that connects via WebServices that also need the data and the images.
    What do you think is the best possibility to save the images?db via blob, file system, ...
    Are there examples how to upload the images via web dynpro and transfer it to the backend?
    Thanks a lot in advance,
      Vanessa

    Hello,
    I'd echo Neil's thoughts - definitely store your images in tables as they are transactional data. Creating a DB table with variable length data isn't difficult - just specify the datatype as rawstring.
    You can then easily read from the db and serve these images in image UI elements, I'm guessing the row repeater UI element is going to be very useful for you.
    Does sound like a good fun project!
    Cheers,
    Chris

Maybe you are looking for