Bug 40782 - Getting Readonly connection from ds.getConnection
Summary: Getting Readonly connection from ds.getConnection
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: Unknown
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords: APIBug
Depends on:
Blocks:
 
Reported: 2006-10-17 23:19 UTC by Jobin Mathew
Modified: 2006-10-20 15:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jobin Mathew 2006-10-17 23:19:40 UTC
I am developing a web application using tomcat server.
Database is MySQL.  I use connection pool for databse access.

The problem here is I am taking read only connection at some occassions but 
after closing (releasing) it and if i take another connection is is also read 
only.


Connection readOnlyCon =  DB.getConnection();
readOnlyCon .setReadonly(true)
................................
readOnlyCon.close();


Connection Con =  DB.getConnection();
Here this connection some times returns readOnly connection. Otherwise we need 
to explicitly set this as readOnly(false);


Is this is a problem of Java  or Tomcat ?
Comment 1 Shankar Unni 2006-10-18 15:59:56 UTC
(In reply to comment #0)

> Is this is a problem of Java  or Tomcat ?

Neither - I would say it's a DBCP problem. However, Tomcat distributes its own
refactored version of DBCP, so perhaps someone here needs to check this out?

A self-contained test case would be useful..
Comment 2 Chris Halstead 2006-10-20 11:45:59 UTC
This is expected behaviour IMHO. You are changing the connection from the
default state and then returning it to the pool without reverting your
modifictions.  This violates the principle of least surprise.

DBCP does not alter read-only status of a connection when it is returned to the
pool.  If you set a conn to R/O and then return it to the pool (conn.close())
without doing conn.setReadOnly(false) it will retain it's R/O status. The next
consumer of that connection will get it with R/O set.
Comment 3 Mark Thomas 2006-10-20 15:40:14 UTC
Is this was to be fixed, and it is debateable whether it is an issue or not then
it would need to be fixed in DBCP. Regardless, this is not a Tomcat issue.