cancel
Showing results for 
Search instead for 
Did you mean: 

WebDynpro Oracle Connection in ResultSet with lots of Queries in Java

Former Member
0 Kudos

Hello you,

I've got an advanced question getting many Views in my WebDynpro.

I'm doing a application which uses

<b>round about 90 different</b>

queries.

Those coming from different Tables are specific joins etc...

Which means PreparedStatements in java.sql.* makes no sense.

Does SAP has any solution setting up an connection, and bringing many

different data (Views) in a pool or things like that?

My solution:

public void wdDoInit()

{

//@@begin wdDoInit()

try

{

OracleDataSource ds = new OracleDataSource();

ds.setURL("jdbc:oracle:oci8:USER/DATABASE@PASS");

Connection conn = ds.getConnection();

Statement stmt = conn.createStatement();

ResultSet rset = stmt.executeQuery("select * from table);

ILabel_datasElement data = wdContext.createLabel_datasElement();

while (rset.next());

data.setField(rset.getString(1));

......

wdContext.nodeLabel_datas().addElement(data);

stmt.close();

rset.close();

conn.close();

}

catch(Exception e)

{

e.printStackTrace();

}

//@@end

}

It works. But I dont like it. Performance is bad because of closing the connection and

statements anytime -> Bad Performance

Is there any Alternative to ResultSet or in that way I work?

Any Ideas?

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hai,

You can Use EJBs Instead of going with conventional JDBC. you can Use EJBs as model for Webdynpro Framework.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e9...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c8780... [original link is broken]

Regards,

Naga

Answers (2)

Answers (2)

Former Member
0 Kudos

Wow,

thx a lot for the quick answers.

This did help me a lot!

Great

Former Member
0 Kudos

Bernd,

The cost is associated with creating new connection rather then with closing connection/statement.

Your code in fact create fresh data source, then create one connection every time. The "right way" is to use PooledDataSource (pool of pre-allocated connections when client code "leases" connection and then releases it back to pool . Also it's far better to setup such pooled data source via VisualAdminsitartor and then use obtain reference to it from JNDI by name moniker.

This blog (/people/william.li/blog/2007/03/30/using-jdbc-connection-pool-in-xi-message-mapping) describes how to setup your own Oracle data source and use it from Java code.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net