commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chad Johnson" <c...@johnson.name>
Subject Re: DBCP connection problems with credentials
Date Mon, 22 Apr 2002 05:20:18 GMT
Hey,
  For flexibility reasons (ie not requiring a recompile when changing uname
and password) why not just skip the compare step and wrap
getConnection(String uname, String password) directly to getConnection()?
Attached is a patch that makes that change to PoolingDataSource.  Any
thoughts?

-Chad Johnson

----- Original Message -----
From: q.werty@laposte.net
Reply-To: Jakarta Commons Developers List commons-dev@jakarta.apache.org
To: commons-dev@jakarta.apache.org
Sent: Fri, 19 Apr 2002 08:23:39
Subject: DBCP connection problems with credentials


> Hi,
>
> I'am starting with DBCP and Tomcat because of some pooling
> problems with Tyrex and Poolman.
> First of all, It seems like DBCP works very well.
>
> Now, I've got just a little problem with getConnection method
> and credentials : PoolingDataSource object doesn't support
> getConnection(user, password) method and throw
> an "UnsupportedOperationException".
>
> I understand it as a pooled connections can't be shared among
> multiple database users. My problem is that some application
> still use getConnection(user, password) method even with
> DataSource, so using DBCP with those applications is impossible
> without modifing app. code.
>
> So, here is my proposal : Why not modifing getConection(user,
> password) in BasicDataSource so that :
> - if username/password are good ones, this method forward
> toward getConnection()
> - if not, this method throw a SQLExeption, saying something
> like "Invalid username/password"
>
> I've tried to modify source code and I ask you if it would be
> correct to transform getConnection(username, password) in
> BasicDataSource like this :
>
> -----------------------------------------------------------
> public Connection getConnection(String username, String
> password)
>   throws SQLException {
>
>   if(username.equalsIgnoreCase(this.username) &&
> password.equalsIgnoreCase(this.password)) {
>     return (createDataSource().getConnection());
>   } else {
>     throw new SQLException("DBCP : Invalid username/password");
>   }
> }
> -----------------------------------------------------------
>
> Thanks in advance for your responses

Mime
View raw message