comparison example/OnClientExample.java @ 610:6aa38e8c0f2d

Updated Copyright year.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 05 Jan 2022 14:29:56 +0100 (2022-01-05)
parents 6666a9c62460
children aeb268156580
comparison
equal deleted inserted replaced
609:6666a9c62460 610:6aa38e8c0f2d
1 /* 1 /*
2 * This Source Code Form is subject to the terms of the Mozilla Public 2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 * 5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V. 6 * Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
7 */ 7 */
8 8
9 import org.monetdb.jdbc.MonetConnection; 9 import org.monetdb.jdbc.MonetConnection;
10 10
11 import java.io.BufferedReader; 11 import java.io.BufferedReader;
96 ResultSet rs = stmt.getResultSet(); 96 ResultSet rs = stmt.getResultSet();
97 long count = 0; 97 long count = 0;
98 while (rs.next()) { 98 while (rs.next()) {
99 count++; 99 count++;
100 } 100 }
101 rs.close();
101 System.out.printf(" OK, returned %d rows%n", count); 102 System.out.printf(" OK, returned %d rows%n", count);
102 } else { 103 } else {
103 System.out.printf(" OK, updated %d rows%n", stmt.getUpdateCount()); 104 System.out.printf(" OK, updated %d rows%n", stmt.getUpdateCount());
104 } 105 }
105 } catch (SQLNonTransientException e) { 106 } catch (SQLNonTransientException e) {
106 throw e; 107 throw e;
107 } catch (SQLException e) { 108 } catch (SQLException e) {
108 System.out.println(" => SQL ERROR " + e.getMessage()); 109 System.out.println(" => SQL ERROR " + e.getMessage());
109 status = 1; 110 status = 1;
110 } 111 }
111
112 } 112 }
113 113
114 return status; 114 return status;
115 } 115 }
116 116
227 InputStream stream = Files.newInputStream(path); 227 InputStream stream = Files.newInputStream(path);
228 // This variant of uploadFrom takes a Stream 228 // This variant of uploadFrom takes a Stream
229 handle.uploadFrom(stream); 229 handle.uploadFrom(stream);
230 } 230 }
231 231
232
233 private void justCountLines(MonetConnection.Download handle) throws IOException { 232 private void justCountLines(MonetConnection.Download handle) throws IOException {
234 System.out.println(" HANDLER: not writing the download to file, just counting the lines"); 233 System.out.println(" HANDLER: not writing the download to file, just counting the lines");
235 InputStream stream = handle.getStream(); 234 InputStream stream = handle.getStream();
236 InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); // MonetDB always sends UTF-8 235 InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); // MonetDB always sends UTF-8
237 BufferedReader bufreader = new BufferedReader(reader); 236 BufferedReader bufreader = new BufferedReader(reader);
258 BufferedWriter bufwriter = new BufferedWriter(writer); 257 BufferedWriter bufwriter = new BufferedWriter(writer);
259 handle.downloadTo(bufwriter); 258 handle.downloadTo(bufwriter);
260 bufwriter.close(); // do not forget this 259 bufwriter.close(); // do not forget this
261 } 260 }
262 } 261 }
263
264 } 262 }
265 } 263 }