You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Paul French <pa...@kirona.com> on 2008/10/09 00:10:59 UTC

Embedded Derby + J2ME + JDBC Connection Pooling

Hello All,
 
I create an EmbeddedSimpleDataSource in my code. My application is
multi-threaded. I assume EmbeddedSimpleDataSource is thread safe from the
point of view of obtaining connections.
 
What is the cost of getting a connection each time I need to do some
database work? (Derby is running embedded in my application)
 
If the cost is high then I would like to use a light weight Connection Pool
Manager similar to Apache Commons DBCP, any ideas of a good implementation
that works on J2ME Personal Profile 1.1.2
 
Thanks
Paul

RE: Embedded Derby + J2ME + JDBC Connection Pooling

Posted by Paul French <pa...@kirona.com>.
Thanks,

I'll try without a database connection pool for now. I will probably be in
the order of 10 connections per second at peek.

Cheers
Paul

-----Original Message-----
From: Knut.Hatlen@Sun.COM [mailto:Knut.Hatlen@Sun.COM] 
Sent: 09 October 2008 09:15
To: Derby Discussion
Subject: Re: Embedded Derby + J2ME + JDBC Connection Pooling

Paul French <pa...@kirona.com> writes:

> Hello All,
>  
> I create an EmbeddedSimpleDataSource in my code. My application is 
> multi-threaded. I assume EmbeddedSimpleDataSource is thread safe from 
> the point of view of obtaining connections.
>  
> What is the cost of getting a connection each time I need to do some 
> database work? (Derby is running embedded in my application)
>  
> If the cost is high then I would like to use a light weight Connection 
> Pool Manager similar to Apache Commons DBCP, any ideas of a good 
> implementation that works on J2ME Personal Profile 1.1.2

Creating connections in embedded Derby is a very cheap operation compared to
creating connections to a database server over the network, so you won't see
the same performance improvements with connection pooling as in a
traditional database environment. There is a one-time cost when you set up a
connection (creating the connection object, transaction object, context
stack, etc.) that you will save if you have a pool. Whether or not it's
worth it depends on how frequently your application creates a new
connection. If it does it once every five seconds, I doubt that you'll
notice the difference. If it creates many connections (like tens or
hundreds) per second, you'll be more likely to see an improvement.

--
Knut Anders

__________ NOD32 3505 (20081008) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



Re: Embedded Derby + J2ME + JDBC Connection Pooling

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Paul French <pa...@kirona.com> writes:

> Hello All,
>  
> I create an EmbeddedSimpleDataSource in my code. My application is
> multi-threaded. I assume EmbeddedSimpleDataSource is thread safe from the
> point of view of obtaining connections.
>  
> What is the cost of getting a connection each time I need to do some database
> work? (Derby is running embedded in my application)
>  
> If the cost is high then I would like to use a light weight Connection Pool
> Manager similar to Apache Commons DBCP, any ideas of a good implementation
> that works on J2ME Personal Profile 1.1.2

Creating connections in embedded Derby is a very cheap operation
compared to creating connections to a database server over the network,
so you won't see the same performance improvements with connection
pooling as in a traditional database environment. There is a one-time
cost when you set up a connection (creating the connection object,
transaction object, context stack, etc.) that you will save if you have
a pool. Whether or not it's worth it depends on how frequently your
application creates a new connection. If it does it once every five
seconds, I doubt that you'll notice the difference. If it creates many
connections (like tens or hundreds) per second, you'll be more likely to
see an improvement.

-- 
Knut Anders