If this is a service that more than one user can access I'd recommend
you use commons connection pooling to handle your connections. That way
you just ask for a connection when you need one, and the commons library
handles the creation. Its not going to work very well if multiple
requests are being serviced using a single JDBC connection - and I'm not
even sure if it is threadsafe to do so.
Rajith Attapattu wrote:
If you deploy this service in Application Scope, then there will be
one and only one instance of this service throught out the life time
of the application.
This way you only create your database connection once.
>Is it enough to create this service with application scope?
So the answer is yes.
Rajith Attapattu
Red Hat.
On 10/9/07, *VF* < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
Hi all,
I would like to ask u, how can i utilize database connection in my
web
service. I have one web service with more methods in it. Id like
to create
database connection just once and not with each call (each
operation works
with the same database connection) Is it enough to create this
service with
application scope?
It looks like this:
Available services
stkdds
Service Description : stkdds
Service Status : Active
Available Operations
* getFinishedOrderBin
* getOrderInfo
* updateOrder
* getUserInfo
* cancelOrder
* updateUser
* testOperation
* getOrdersOverview
* getAllAccountsInfo
* getFinishedOrder
* getAccountInfo
* newOrder
And my code for database connection smth like this:
public Connection setConnection() throws Exception {
if(conn != null){
return conn;
}
Class.forName("org.firebirdsql.jdbc.FBDriver");
conn = DriverManager.getConnection (p_connect_string,
sqlProps);
return conn;
Thanks Vladi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
--

Anthony
-------------------------------------
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand
[EMAIL PROTECTED]
Ph +64 4 472 8818
Fax +64 4 472 8811
-------------------------------------
www.bcsoft.co.nz
---------------------------------------------------------------
This email may contain confidential or privileged information,
and is intended for use only by the addressee, or addressees.
If you are not the intended recipient please advise the sender
immediately and do not copy, use or disclose the contents to
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses
received with this email, or to any changes made to the original
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black
Coffee Software Ltd.
---------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]