annotate tests/SQLcopyinto.java @ 257:529b92d09fc6

Resolve compilation warnings when compiled with javac -Xlint such as: tests/SQLcopyinto.java:93: warning: [rawtypes] found raw type: List List warning = server.connect(host, port, login, passw); ^ missing type arguments for generic class List<E> where E is a type-variable: E extends Object declared in interface List tests/SQLcopyinto.java:95: warning: [rawtypes] found raw type: Iterator for (Iterator it = warning.iterator(); it.hasNext(); ) { ^ missing type arguments for generic class Iterator<E> where E is a type-variable: E extends Object declared in interface Iterator
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 22 Nov 2018 13:12:53 +0100 (2018-11-22)
parents 2b1f650869d6
children d4baf8a4b43a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
251
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
1 /*
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
2 * This Source Code Form is subject to the terms of the Mozilla Public
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
5 *
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V.
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
7 */
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
8
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
9 import java.sql.*;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
10 import java.io.*;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
11 import java.util.*;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
12 import nl.cwi.monetdb.mcl.net.MapiSocket;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
13
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
14 /**
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
15 * This program demonstrates how the MonetDB JDBC driver can facilitate
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
16 * in performing COPY INTO ... FROM STDIN sequences.
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
17 * It shows how a data stream via MapiSocket to STDIN can be performed.
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
18 *
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
19 * @author Fabian Groffen, Martin van Dinther
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
20 */
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
21
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
22 public class SQLcopyinto {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
23 final private static String tablenm = "exampleSQLCopyInto";
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
24
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
25 public static void main(String[] args) throws Exception {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
26 System.out.println("SQLcopyinto started");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
27 if (args.length == 0) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
28 System.err.println("Error: missing startup argument: the jdbc connection url !");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
29 System.err.println("Usage: java -cp monetdb-jdbc-2.28.jar:. SQLcopyinto \"jdbc:monetdb://localhost:50000/demo?user=monetdb&password=monetdb\"");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
30 System.exit(-1);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
31 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
32 String jdbc_url = args[0];
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
33
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
34 // request a connection to MonetDB server via the driver manager
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
35 Connection conn = DriverManager.getConnection(jdbc_url);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
36 System.out.println("Connected to MonetDB server");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
37
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
38 Statement stmt = null;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
39 ResultSet rs = null;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
40 try {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
41 stmt = conn.createStatement();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
42 stmt.execute("CREATE TABLE IF NOT EXISTS " + tablenm + " (id int, val varchar(24))");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
43
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
44 fillTableUsingCopyIntoSTDIN(conn);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
45
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
46 // check content of the table populated via COPY INTO ... FROM STDIN
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
47 System.out.println("Listing uploaded data:");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
48 rs = stmt.executeQuery("SELECT * FROM " + tablenm);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
49 if (rs != null) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
50 while (rs.next()) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
51 System.out.println("Row data: " + rs.getString(1) + ", " + rs.getString(2));
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
52 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
53 rs.close();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
54 rs = null;
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
55 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
56
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
57 stmt.execute("DROP TABLE " + tablenm);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
58
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
59 System.out.println("SQLcopyinto completed");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
60 } catch (SQLException e) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
61 System.err.println("SQLException: " + e.getMessage());
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
62 } catch (Exception e) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
63 System.err.println("Exception: " + e.getMessage());
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
64 } finally {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
65 // free resources
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
66 if (rs != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
67 rs.close();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
68 if (stmt != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
69 stmt.close();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
70 // close the JDBC connection to MonetDB server
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
71 if (conn != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
72 conn.close();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
73 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
74 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
75
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
76 public static void fillTableUsingCopyIntoSTDIN(Connection mcon) throws Exception {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
77 System.out.println();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
78 System.out.println("CopyInto STDIN begin");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
79
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
80 MapiSocket server = new MapiSocket();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
81 try {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
82 server.setLanguage("sql");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
83 server.setSoTimeout(60);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
84
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
85 // extract from MonetConnection object the used connection properties
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
86 String host = mcon.getClientInfo("host");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
87 int port = Integer.parseInt(mcon.getClientInfo("port"));
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
88 String login = mcon.getClientInfo("user");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
89 String passw = mcon.getClientInfo("password");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
90 // System.out.println("host: " + host + " port: " + port + " login: " + login + " passwd: " + passw);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
91
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
92 System.out.println("Before connecting to MonetDB server via MapiSocket");
257
529b92d09fc6 Resolve compilation warnings when compiled with javac -Xlint
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 251
diff changeset
93 List<String> warning = server.connect(host, port, login, passw);
251
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
94 if (warning != null) {
257
529b92d09fc6 Resolve compilation warnings when compiled with javac -Xlint
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 251
diff changeset
95 for (Iterator<String> it = warning.iterator(); it.hasNext(); ) {
251
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
96 System.out.println("Warning: " + it.next().toString());
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
97 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
98 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
99 System.out.println("Connected to MonetDB server via MapiSocket");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
100
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
101 nl.cwi.monetdb.mcl.io.BufferedMCLReader mclIn = server.getReader();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
102 nl.cwi.monetdb.mcl.io.BufferedMCLWriter mclOut = server.getWriter();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
103
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
104 String error = mclIn.waitForPrompt();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
105 if (error != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
106 System.err.println("Received start error: " + error);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
107
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
108 System.out.println("Before sending data to STDIN");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
109
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
110 // the leading 's' is essential, since it is a protocol marker
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
111 // that should not be omitted, likewise the trailing semicolon
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
112 mclOut.write('s');
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
113 mclOut.write("COPY INTO " + tablenm + " FROM STDIN USING DELIMITERS ',','\\n';");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
114 mclOut.newLine();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
115 // now write the row data values as csv data lines to the STDIN stream
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
116 for (int i = 0; i < 40; i++) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
117 mclOut.write("" + i + ",val_" + i);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
118 mclOut.newLine();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
119 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
120 mclOut.writeLine(""); // need this one for synchronisation over flush()
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
121
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
122 error = mclIn.waitForPrompt();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
123 if (error != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
124 System.err.println("Received error: " + error);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
125
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
126 mclOut.writeLine(""); // need this one for synchronisation over flush()
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
127
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
128 error = mclIn.waitForPrompt();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
129 if (error != null)
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
130 System.err.println("Received finish error: " + error);
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
131
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
132 System.out.println("Completed sending data via STDIN");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
133 } catch (Exception e) {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
134 System.err.println("Mapi Exception: " + e.getMessage());
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
135 } finally {
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
136 // close connection to MonetDB server
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
137 server.close();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
138 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
139
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
140 System.out.println("CopyInto STDIN end");
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
141 System.out.println();
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
142 }
2b1f650869d6 Improved example program SQLcopyinto,java and added to tests directory for automatic testing
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
143 }