You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2013/11/15 14:59:46 UTC

Re: [OT] minIdle not being enforced and connections are getting closed instead of returning to the pool

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Srikanth,

On 11/15/13, 2:36 AM, Srikanth wrote:
> I was unwrapping each connection before returning it using the
> below piece of code.
> 
> con =
> ds.getConnection().unwrap(oracle.jdbc.OracleConnection.*class*);
> 
> *return* con;
> 
> As explained by you, this is where the problem was.

That will definitely do it. You end up closing the underlying
connection to the DB and never returning the real object to the pool
(unless you are managing the relationship between pooled-connections
and unwrapped-connections).

> I needed a OracleConnection in some parts of my application as I
> was creating ArrayDescriptor, which failed when I passed the proxy
> Connection.

I have yet to see a use case where downcasting to Oracle's Connection
is truly required. What can't you do with the JDBC API?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJShijSAAoJEBzwKT+lPKRYpmgP/0mQ667wWM8RvdCK+/YOafO4
Xb3o8B2/cfnIRohoAnQPeLnq0O6eP7xlAG+GNi8cB3iS3EilJY9YqwCrIAaFML82
cR095yVUgR69oiL6oZFwR6UrONzf6ow7vu0QkQhm8MqFQKrvso21Q96A8ypdPizg
M7TPVfKYGTeD5Ug3SGMkCIPfLOHE+rDdqggKX7eaIf+2kh4yTufHzjXSRu2xSvwE
8Qf1nByMMXjnD8OJ02Td2tgMR6FG4drICCjJdZPpdM1LRmTmz3NqRd8ZiXJDd7vC
Bng/u/+N3pMoP1XrYguhRI+Riskr1rKHXB2e2ldszqGP1CiyG/1RVeRwAKLoYzZp
gv63e7FPtw6MXpPYL/ToACOecxqTPJmVGhmR9JPTxHOcyigQ1IRt4xgUbzqPK0MO
raI90wIPO5LspR/ToptrS8KzZQwOLDEsT33G4UUzyFiYqqX0ZtLoIqB5KKMITphW
JCUehv3fzIyd4A5vdBGoRtN+GXKgHrIgrC7la2WPScFc5TtxF82hV79ntZwY18Nw
JEp7AFJFnzUctWzsSuAzK46+4moUfN3x0j+hUE2OfjL3NUDg+5cyqdiAc/OuEiZD
d4WFIO8CqLIivH3eNY88phtyF6s3wRMMeinaL4dRz036/xU6EUrAsp1DN+Z4iUKR
wrtS2cBs0ZWjl7f1mBjN
=KEnf
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] minIdle not being enforced and connections are getting closed instead of returning to the pool

Posted by Srikanth <ga...@gmail.com>.
Hi Chris,

We are creating oracle.sql.ARRAY objects in our application using the below
piece of code.

ArrayDescriptor varArrayDesc =
ArrayDescriptor.createDescriptor("ARRAY_XYZ", connection);
ARRAY xyzArray = new ARRAY(ArrayDescriptor paramArrayDescriptor, Connection
paramConnection, Object paramObject);

When we passed the proxy connection returned from the pool, we were getting
class cast exceptions as internally jdbc driver (ojdbc6.jar in my case) is
somewhere trying cast the proxy connection to
"oracle.jdbc.OracleConnection".

That's the reason we were unwrapping the connections.


Thanks
Srikanth


On Fri, Nov 15, 2013 at 7:29 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Srikanth,
>
> On 11/15/13, 2:36 AM, Srikanth wrote:
> > I was unwrapping each connection before returning it using the
> > below piece of code.
> >
> > con =
> > ds.getConnection().unwrap(oracle.jdbc.OracleConnection.*class*);
> >
> > *return* con;
> >
> > As explained by you, this is where the problem was.
>
> That will definitely do it. You end up closing the underlying
> connection to the DB and never returning the real object to the pool
> (unless you are managing the relationship between pooled-connections
> and unwrapped-connections).
>
> > I needed a OracleConnection in some parts of my application as I
> > was creating ArrayDescriptor, which failed when I passed the proxy
> > Connection.
>
> I have yet to see a use case where downcasting to Oracle's Connection
> is truly required. What can't you do with the JDBC API?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.15 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJShijSAAoJEBzwKT+lPKRYpmgP/0mQ667wWM8RvdCK+/YOafO4
> Xb3o8B2/cfnIRohoAnQPeLnq0O6eP7xlAG+GNi8cB3iS3EilJY9YqwCrIAaFML82
> cR095yVUgR69oiL6oZFwR6UrONzf6ow7vu0QkQhm8MqFQKrvso21Q96A8ypdPizg
> M7TPVfKYGTeD5Ug3SGMkCIPfLOHE+rDdqggKX7eaIf+2kh4yTufHzjXSRu2xSvwE
> 8Qf1nByMMXjnD8OJ02Td2tgMR6FG4drICCjJdZPpdM1LRmTmz3NqRd8ZiXJDd7vC
> Bng/u/+N3pMoP1XrYguhRI+Riskr1rKHXB2e2ldszqGP1CiyG/1RVeRwAKLoYzZp
> gv63e7FPtw6MXpPYL/ToACOecxqTPJmVGhmR9JPTxHOcyigQ1IRt4xgUbzqPK0MO
> raI90wIPO5LspR/ToptrS8KzZQwOLDEsT33G4UUzyFiYqqX0ZtLoIqB5KKMITphW
> JCUehv3fzIyd4A5vdBGoRtN+GXKgHrIgrC7la2WPScFc5TtxF82hV79ntZwY18Nw
> JEp7AFJFnzUctWzsSuAzK46+4moUfN3x0j+hUE2OfjL3NUDg+5cyqdiAc/OuEiZD
> d4WFIO8CqLIivH3eNY88phtyF6s3wRMMeinaL4dRz036/xU6EUrAsp1DN+Z4iUKR
> wrtS2cBs0ZWjl7f1mBjN
> =KEnf
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>