Skip to content

Commit

Permalink
Use PrintWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
rayokota committed Jul 3, 2024
1 parent a457c5c commit ad4ec53
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/io/kcache/kwack/KwackEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.kcache.kwack.translator.avro.AvroTranslator;
import io.kcache.kwack.util.Jackson;
import io.vavr.control.Either;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -207,6 +208,7 @@ public void init() {
public void start() throws IOException {
if (query != null && !query.isEmpty()) {
try {
PrintWriter pw = new PrintWriter(System.out);
try (Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query)) {
ResultSetMetaData md = rs.getMetaData();
Expand All @@ -227,10 +229,10 @@ public void start() throws IOException {
row.put(name, toJson(rs.getObject(i + 1)));
}
String s = MAPPER.writeValueAsString(row);
// TODO use PrintWriter
System.out.println(s);
pw.println(s);
}
}
pw.flush();
} catch (SQLException e) {
throw new IOException(e);
}
Expand Down Expand Up @@ -571,7 +573,7 @@ private void initTable(DuckDBConnection conn, String topic) {
}
ddl += valueDdl;
if (rowInfoSize > 0) {
ddl += ROWINFO + " " + ROWINFO;
ddl += ROWINFO + " " + rowInfoDef.toDdl();
}
ddl += ")";
try {
Expand Down

0 comments on commit ad4ec53

Please sign in to comment.