[ 
https://issues.apache.org/jira/browse/DBCP-209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Remijan updated DBCP-209:
---------------------------------


This make sense, but what about considering this.  In Tomcat a datasource is 
configured with something like this:

<Resource 
  name="jdbc/TestDB"
  auth="Container"
  type="javax.sql.DataSource"
/>

Now "auth" can have the values Container or Application.  According to the 
Tomcat documentation if auth="Container" then Tomcat will take care of handling 
logging in.  In this case the username and password of <ResourceParams /> makes 
sense.  But if auth="Application" then the application is suppose to handle 
login. So I interpret this as using the getConnection(username, password) 
method.  This make any sense?

> Is DataSource.getConnection(user, pass) working the way it is suppose to?
> -------------------------------------------------------------------------
>
>                 Key: DBCP-209
>                 URL: https://issues.apache.org/jira/browse/DBCP-209
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.2.1
>            Reporter: Michael Remijan
>             Fix For: 1.3
>
>
> In Tomcat's server.xml, I create a DataSource resource using the FACTORY 
> org.apache.commons.dbcp.BasicDataSourceFactory and I also provide a  URL and 
> a DRIVERCLASSNAME.  However I do not provide USERNAME or PASSWORD because I 
> want to use DataSource.getConnection(user, pass) in my application.  When I 
> call DataSource.getConnection(user, pass) I get the following exception, 
> java.sql.SQLException: invalid arguments in call, which was unexpected.  I 
> dug into the source code for BasicDataSource and I found what I think is the 
> source of the problem.  First, the method getConnection(user, pass) call the 
> createDataSource() method.  The createDataSource() method creates a 
> Properties object and tries to put the username and password into the 
> properties object.  However, because the server.xml file does contain a 
> username or password, this Properties object (named connectionProperties in 
> the code) is empty.  The createDataSource() the proceeds to call the 
> validateConnectionFactory() method.  This method then tries to get a 
> Connection object!! This attempt fails because the Properties object has no 
> username or password in it hence the Oracle driver complains about being 
> passed invalid arguments.  My question is why is the code working this way?  
> Why does the createDataSource() and validateConnectionFactory() methods 
> assume the username and password have been set in server.xml and then attempt 
> to try to return a Connection object with the username and password passed to 
> the getConnection(user, pass) method?  It would seem to me the 
> createDataSource() and validateConnectionFactory() methods should be aware of 
> the username and password passed to the getConnection(user, pass) if this 
> method is used.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to