Skip to Content
avatar image
Former Member

How to get and use connection from Web AS 7.0 pool?

Hello!

I've set up a datasource and connection pool in my Web AS according http://help.sap.com/saphelp_nw70/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm

And I have some questions about using connection pool:

1) here is my code which get connection form pool:

InitialContext ctx = new InitialContext();
DataSource datasource = (DataSource) ctx.lookup("jdbc/IndexesDataSource");
Connection con = datasource.getConnection();
return con;

Does it properly?

2) Which method I should call when I need to pass connection back to the pool? Will it be enough to call con.close()?

regards, Lev

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 23, 2009 at 07:22 AM

    Hi Lev,

    Write code like this

    try{

    InitialContext ctx=new InitialContext();

    DataSource ds=(DataSource)ctx.lookup("jdbc/indexsDataSource");

    Connection con=ds.getConnection();

    Statement stmt=con.createStatement();

    con.close();

    }

    catch(Exception e)

    {

    wdComponentAPI.getMessageManager().reportException("Exception "+e,true);

    }

    also have a look at below links[Link|http://help.sap.com/saphelp_nw04/helpdata/en/61/fdbc3d16f39e33e10000000a11405a/frameset.htm][Link1|http://help.sap.com/saphelp_nw04/helpdata/en/46/ddc4705e911f43a611840d8decb5f6/frameset.htm][Tutorial|http://help.sap.com/saphelp_nw04/helpdata/en/91/9c2226df76f64fa7783dcaa4534395/frameset.htm]

    Regards,

    Krishna kattu

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 28, 2009 at 10:09 AM

    When I run my WD application, connection pool works fine, but if I run tests, system doesn't use connection pool.

    Add comment
    10|10000 characters needed characters exceeded