Lehel44 commented on code in PR #6756:
URL: https://github.com/apache/nifi/pull/6756#discussion_r1043837059


##########
nifi-nar-bundles/nifi-dbcp-services-bundle/nifi-postgres-dbcp-service/src/main/java/org/apache/nifi/service/PostgreSQLConnectionPool.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.dbcp.AbstractDBCPConnectionPool;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.nifi.service.JdbcUrlFormat.FULL_URL;
+import static org.apache.nifi.service.JdbcUrlFormat.PARAMETERS;
+import static org.apache.nifi.service.JdbcUrlFormat.POSTGRESQL_BASIC_URI;
+
+/**
+ * Implementation of Database Connection Pooling Service for PostgreSQL with 
built-in JDBC driver.
+ * Apache DBCP is used for connection pooling functionality.
+ */
+@Tags({"postgres", "postgresql", "dbcp", "jdbc", "database", "connection", 
"pooling", "store"})
+@CapabilityDescription("Provides PostgreSQL Connection Pooling Service with 
built-in JDBC driver." +
+        " Connections can be requested from the pool and returned once they 
have been used.")
+@RequiresInstanceClassLoading
+public class PostgreSQLConnectionPool extends AbstractDBCPConnectionPool {
+
+    public static final PropertyDescriptor CONNECTION_URL_FORMAT = new 
PropertyDescriptor.Builder()
+            .name("connection-url-format")
+            .displayName("Connection URL Format")
+            .description("The format of the connection URL.")
+            .allowableValues(JdbcUrlFormat.class)
+            .required(true)
+            .defaultValue(FULL_URL.getValue())
+            .build();
+
+    public static final PropertyDescriptor POSTGRES_DATABASE_URL = new 
PropertyDescriptor.Builder()
+            .fromPropertyDescriptor(DATABASE_URL)
+            .dependsOn(CONNECTION_URL_FORMAT, FULL_URL)
+            .build();
+
+    public static final PropertyDescriptor DATABASE_NAME = new 
PropertyDescriptor.Builder()

Review Comment:
   According to [Postgres 
documentation](https://jdbc.postgresql.org/documentation/use/) there are six 
ways to specify the connection URL:
   
   - jdbc:postgresql:database
   - jdbc:postgresql:/
   - jdbc:postgresql://host/database
   - jdbc:postgresql://host/
   - jdbc:postgresql://host:port/database
   - jdbc:postgresql://host:port/
   
   Since the URL syntax is different based on which parts (db, host, port) 
provided with the current approach - URL Parameters - the user doesn't need to 
bother with the URL syntax. The FULL Url property is useful if it comes from a 
flowfile property as a parameter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to