lidavidm commented on code in PR #1188: URL: https://github.com/apache/arrow-adbc/pull/1188#discussion_r1354890131
########## docs/source/java/quickstart.rst: ########## Review Comment: I don't know if you saw, but the C++ quickstart is actually an executable C++ file with reST formatted comments via a custom directive. We could do the same for Java using that same directive and assuming JShell? ########## docs/source/java/driver_manager.rst: ########## @@ -0,0 +1,59 @@ +.. 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. + +============== +Driver Manager +============== + +The driver manager is a library that provides bindings to the ADBC Java API. It delegates to dynamically-loaded drivers. This allows applications to use multiple drivers simultaneously and decouple themselves from the specific driver. + +The Java driver manager provides both low-level bindings that are essentially the same as the C API and high-level bindings that implement the JDBC standard. + +Installation +============ + +To include the ADBC Driver Manager in your Maven project, add the following dependency: + +.. code-block:: xml + + <dependency> + <groupId>com.adbc</groupId> + <artifactId>adbc-driver-manager</artifactId> + <version>1.0.0</version> + </dependency> + +Usage +===== + +First, load the driver: + +.. code-block:: java + + import org.apache.arrow.adbc.core.AdbcDatabase; + import org.apache.arrow.adbc.core.AdbcDriver; + import org.apache.arrow.adbc.drivermanager.AdbcDriverManager; + +Then, create a connection: + +.. code-block:: java + + Connection conn = DriverManager.getConnection("jdbc:adbc:sqlite:sample.db"); Review Comment: Does this actually work? ########## docs/source/java/quickstart.rst: ########## @@ -0,0 +1,91 @@ +.. 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. + +========== +Quickstart +========== + +Here we'll briefly tour basic features of ADBC with the PostgreSQL driver for Java. + +Installation +============ + +To include ADBC in your Maven project, add the following dependency: + +.. code-block:: xml + + <dependency> + <groupId>org.apache.arrow.adbc</groupId> + <artifactId>adbc-driver-jdbc</artifactId> + <version>0.7.0</version> + </dependency> + +For the examples in this section, the following imports are required: + +.. code-block:: java + + import org.apache.arrow.adbc.core.AdbcConnection; + import org.apache.arrow.adbc.core.AdbcDatabase; + import org.apache.arrow.adbc.core.AdbcDriver; + import org.apache.arrow.adbc.core.AdbcException; + import org.apache.arrow.adbc.core.AdbcStatement; + +JDBC-style API +============== + +ADBC provides a high-level API in the style of the JDBC standard. + +Creating a Connection +--------------------- + +.. code-block:: java + + final Map<String, Object> parameters = new HashMap<>(); + parameters.put(AdbcDriver.PARAM_URL, "jdbc:postgresql://localhost:5432/postgres"); + try ( + BufferAllocator allocator = new RootAllocator(); + AdbcDatabase db = new JdbcDriver(allocator).open(parameters); + AdbcConnection adbcConnection = db.connect(); + + ) { + // run queries, etc. + } catch (AdbcException e) { + // throw + } + +In application code, the connection must be closed after usage or memory may leak. +It is recommended to wrap the connection in a try-resource block for automatic +resource management. In this example, we are connecting to a PostgreSQL database, +specifically the default database "postgres". + +Creating a Statement +-------------------- + +.. code-block:: java + + AdbcStatement stmt = adbcConnection.createStatement(); Review Comment: This should be in a try-with-resources too, and I think QueryResult below as well ########## docs/source/java/index.rst: ########## @@ -15,11 +15,13 @@ .. specific language governing permissions and limitations .. under the License. -==== +====== Java -==== +====== Review Comment: nit: I don't think this needs to be padded ########## docs/source/java/quickstart.rst: ########## @@ -0,0 +1,91 @@ +.. 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. + +========== +Quickstart +========== + +Here we'll briefly tour basic features of ADBC with the PostgreSQL driver for Java. + +Installation +============ + +To include ADBC in your Maven project, add the following dependency: + +.. code-block:: xml + + <dependency> + <groupId>org.apache.arrow.adbc</groupId> + <artifactId>adbc-driver-jdbc</artifactId> + <version>0.7.0</version> + </dependency> + +For the examples in this section, the following imports are required: + +.. code-block:: java + + import org.apache.arrow.adbc.core.AdbcConnection; + import org.apache.arrow.adbc.core.AdbcDatabase; + import org.apache.arrow.adbc.core.AdbcDriver; + import org.apache.arrow.adbc.core.AdbcException; + import org.apache.arrow.adbc.core.AdbcStatement; + +JDBC-style API +============== + +ADBC provides a high-level API in the style of the JDBC standard. + +Creating a Connection +--------------------- + +.. code-block:: java + + final Map<String, Object> parameters = new HashMap<>(); + parameters.put(AdbcDriver.PARAM_URL, "jdbc:postgresql://localhost:5432/postgres"); + try ( + BufferAllocator allocator = new RootAllocator(); + AdbcDatabase db = new JdbcDriver(allocator).open(parameters); + AdbcConnection adbcConnection = db.connect(); + + ) { + // run queries, etc. + } catch (AdbcException e) { + // throw + } + +In application code, the connection must be closed after usage or memory may leak. +It is recommended to wrap the connection in a try-resource block for automatic Review Comment: nit: I think it's usually called 'try-with-resources' ########## docs/source/java/api/adbc_driver_manager.rst: ########## Review Comment: I think this is OK for now but we eventually should generate the Javadocs and link to them instead. ########## docs/source/java/driver_manager.rst: ########## @@ -0,0 +1,59 @@ +.. 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. + +============== +Driver Manager +============== + +The driver manager is a library that provides bindings to the ADBC Java API. It delegates to dynamically-loaded drivers. This allows applications to use multiple drivers simultaneously and decouple themselves from the specific driver. + +The Java driver manager provides both low-level bindings that are essentially the same as the C API and high-level bindings that implement the JDBC standard. + +Installation +============ + +To include the ADBC Driver Manager in your Maven project, add the following dependency: + +.. code-block:: xml + + <dependency> + <groupId>com.adbc</groupId> + <artifactId>adbc-driver-manager</artifactId> + <version>1.0.0</version> Review Comment: Wrong package name and version? ########## docs/source/java/driver_manager.rst: ########## @@ -0,0 +1,59 @@ +.. 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. + +============== +Driver Manager +============== + +The driver manager is a library that provides bindings to the ADBC Java API. It delegates to dynamically-loaded drivers. This allows applications to use multiple drivers simultaneously and decouple themselves from the specific driver. + +The Java driver manager provides both low-level bindings that are essentially the same as the C API and high-level bindings that implement the JDBC standard. Review Comment: This isn't true, as much as I would like it to be. ########## docs/source/java/quickstart.rst: ########## @@ -0,0 +1,91 @@ +.. 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. + +========== +Quickstart +========== + +Here we'll briefly tour basic features of ADBC with the PostgreSQL driver for Java. + +Installation +============ + +To include ADBC in your Maven project, add the following dependency: + +.. code-block:: xml + + <dependency> + <groupId>org.apache.arrow.adbc</groupId> + <artifactId>adbc-driver-jdbc</artifactId> + <version>0.7.0</version> + </dependency> + +For the examples in this section, the following imports are required: + +.. code-block:: java + + import org.apache.arrow.adbc.core.AdbcConnection; + import org.apache.arrow.adbc.core.AdbcDatabase; + import org.apache.arrow.adbc.core.AdbcDriver; + import org.apache.arrow.adbc.core.AdbcException; + import org.apache.arrow.adbc.core.AdbcStatement; + +JDBC-style API +============== + +ADBC provides a high-level API in the style of the JDBC standard. + +Creating a Connection +--------------------- + +.. code-block:: java + + final Map<String, Object> parameters = new HashMap<>(); + parameters.put(AdbcDriver.PARAM_URL, "jdbc:postgresql://localhost:5432/postgres"); + try ( + BufferAllocator allocator = new RootAllocator(); + AdbcDatabase db = new JdbcDriver(allocator).open(parameters); + AdbcConnection adbcConnection = db.connect(); + Review Comment: ```suggestion ``` -- 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]
