[ 
https://issues.apache.org/jira/browse/NIFI-3339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15839070#comment-15839070
 ] 

ASF GitHub Bot commented on NIFI-3339:
--------------------------------------

Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1417#discussion_r97923254
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-dbcp-service-api/src/main/java/org/apache/nifi/dbcp/DBCPService.java
 ---
    @@ -31,4 +33,6 @@
     @CapabilityDescription("Provides Database Connection Pooling Service. 
Connections can be asked from pool and returned after usage.")
     public interface DBCPService extends ControllerService {
         public Connection getConnection()  throws ProcessException;
    +
    +    public DataSource getDataSource()  throws ProcessException;
    --- End diff --
    
    I concern a bit about exposing DataSource object, because 
javax.sql.DataSouce has additional getConnection method that takes username and 
password. It enables extension points accessing different user/privilege to the 
data source without NiFi data flow manager's intention.
    
    Since DataSource interface only has methods to create a Connection, is it 
possible to create a DBCPService instance as following example code to work 
with Spring framework? Instead of exposing DataSource instance?
    
    ```java
            // Acquire DBCPService instance somehow.
            final DBCPService dbcpService = null;
    
            // Create DataSource instance extending BasicDataSource which 
returns connection created by service.
            final DataSource dataSource = new BasicDataSource() {
                @Override
                public Connection getConnection() throws SQLException {
                    return dbcpService.getConnection();
                }
    
                @Override
                public Connection getConnection(String user, String pass) 
throws SQLException {
                    throw new SQLException("User and password can not be 
overwritten.");
                }
            };
    
            // Write code using dataSource instance.
    ```


> Add getDataSource() to DBCPService
> ----------------------------------
>
>                 Key: NIFI-3339
>                 URL: https://issues.apache.org/jira/browse/NIFI-3339
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Toivo Adams
>            Assignee: Toivo Adams
>            Priority: Minor
>
> Currently DBCPService returns only Connection. 
> Sometimes DataSource is needed, for example Spring JdbcTemplate, 
> SimpleJdbcCall need DataSource.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to