Add copy examples#2762
Conversation
| } catch (Exception ex) { | ||
| ex.printStackTrace(); |
There was a problem hiding this comment.
I guess this catch is non-essential, and we don't want to promote printStackTrace pattern :)
| } catch (Exception ex) { | |
| ex.printStackTrace(); |
| try { | ||
| cp.cancelCopy(); | ||
| } catch (SQLException se) { // should fail with obsolete operation | ||
| se.printStackTrace(); |
There was a problem hiding this comment.
Do we require calling cancelCopy? Why call it if we expect it to fail?
There was a problem hiding this comment.
I pulled this out of a test case. We really don't need it.
| private int dataRows = origData.length; | ||
| private String sql = "COPY copytest FROM STDIN"; | ||
| try (Connection con = DriverManager.getConnection(url, "postgres", "somepassword")){ | ||
| createTempTable(con, "copytest", "stringvalue text, intvalue int, numvalue numeric(5,2)"); |
There was a problem hiding this comment.
Ideally, the sample should be copy-pasteable, so we should use plain try (Statement st = con.createStatement()) { st.execute("create table ...") }
An alternative option is to provide table DDL above Java code, so the users create or reuse an existing table.
| CopyOut cp = copyAPI.copyOut(sql); | ||
| int count = 0; | ||
| byte[] buf; | ||
| while ((buf = cp.readFromCopy()) != null) { |
There was a problem hiding this comment.
It would be nice to clarify what does byte[] buf mean.
Does it contain single row only? Does it contain just a bunch of next bytes?
* Add copy examples
* fix: fix testGetSQLTypeQueryCache by searching for xid type. We used to search for box type but it is now cached fix OidValueCorrectnessTest BOX_ARRAY OID, by adding BOX_ARRAY to the oidTypeName map * branches: '*' to branches: '**' in the workflow definition to ensure that all pull requests get tested * added alias /about/license.html (#2765) * Add copy examples (#2762) * make changelogs more compact, only show the link to the changelog (#2758) add SNAPSHOT link to download page * Update README.md (#2759) * re-add slonik duke image (#2760) * edit changelogs to make them correct and readable (#2743) * Correct the instructions for building without tests
No description provided.