File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 55import java .sql .SQLException ;
66import java .time .LocalDateTime ;
77import java .math .BigDecimal ;
8- import org .duckdb .DuckDBTimestamp ;
98
109public class DuckDBAppender implements AutoCloseable {
1110
@@ -51,6 +50,10 @@ public void append(long value) throws SQLException {
5150 DuckDBNative .duckdb_jdbc_appender_append_long (appender_ref , value );
5251 }
5352
53+ public void appendBytes (byte [] value ) throws SQLException {
54+ DuckDBNative .duckdb_jdbc_appender_append_string (appender_ref , value );
55+ }
56+
5457 // New naming schema for object params to keep compatibility with calling "append(null)"
5558 public void appendLocalDateTime (LocalDateTime value ) throws SQLException {
5659 if (value == null ) {
Original file line number Diff line number Diff line change @@ -2635,6 +2635,27 @@ public static void test_appender_null_varchar() throws Exception {
26352635 conn .close ();
26362636 }
26372637
2638+ public static void test_appender_bytes () throws Exception {
2639+ DuckDBConnection conn = DriverManager .getConnection (JDBC_URL ).unwrap (DuckDBConnection .class );
2640+ Statement stmt = conn .createStatement ();
2641+
2642+ stmt .execute ("CREATE TABLE data (a BLOB)" );
2643+ DuckDBAppender appender = conn .createAppender (DuckDBConnection .DEFAULT_SCHEMA , "data" );
2644+
2645+ appender .beginRow ();
2646+ appender .appendBytes ("test" .getBytes (StandardCharsets .UTF_8 ));
2647+ appender .endRow ();
2648+ appender .flush ();
2649+ appender .close ();
2650+
2651+ ResultSet results = stmt .executeQuery ("SELECT * FROM data" );
2652+ assertTrue (results .next ());
2653+ assertEquals (new String (results .getBytes (1 )), "test" );
2654+
2655+ stmt .close ();
2656+ conn .close ();
2657+ }
2658+
26382659 public static void test_get_catalog () throws Exception {
26392660 Connection conn = DriverManager .getConnection (JDBC_URL );
26402661 ResultSet rs = conn .getMetaData ().getCatalogs ();
You can’t perform that action at this time.
0 commit comments