cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member186148
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

former_member186148
Active Participant
0 Kudos

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