From dev-return-12933-apmail-nifi-dev-archive=nifi.apache.org@nifi.apache.org Mon Jan 9 14:18:55 2017 Return-Path: X-Original-To: apmail-nifi-dev-archive@minotaur.apache.org Delivered-To: apmail-nifi-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9B8619D2B for ; Mon, 9 Jan 2017 14:18:55 +0000 (UTC) Received: (qmail 73247 invoked by uid 500); 9 Jan 2017 14:18:55 -0000 Delivered-To: apmail-nifi-dev-archive@nifi.apache.org Received: (qmail 73191 invoked by uid 500); 9 Jan 2017 14:18:55 -0000 Mailing-List: contact dev-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list dev@nifi.apache.org Received: (qmail 73180 invoked by uid 99); 9 Jan 2017 14:18:55 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jan 2017 14:18:55 +0000 Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 2D54D1A0314 for ; Mon, 9 Jan 2017 14:18:55 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id x49so70583136qtc.2 for ; Mon, 09 Jan 2017 06:18:55 -0800 (PST) X-Gm-Message-State: AIkVDXIfrsUYuPd7lDHjrkfkBR3PZHtbOONRhEQ4+b0lvVG7W5e/oTYrU+mlWic1tB2uTbJEgYh8OJvVGYQM+A== X-Received: by 10.200.51.6 with SMTP id t6mr71883762qta.75.1483971534169; Mon, 09 Jan 2017 06:18:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.165.5 with HTTP; Mon, 9 Jan 2017 06:18:53 -0800 (PST) In-Reply-To: <1483953646500-14405.post@n7.nabble.com> References: <1483953646500-14405.post@n7.nabble.com> From: Matt Burgess Date: Mon, 9 Jan 2017 09:18:53 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Spring JdbcTemplate, SimpleJdbcCall and DataSource To: dev@nifi.apache.org Content-Type: text/plain; charset=UTF-8 Toivo, I'm guessing the original DBCPService API only has getConnection() because that was all that was really needed by the processors at the time, and/or to keep more control over the DataSource object (for example, the controller service's shutdown() method closes the DataSource). Having said that, NiFi has extended other APIs to allow more access to the underlying objects, with the caveat that the user must take care of more of the "plumbing"/lifecycle. An example is the ProcessSession.read(flowFile) method [1] which returns an InputStream (rather than requiring an InputStreamCallback to which the InputStream is provided and otherwise managed by the framework). For that reason, and because DataSource is part of javax.sql vs. needing an additional DBCP dependency in the API, I think getDataSource() is a legitimate addition to the DBCPService API if you have other NiFi work that requires it. One thing to note: the nifi-hive-nar supplies subclasses of DBCPService, so any changes to the API would have to be implemented in those subclasses as well (HiveConnectionPool [2], unit tests, etc.) Regards, Matt [1] https://github.com/apache/nifi/blob/master/nifi-api/src/main/java/org/apache/nifi/processor/ProcessSession.java#L570 [2] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java On Mon, Jan 9, 2017 at 4:20 AM, Toivo Adams wrote: > Spring JdbcTemplate, SimpleJdbcCall and DataSource > > Does anybody use Spring JdbcTemplate, SimpleJdbcCall? > Both take DataSource constructor parameeter and not Connection. > And later when SimpleJdbcCall (or JdbcTemplate) need Connection, it will ask > it from DataSource and release afterwards. > > Currently DBCPService returns only Connection. > I want to add method which returns also DataSource. > > Opinions? > > Thanks > Toivo > > > > > -- > View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/Spring-JdbcTemplate-SimpleJdbcCall-and-DataSource-tp14405.html > Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.