on 05-10-2007 12:22 PM
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
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/webcontent/uuid/28113de9-0601-0010-71a3-c8780... [original link is broken]
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow,
thx a lot for the quick answers.
This did help me a lot!
Great
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.