Skip to content

Commit

Permalink
Merge pull request #3636 from shoffmeister/patch-1
Browse files Browse the repository at this point in the history
Consistent code style for Appender sample
  • Loading branch information
szarnyasg authored Sep 14, 2024
2 parents 4deff1e + 840bd91 commit 55dd4c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/api/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ import java.sql.Statement;
import org.duckdb.DuckDBConnection;

DuckDBConnection conn = (DuckDBConnection) DriverManager.getConnection("jdbc:duckdb:");
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE tbl (x BIGINT, y FLOAT, s VARCHAR)");
try (var stmt = conn.createStatement()) {
stmt.execute("CREATE TABLE tbl (x BIGINT, y FLOAT, s VARCHAR)"
);

// using try-with-resources to automatically close the appender at the end of the scope
try (var appender = conn.createAppender(DuckDBConnection.DEFAULT_SCHEMA, "tbl")) {
Expand All @@ -220,7 +221,6 @@ try (var appender = conn.createAppender(DuckDBConnection.DEFAULT_SCHEMA, "tbl"))
appender.append("world");
appender.endRow();
}
stmt.close();
```

### Batch Writer
Expand Down

0 comments on commit 55dd4c1

Please sign in to comment.