annotate tests/Test_Rtimedate.java @ 350:54137aeb1f92

Update Copyright year.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 02 Jan 2020 14:42:27 +0100 (2020-01-02)
parents d4baf8a4b43a
children f523727db392
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1 /*
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2 * This Source Code Form is subject to the terms of the Mozilla Public
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
5 *
350
54137aeb1f92 Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
7 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
8
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
9 import java.sql.*;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
10
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
11 public class Test_Rtimedate {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
12 public static void main(String[] args) throws Exception {
27
04fbf3655452 Disable Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); code
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
13 // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
14 Connection con = DriverManager.getConnection(args[0]);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
15 Statement stmt = con.createStatement();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
16 ResultSet rs = null;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
17
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
18 con.setAutoCommit(false);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
19 // >> false: auto commit should be off now
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
20 System.out.println("false\t" + con.getAutoCommit());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
21
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
22 try {
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
23 stmt.executeUpdate("CREATE TABLE table_Test_Rtimedate ( id int PRIMARY KEY, ts timestamp, t time, d date, vc varchar(30) )");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
24
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
25 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (1, timestamp '2004-04-24 11:43:53.123')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
26 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, t) VALUES (2, time '11:43:53.123')");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
27 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (3, date '2004-04-24')");
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
28 // same values but now as strings to test string to timestamp / time / date object conversions
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
29 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (4, '2004-04-24 11:43:53.654321')");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
30 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (5, '11:43:53')");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
31 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (6, '2004-04-24')");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
32
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
33 // test also with small years (< 1000) (see bug 6468)
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
34 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (11, timestamp '904-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
35 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (12, timestamp '74-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
36 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (13, timestamp '4-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
37 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (14, date '904-04-24')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
38 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (15, date '74-04-24')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
39 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (16, date '4-04-24')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
40 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (17, '904-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
41 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (18, '74-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
42 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (19, '4-04-24 11:43:53.567')");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
43
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
44 // test also with negative years (see bug 6468)
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
45 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (21, timestamp '-4-04-24 11:43:53.567')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
46 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, ts) VALUES (22, timestamp '-2004-04-24 11:43:53.567')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
47 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (23, date '-4-04-24')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
48 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, d) VALUES (24, date '-3004-04-24')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
49 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (25, '-2004-04-24 11:43:53.654321')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
50 stmt.executeUpdate("INSERT INTO table_Test_Rtimedate(id, vc) VALUES (26, '-3004-04-24')"); // negative year
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
51
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
52 rs = stmt.executeQuery("SELECT * FROM table_Test_Rtimedate");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
53
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
54 readNextRow(rs, 1, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
55 readNextRow(rs, 2, "t");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
56 readNextRow(rs, 3, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
57
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
58 readNextRow(rs, 4, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
59 readNextRow(rs, 5, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
60 readNextRow(rs, 6, "vc");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
61
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
62 readNextRow(rs, 11, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
63 readNextRow(rs, 12, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
64 readNextRow(rs, 13, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
65 readNextRow(rs, 14, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
66 readNextRow(rs, 15, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
67 readNextRow(rs, 16, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
68 readNextRow(rs, 17, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
69 readNextRow(rs, 18, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
70 readNextRow(rs, 19, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
71
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
72 readNextRow(rs, 21, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
73 readNextRow(rs, 22, "ts");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
74 readNextRow(rs, 23, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
75 readNextRow(rs, 24, "d");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
76 readNextRow(rs, 25, "vc");
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
77 readNextRow(rs, 26, "vc");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
78
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
79 readWarnings(stmt.getWarnings());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
80 readWarnings(con.getWarnings());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
81 } catch (SQLException e) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
82 System.out.println("failed :( "+ e.getMessage());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
83 System.out.println("ABORTING TEST!!!");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
84 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
85
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
86 con.rollback();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
87 con.close();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
88 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
89
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
90 private static void readNextRow(ResultSet rs, int rowseq, String colnm) throws SQLException {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
91 rs.next();
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
92 readWarnings(rs.getWarnings());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
93 rs.clearWarnings();
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
94
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
95 // fetch the column value using multiple methods: getString(), getTimestamp(), getTime() and getDate()
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
96 // to test proper conversion and error reporting
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
97 String data = rs.getString("id") + ". " + colnm + " " + rs.getString(colnm) + " to ";
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
98
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
99 // getTimestamp() may raise a conversion warning when the value is of type Time or a String which doesn't match format yyyy-mm-dd hh:mm:ss
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
100 try {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
101 System.out.println(data + "ts: " + rs.getTimestamp(colnm));
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
102 } catch (SQLException e) {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
103 System.out.println("rs.getTimestamp(colnm) failed with error: " + e.getMessage());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
104 }
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
105 readWarnings(rs.getWarnings());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
106 rs.clearWarnings();
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
107
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
108 // getTime() may raise a conversion warning when the value is of type Date or a String which doesn't match format hh:mm:ss
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
109 try {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
110 System.out.println(data + "tm: " + rs.getTime(colnm));
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
111 } catch (SQLException e) {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
112 System.out.println("rs.getTime(colnm) failed with error: " + e.getMessage());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
113 }
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
114 readWarnings(rs.getWarnings());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
115 rs.clearWarnings();
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
116
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
117 // getDate() may raise a conversion warning when the value is of type Time or a String which doesn't match format yyyy-mm-dd
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
118 try {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
119 System.out.println(data + "dt: " + rs.getDate(colnm));
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
120 } catch (SQLException e) {
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
121 System.out.println("rs.getDate(colnm) failed with error: " + e.getMessage());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
122 }
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
123 readWarnings(rs.getWarnings());
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
124 rs.clearWarnings();
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
125 }
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
126
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
127 private static void readWarnings(SQLWarning w) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
128 while (w != null) {
198
376a15ce49e3 Improve parsing negative years.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
129 System.out.println("Warning: " + w.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
130 w = w.getNextWarning();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
131 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
132 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
133 }