comparison tests/JDBC_API_Tester.java @ 852:d9a45743536d monetdbs

Merge 'default' into 'monetdbs'
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Fri, 05 Jan 2024 12:45:48 +0100 (16 months ago)
parents a71afa48f269 d7ffef8faf38
children cd365d70c745
comparison
equal deleted inserted replaced
851:157dcb2d6516 852:d9a45743536d
1 /* 1 /*
2 * SPDX-License-Identifier: MPL-2.0
3 *
2 * This Source Code Form is subject to the terms of the Mozilla Public 4 * 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 5 * 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/. 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 * 7 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V. 8 * Copyright 2024 MonetDB Foundation;
9 * Copyright August 2008 - 2023 MonetDB B.V.;
10 * Copyright 1997 - July 2008 CWI.
7 */ 11 */
8 12
9 import java.sql.*; 13 import java.sql.*;
10 14
11 import java.io.StringReader; 15 import java.io.StringReader;
35 * @author Martin van Dinther 39 * @author Martin van Dinther
36 * @version 0.2 40 * @version 0.2
37 */ 41 */
38 final public class JDBC_API_Tester { 42 final public class JDBC_API_Tester {
39 StringBuilder sb; // buffer to collect the test output 43 StringBuilder sb; // buffer to collect the test output
40 final static int sbInitLen = 3712; 44 final static int sbInitLen = 5224;
41 Connection con; // main connection shared by all tests 45 Connection con; // main connection shared by all tests
42 int dbmsMajorVersion; 46 int dbmsMajorVersion;
43 int dbmsMinorVersion; 47 int dbmsMinorVersion;
44 boolean foundDifferences = false; 48 boolean foundDifferences = false;
45 49
773 "null sys schemas SYSTEM TABLE null null null null null null\n"); 777 "null sys schemas SYSTEM TABLE null null null null null null\n");
774 778
775 compareResultSet(dbmd.getColumns(null, "sys", "table\\_types", null), "getColumns(null, sys, table\\_types, null)", 779 compareResultSet(dbmd.getColumns(null, "sys", "table\\_types", null), "getColumns(null, sys, table\\_types, null)",
776 "Resultset with 24 columns\n" + 780 "Resultset with 24 columns\n" +
777 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE SCOPE_CATALOG SCOPE_SCHEMA SCOPE_TABLE SOURCE_DATA_TYPE IS_AUTOINCREMENT IS_GENERATEDCOLUMN\n" + 781 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE SCOPE_CATALOG SCOPE_SCHEMA SCOPE_TABLE SOURCE_DATA_TYPE IS_AUTOINCREMENT IS_GENERATEDCOLUMN\n" +
778 "char(1) varchar(1024) varchar(1024) varchar(1024) int varchar(1024) int int int int int varchar(65000) varchar(2048) int int int int varchar(3) char(1) char(1) char(1) smallint char(3) varchar(3)\n" + 782 "char(1) varchar(1024) varchar(1024) varchar(1024) int varchar(1024) int int int int int varchar(65000) varchar(2048) int int bigint int varchar(3) char(1) char(1) char(1) smallint char(3) varchar(3)\n" +
779 "null sys table_types table_type_id 5 smallint 16 0 0 2 0 null null 0 0 null 1 NO null null null null NO NO\n" + 783 "null sys table_types table_type_id 5 smallint 16 0 0 2 0 null null 0 0 null 1 NO null null null null NO NO\n" +
780 "null sys table_types table_type_name 12 varchar 25 0 0 0 0 null null 0 0 25 2 NO null null null null NO NO\n"); 784 "null sys table_types table_type_name 12 varchar 25 0 0 0 0 null null 0 0 100 2 NO null null null null NO NO\n");
781 785
782 compareResultSet(dbmd.getPrimaryKeys(null, "sys", "table\\_types"), "getPrimaryKeys(null, sys, table\\_types)", 786 compareResultSet(dbmd.getPrimaryKeys(null, "sys", "table\\_types"), "getPrimaryKeys(null, sys, table\\_types)",
783 "Resultset with 6 columns\n" + 787 "Resultset with 6 columns\n" +
784 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME\n" + 788 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME\n" +
785 "char(1) varchar(1024) varchar(1024) varchar(1024) smallint varchar(1024)\n" + 789 "char(1) varchar(1024) varchar(1024) varchar(1024) smallint varchar(1024)\n" +
1027 "CREATE TABLE jdbctst.nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);"); 1031 "CREATE TABLE jdbctst.nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);");
1028 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_nopk_twoucs", 1032 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_nopk_twoucs",
1029 "CREATE LOCAL TEMP TABLE tmp.tmp_nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);"); 1033 "CREATE LOCAL TEMP TABLE tmp.tmp_nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);");
1030 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_nopk_twoucs", 1034 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_nopk_twoucs",
1031 "CREATE GLOBAL TEMP TABLE tmp.glbl_nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);"); 1035 "CREATE GLOBAL TEMP TABLE tmp.glbl_nopk_twoucs (id2 INT NOT NULL UNIQUE, name2 VARCHAR(99) UNIQUE);");
1036 handleExecuteDDL(stmt, action, objtype, "tmp.tlargechar",
1037 "CREATE TEMP TABLE tlargechar (c1 varchar(2147483647), c2 char(2147483646), c3 clob(2147483645), c4 json(2147483644), c5 url(2147483643)) ON COMMIT PRESERVE ROWS;");
1032 /* next 3 tables copied from example in https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlforeignkeys-function?view=sql-server-ver15 */ 1038 /* next 3 tables copied from example in https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlforeignkeys-function?view=sql-server-ver15 */
1033 handleExecuteDDL(stmt, action, objtype, "\"CUSTOMERS\"", 1039 handleExecuteDDL(stmt, action, objtype, "\"CUSTOMERS\"",
1034 "CREATE TABLE \"CUSTOMERS\" (\"CUSTID\" INT PRIMARY KEY, \"NAME\" VARCHAR(60) NOT NULL, \"ADDRESS\" VARCHAR(90), \"PHONE\" VARCHAR(20));"); 1040 "CREATE TABLE \"CUSTOMERS\" (\"CUSTID\" INT PRIMARY KEY, \"NAME\" VARCHAR(60) NOT NULL, \"ADDRESS\" VARCHAR(90), \"PHONE\" VARCHAR(20));");
1035 handleExecuteDDL(stmt, action, objtype, "\"ORDERS\"", 1041 handleExecuteDDL(stmt, action, objtype, "\"ORDERS\"",
1036 "CREATE TABLE \"ORDERS\" (\"ORDERID\" INT PRIMARY KEY, \"CUSTID\" INT NOT NULL REFERENCES \"CUSTOMERS\" (\"CUSTID\")" + 1042 "CREATE TABLE \"ORDERS\" (\"ORDERID\" INT PRIMARY KEY, \"CUSTID\" INT NOT NULL REFERENCES \"CUSTOMERS\" (\"CUSTID\")" +
1154 "null jdbctst fk2c TABLE null null null null null null\n" + 1160 "null jdbctst fk2c TABLE null null null null null null\n" +
1155 "null jdbctst nopk_twoucs TABLE jdbctst.nopk_twoucs table comment null null null null null\n" + 1161 "null jdbctst nopk_twoucs TABLE jdbctst.nopk_twoucs table comment null null null null null\n" +
1156 "null jdbctst pk2c TABLE null null null null null null\n" + 1162 "null jdbctst pk2c TABLE null null null null null null\n" +
1157 "null jdbctst pk_uc TABLE jdbctst.pk_uc table comment null null null null null\n"); 1163 "null jdbctst pk_uc TABLE jdbctst.pk_uc table comment null null null null null\n");
1158 1164
1165 String tabletypes[] = {"BASE TABLE", "LOCAL TEMPORARY", "GLOBAL TEMPORARY"};
1166 compareResultSet(dbmd.getTables(null, "tmp", "tlargechar", tabletypes), "getTables(null, tmp, tlargechar, tabletypes)",
1167 "Resultset with 10 columns\n" +
1168 "TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS TYPE_CAT TYPE_SCHEM TYPE_NAME SELF_REFERENCING_COL_NAME REF_GENERATION\n" +
1169 "char(1) varchar(1024) varchar(1024) varchar(25) varchar(1048576) char(1) char(1) char(1) char(1) char(1)\n" +
1170 "null tmp tlargechar LOCAL TEMPORARY TABLE null null null null null null\n");
1171
1172 String badtabletypes[] = {null, "", null, ""};
1173 compareResultSet(dbmd.getTables(null, "tmp", "tlargechar", badtabletypes), "getTables(null, tmp, tlargechar, badtabletypes)",
1174 "Resultset with 10 columns\n" +
1175 "TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS TYPE_CAT TYPE_SCHEM TYPE_NAME SELF_REFERENCING_COL_NAME REF_GENERATION\n" +
1176 "char(1) varchar(1024) varchar(1024) varchar(25) varchar(1048576) char(1) char(1) char(1) char(1) char(1)\n");
1177
1159 compareResultSet(dbmd.getTables(null, "jdbctst", "schemas", null), "getTables(null, jdbctst, schemas, null)", 1178 compareResultSet(dbmd.getTables(null, "jdbctst", "schemas", null), "getTables(null, jdbctst, schemas, null)",
1160 "Resultset with 10 columns\n" + 1179 "Resultset with 10 columns\n" +
1161 "TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS TYPE_CAT TYPE_SCHEM TYPE_NAME SELF_REFERENCING_COL_NAME REF_GENERATION\n" + 1180 "TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS TYPE_CAT TYPE_SCHEM TYPE_NAME SELF_REFERENCING_COL_NAME REF_GENERATION\n" +
1162 "char(1) varchar(1024) varchar(1024) varchar(25) varchar(1048576) char(1) char(1) char(1) char(1) char(1)\n"); 1181 "char(1) varchar(1024) varchar(1024) varchar(25) varchar(1048576) char(1) char(1) char(1) char(1) char(1)\n");
1163 1182
1164 compareResultSet(dbmd.getColumns(null, "jdbctst", "pk\\_uc", null), "getColumns(null, jdbctst, pk\\_uc, null)", 1183 compareResultSet(dbmd.getColumns(null, "jdbctst", "pk\\_uc", null), "getColumns(null, jdbctst, pk\\_uc, null)",
1165 "Resultset with 24 columns\n" + 1184 "Resultset with 24 columns\n" +
1166 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE SCOPE_CATALOG SCOPE_SCHEMA SCOPE_TABLE SOURCE_DATA_TYPE IS_AUTOINCREMENT IS_GENERATEDCOLUMN\n" + 1185 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE SCOPE_CATALOG SCOPE_SCHEMA SCOPE_TABLE SOURCE_DATA_TYPE IS_AUTOINCREMENT IS_GENERATEDCOLUMN\n" +
1167 "char(1) varchar(1024) varchar(1024) varchar(1024) int varchar(1024) int int int int int varchar(65000) varchar(2048) int int int int varchar(3) char(1) char(1) char(1) smallint char(3) varchar(3)\n" + 1186 "char(1) varchar(1024) varchar(1024) varchar(1024) int varchar(1024) int int int int int varchar(65000) varchar(2048) int int bigint int varchar(3) char(1) char(1) char(1) smallint char(3) varchar(3)\n" +
1168 "null jdbctst pk_uc id1 4 int 32 0 0 2 0 null null 0 0 null 1 NO null null null null NO NO\n" + 1187 "null jdbctst pk_uc id1 4 int 32 0 0 2 0 null null 0 0 null 1 NO null null null null NO NO\n" +
1169 "null jdbctst pk_uc name1 12 varchar 99 0 0 0 1 null null 0 0 99 2 YES null null null null NO NO\n"); 1188 "null jdbctst pk_uc name1 12 varchar 99 0 0 0 1 null null 0 0 396 2 YES null null null null NO NO\n");
1189
1190 compareResultSet(dbmd.getColumns(null, "tmp", "tlargechar", null), "getColumns(null, tmp, tlargechar, null)",
1191 "Resultset with 24 columns\n" +
1192 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE SCOPE_CATALOG SCOPE_SCHEMA SCOPE_TABLE SOURCE_DATA_TYPE IS_AUTOINCREMENT IS_GENERATEDCOLUMN\n" +
1193 "char(1) varchar(1024) varchar(1024) varchar(1024) int varchar(1024) int int int int int varchar(65000) varchar(2048) int int bigint int varchar(3) char(1) char(1) char(1) smallint char(3) varchar(3)\n" +
1194 "null tmp tlargechar c1 12 varchar 2147483647 0 0 0 1 null null 0 0 8589934588 1 YES null null null null NO NO\n" +
1195 "null tmp tlargechar c2 1 char 2147483646 0 0 0 1 null null 0 0 8589934584 2 YES null null null null NO NO\n" +
1196 "null tmp tlargechar c3 2005 clob 2147483645 0 0 0 1 null null 0 0 8589934580 3 YES null null null null NO NO\n" +
1197 "null tmp tlargechar c4 12 json 2147483644 0 0 0 1 null null 0 0 8589934576 4 YES null null null null NO NO\n" +
1198 "null tmp tlargechar c5 12 url 2147483643 0 0 0 1 null null 0 0 8589934572 5 YES null null null null NO NO\n");
1170 1199
1171 compareResultSet(dbmd.getPrimaryKeys(null, "jdbctst", "pk\\_uc"), "getPrimaryKeys(null, jdbctst, pk\\_uc)", 1200 compareResultSet(dbmd.getPrimaryKeys(null, "jdbctst", "pk\\_uc"), "getPrimaryKeys(null, jdbctst, pk\\_uc)",
1172 "Resultset with 6 columns\n" + 1201 "Resultset with 6 columns\n" +
1173 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME\n" + 1202 "TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME\n" +
1174 "char(1) varchar(1024) varchar(1024) varchar(1024) smallint varchar(1024)\n" + 1203 "char(1) varchar(1024) varchar(1024) varchar(1024) smallint varchar(1024)\n" +
1397 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_pk_uc", "DROP TABLE tmp.tmp_pk_uc;"); 1426 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_pk_uc", "DROP TABLE tmp.tmp_pk_uc;");
1398 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_pk_uc", "DROP TABLE tmp.glbl_pk_uc;"); 1427 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_pk_uc", "DROP TABLE tmp.glbl_pk_uc;");
1399 handleExecuteDDL(stmt, action, objtype, "jdbctst.nopk_twoucs", "DROP TABLE jdbctst.nopk_twoucs;"); 1428 handleExecuteDDL(stmt, action, objtype, "jdbctst.nopk_twoucs", "DROP TABLE jdbctst.nopk_twoucs;");
1400 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_nopk_twoucs", "DROP TABLE tmp.tmp_nopk_twoucs;"); 1429 handleExecuteDDL(stmt, action, objtype, "tmp.tmp_nopk_twoucs", "DROP TABLE tmp.tmp_nopk_twoucs;");
1401 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_nopk_twoucs", "DROP TABLE tmp.glbl_nopk_twoucs;"); 1430 handleExecuteDDL(stmt, action, objtype, "tmp.glbl_nopk_twoucs", "DROP TABLE tmp.glbl_nopk_twoucs;");
1431 handleExecuteDDL(stmt, action, objtype, "tmp.tlargechar", "DROP TABLE tmp.tlargechar;");
1402 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"LINES\"", "DROP TABLE jdbctst.\"LINES\";"); 1432 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"LINES\"", "DROP TABLE jdbctst.\"LINES\";");
1403 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"ORDERS\"", "DROP TABLE jdbctst.\"ORDERS\";"); 1433 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"ORDERS\"", "DROP TABLE jdbctst.\"ORDERS\";");
1404 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"CUSTOMERS\"", "DROP TABLE jdbctst.\"CUSTOMERS\";"); 1434 handleExecuteDDL(stmt, action, objtype, "jdbctst.\"CUSTOMERS\"", "DROP TABLE jdbctst.\"CUSTOMERS\";");
1405 handleExecuteDDL(stmt, action, objtype, "jdbctst.fk2c", "DROP TABLE jdbctst.fk2c;"); 1435 handleExecuteDDL(stmt, action, objtype, "jdbctst.fk2c", "DROP TABLE jdbctst.fk2c;");
1406 handleExecuteDDL(stmt, action, objtype, "jdbctst.pk2c", "DROP TABLE jdbctst.pk2c;"); 1436 handleExecuteDDL(stmt, action, objtype, "jdbctst.pk2c", "DROP TABLE jdbctst.pk2c;");
3026 .append(rs.getString("ts")).append(" | ") 3056 .append(rs.getString("ts")).append(" | ")
3027 // .append(rs.getString("tsz")).append(" | ") -- this values changes when summer or wintertime changes so no stable output 3057 // .append(rs.getString("tsz")).append(" | ") -- this values changes when summer or wintertime changes so no stable output
3028 .append(rs.getString("t")).append(" | ") 3058 .append(rs.getString("t")).append(" | ")
3029 // .append(rs.getString("tz")) -- this values changes when summer or wintertime changes so no stable output 3059 // .append(rs.getString("tz")) -- this values changes when summer or wintertime changes so no stable output
3030 .append("\n"); 3060 .append("\n");
3061 rs.getString("tsz");
3062 rs.getString("tz");
3031 3063
3032 tsz.setTimeZone(TimeZone.getDefault()); 3064 tsz.setTimeZone(TimeZone.getDefault());
3033 tz.setTimeZone(tsz.getTimeZone()); 3065 tz.setTimeZone(tsz.getTimeZone());
3034 sb.append("default (").append(tsz.getTimeZone().getID()).append("):\n") 3066 sb.append("default (").append(tsz.getTimeZone().getID()).append("):\n")
3035 .append(tsz.format(rs.getTimestamp("ts"))).append(" | ") 3067 .append(tsz.format(rs.getTimestamp("ts"))).append(" | ")
3048 sb.append(c.getTimeZone().getID()).append(":\n") 3080 sb.append(c.getTimeZone().getID()).append(":\n")
3049 .append(rs.getTimestamp("ts", c)).append(" | ") 3081 .append(rs.getTimestamp("ts", c)).append(" | ")
3050 .append(rs.getTimestamp("tsz", c)).append(" | ") 3082 .append(rs.getTimestamp("tsz", c)).append(" | ")
3051 .append(rs.getTime("t", c)).append(" | ") 3083 .append(rs.getTime("t", c)).append(" | ")
3052 .append(rs.getTime("tz", c)).append("\n"); 3084 .append(rs.getTime("tz", c)).append("\n");
3085
3086 sb.append("getObject:\n")
3087 .append(rs.getObject("ts")).append(" | ")
3088 // .append(rs.getObject("tsz")).append(" | ") -- this value changes on different time zones, so no stable output
3089 .append(rs.getObject("t")).append(" | ")
3090 // .append(rs.getObject("tz")) -- this value changes on different time zones, so no stable output
3091 .append("\n");
3092 rs.getObject("tsz");
3093 rs.getObject("tz");
3053 3094
3054 SQLWarning w = rs.getWarnings(); 3095 SQLWarning w = rs.getWarnings();
3055 while (w != null) { 3096 while (w != null) {
3056 sb.append(w.getMessage()).append("\n"); 3097 sb.append(w.getMessage()).append("\n");
3057 w = w.getNextWarning(); 3098 w = w.getNextWarning();
3087 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" + 3128 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" +
3088 "America/Los_Angeles:\n" + 3129 "America/Los_Angeles:\n" +
3089 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" + 3130 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" +
3090 "Africa/Windhoek:\n" + 3131 "Africa/Windhoek:\n" +
3091 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" + 3132 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" +
3133 "getObject:\n" +
3134 // old output "1970-01-01 00:00:00.0 | 1970-01-01T01:00+01:00 | 00:00:00 | 01:00+01:00\n" +
3135 "1970-01-01 00:00:00.0 | 00:00:00 | \n" +
3092 "retrieved row (String):\n" + 3136 "retrieved row (String):\n" +
3093 // old output "1970-01-01 00:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 00:00:00 | 01:00:00+01:00\n" + 3137 // old output "1970-01-01 00:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 00:00:00 | 01:00:00+01:00\n" +
3094 "1970-01-01 00:00:00.000000 | 00:00:00 | \n" + 3138 "1970-01-01 00:00:00.000000 | 00:00:00 | \n" +
3095 "default (UTC):\n" + 3139 "default (UTC):\n" +
3096 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" + 3140 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" +
3097 "America/Los_Angeles:\n" + 3141 "America/Los_Angeles:\n" +
3098 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" + 3142 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" +
3099 "Africa/Windhoek:\n" + 3143 "Africa/Windhoek:\n" +
3100 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" + 3144 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" +
3145 "getObject:\n" +
3146 // old output "1970-01-01 00:00:00.0 | 1970-01-01T01:00+01:00 | 00:00:00 | 01:00+01:00\n" +
3147 "1970-01-01 00:00:00.0 | 00:00:00 | \n" +
3101 "retrieved row (String):\n" + 3148 "retrieved row (String):\n" +
3102 // old output "1969-12-31 16:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 16:00:00 | 01:00:00+01:00\n" + 3149 // old output "1969-12-31 16:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 16:00:00 | 01:00:00+01:00\n" +
3103 "1969-12-31 16:00:00.000000 | 16:00:00 | \n" + 3150 "1969-12-31 16:00:00.000000 | 16:00:00 | \n" +
3104 "default (UTC):\n" + 3151 "default (UTC):\n" +
3105 "1969-12-31 16:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 16:00:00.000+0000 | 00:00:00.000+0000\n" + 3152 "1969-12-31 16:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 16:00:00.000+0000 | 00:00:00.000+0000\n" +
3106 "America/Los_Angeles:\n" + 3153 "America/Los_Angeles:\n" +
3107 "1970-01-01 00:00:00.0 | 1970-01-01 00:00:00.0 | 00:00:00 | 00:00:00\n" + 3154 "1970-01-01 00:00:00.0 | 1970-01-01 00:00:00.0 | 00:00:00 | 00:00:00\n" +
3108 "Africa/Windhoek:\n" + 3155 "Africa/Windhoek:\n" +
3109 "1969-12-31 14:00:00.0 | 1970-01-01 00:00:00.0 | 14:00:00 | 00:00:00\n" + 3156 "1969-12-31 14:00:00.0 | 1970-01-01 00:00:00.0 | 14:00:00 | 00:00:00\n" +
3157 "getObject:\n" +
3158 // old output "1969-12-31 16:00:00.0 | 1970-01-01T01:00+01:00 | 16:00:00 | 01:00+01:00\n" +
3159 "1969-12-31 16:00:00.0 | 16:00:00 | \n" +
3110 "retrieved row (String):\n" + 3160 "retrieved row (String):\n" +
3111 // old output "1970-01-01 00:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 00:00:00 | 01:00:00+01:00\n" + 3161 // old output "1970-01-01 00:00:00.000000 | 1970-01-01 01:00:00.000000+01:00 | 00:00:00 | 01:00:00+01:00\n" +
3112 "1970-01-01 00:00:00.000000 | 00:00:00 | \n" + 3162 "1970-01-01 00:00:00.000000 | 00:00:00 | \n" +
3113 "default (UTC):\n" + 3163 "default (UTC):\n" +
3114 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" + 3164 "1970-01-01 00:00:00.000+0000 | 1970-01-01 00:00:00.000+0000 | 00:00:00.000+0000 | 00:00:00.000+0000\n" +
3115 "America/Los_Angeles:\n" + 3165 "America/Los_Angeles:\n" +
3116 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" + 3166 "1970-01-01 08:00:00.0 | 1970-01-01 00:00:00.0 | 08:00:00 | 00:00:00\n" +
3117 "Africa/Windhoek:\n" + 3167 "Africa/Windhoek:\n" +
3118 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" + 3168 "1969-12-31 22:00:00.0 | 1970-01-01 00:00:00.0 | 22:00:00 | 00:00:00\n" +
3169 "getObject:\n" +
3170 // old output "1970-01-01 00:00:00.0 | 1970-01-01T01:00+01:00 | 00:00:00 | 01:00+01:00\n" +
3171 "1970-01-01 00:00:00.0 | 00:00:00 | \n" +
3119 "0. true true\n"); 3172 "0. true true\n");
3120 } 3173 }
3121 3174
3122 private void Test_PStypes() { 3175 private void Test_PStypes() {
3123 sb.setLength(0); // clear the output log buffer 3176 sb.setLength(0); // clear the output log buffer
4259 compareExpectedOutput("Test_Rtimedate", 4312 compareExpectedOutput("Test_Rtimedate",
4260 "0. false false\n" + 4313 "0. false false\n" +
4261 "1. ts 2004-04-24 11:43:53.123000 to ts: 2004-04-24 11:43:53.123\n" + 4314 "1. ts 2004-04-24 11:43:53.123000 to ts: 2004-04-24 11:43:53.123\n" +
4262 "1. ts 2004-04-24 11:43:53.123000 to tm: 11:43:53\n" + 4315 "1. ts 2004-04-24 11:43:53.123000 to tm: 11:43:53\n" +
4263 "1. ts 2004-04-24 11:43:53.123000 to dt: 2004-04-24\n" + 4316 "1. ts 2004-04-24 11:43:53.123000 to dt: 2004-04-24\n" +
4317 "1. ts 2004-04-24 11:43:53.123000 to LocalDateTime: 2004-04-24T11:43:53.123\n" +
4264 "2. t 11:43:53 to ts: 1970-01-01 11:43:53.0\n" + 4318 "2. t 11:43:53 to ts: 1970-01-01 11:43:53.0\n" +
4265 "2. t 11:43:53 to tm: 11:43:53\n" + 4319 "2. t 11:43:53 to tm: 11:43:53\n" +
4266 "2. t 11:43:53 to dt: 1970-01-01\n" + 4320 "2. t 11:43:53 to dt: 1970-01-01\n" +
4321 "2. t 11:43:53 to LocalTime: 11:43:53\n" +
4267 "3. d 2004-04-24 to ts: 2004-04-24 00:00:00.0\n" + 4322 "3. d 2004-04-24 to ts: 2004-04-24 00:00:00.0\n" +
4268 "3. d 2004-04-24 to tm: 00:00:00\n" + 4323 "3. d 2004-04-24 to tm: 00:00:00\n" +
4269 "3. d 2004-04-24 to dt: 2004-04-24\n" + 4324 "3. d 2004-04-24 to dt: 2004-04-24\n" +
4325 "3. d 2004-04-24 to LocalDate: 2004-04-24\n" +
4270 "4. vc 2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321\n" + 4326 "4. vc 2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321\n" +
4271 "4. vc 2004-04-24 11:43:53.654321 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 5 found: '-' in '2004-04-24 11:43:53.654321'\n" + 4327 "4. vc 2004-04-24 11:43:53.654321 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 5 found: '-' in '2004-04-24 11:43:53.654321'\n" +
4272 "4. vc 2004-04-24 11:43:53.654321 to dt: 2004-04-24\n" + 4328 "4. vc 2004-04-24 11:43:53.654321 to dt: 2004-04-24\n" +
4273 "5. vc 11:43:53 to ts: rs.getTimestamp(colnm) failed with error: parsing failed at pos 3 found: ':' in '11:43:53'\n" + 4329 "5. vc 11:43:53 to ts: rs.getTimestamp(colnm) failed with error: parsing failed at pos 3 found: ':' in '11:43:53'\n" +
4274 "5. vc 11:43:53 to tm: 11:43:53\n" + 4330 "5. vc 11:43:53 to tm: 11:43:53\n" +
4277 "6. vc 2004-04-24 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 5 found: '-' in '2004-04-24'\n" + 4333 "6. vc 2004-04-24 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 5 found: '-' in '2004-04-24'\n" +
4278 "6. vc 2004-04-24 to dt: 2004-04-24\n" + 4334 "6. vc 2004-04-24 to dt: 2004-04-24\n" +
4279 "11. ts 904-04-24 11:43:53.567000 to ts: 0904-04-24 11:43:53.567\n" + 4335 "11. ts 904-04-24 11:43:53.567000 to ts: 0904-04-24 11:43:53.567\n" +
4280 "11. ts 904-04-24 11:43:53.567000 to tm: 11:43:53\n" + 4336 "11. ts 904-04-24 11:43:53.567000 to tm: 11:43:53\n" +
4281 "11. ts 904-04-24 11:43:53.567000 to dt: 0904-04-24\n" + 4337 "11. ts 904-04-24 11:43:53.567000 to dt: 0904-04-24\n" +
4338 "11. ts 904-04-24 11:43:53.567000 to LocalDateTime: rs.getObject(colnm, class<T>): Failed to convert to LocalDateTime: Text '904-04-24T11:43:53.567000' could not be parsed at index 0\n" +
4282 "12. ts 74-04-24 11:43:53.567000 to ts: 0074-04-24 11:43:53.567\n" + 4339 "12. ts 74-04-24 11:43:53.567000 to ts: 0074-04-24 11:43:53.567\n" +
4283 "12. ts 74-04-24 11:43:53.567000 to tm: 11:43:53\n" + 4340 "12. ts 74-04-24 11:43:53.567000 to tm: 11:43:53\n" +
4284 "12. ts 74-04-24 11:43:53.567000 to dt: 0074-04-24\n" + 4341 "12. ts 74-04-24 11:43:53.567000 to dt: 0074-04-24\n" +
4342 "12. ts 74-04-24 11:43:53.567000 to LocalDateTime: rs.getObject(colnm, class<T>): Failed to convert to LocalDateTime: Text '74-04-24T11:43:53.567000' could not be parsed at index 0\n" +
4285 "13. ts 4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567\n" + 4343 "13. ts 4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567\n" +
4286 "13. ts 4-04-24 11:43:53.567000 to tm: 11:43:53\n" + 4344 "13. ts 4-04-24 11:43:53.567000 to tm: 11:43:53\n" +
4287 "13. ts 4-04-24 11:43:53.567000 to dt: 0004-04-24\n" + 4345 "13. ts 4-04-24 11:43:53.567000 to dt: 0004-04-24\n" +
4346 "13. ts 4-04-24 11:43:53.567000 to LocalDateTime: rs.getObject(colnm, class<T>): Failed to convert to LocalDateTime: Text '4-04-24T11:43:53.567000' could not be parsed at index 0\n" +
4288 "14. d 904-04-24 to ts: 0904-04-24 00:00:00.0\n" + 4347 "14. d 904-04-24 to ts: 0904-04-24 00:00:00.0\n" +
4289 "14. d 904-04-24 to tm: 00:00:00\n" + 4348 "14. d 904-04-24 to tm: 00:00:00\n" +
4290 "14. d 904-04-24 to dt: 0904-04-24\n" + 4349 "14. d 904-04-24 to dt: 0904-04-24\n" +
4350 "14. d 904-04-24 to LocalDate: rs.getObject(colnm, class<T>): Failed to convert to LocalDate: Text '904-04-24' could not be parsed at index 0\n" +
4291 "15. d 74-04-24 to ts: 0074-04-24 00:00:00.0\n" + 4351 "15. d 74-04-24 to ts: 0074-04-24 00:00:00.0\n" +
4292 "15. d 74-04-24 to tm: 00:00:00\n" + 4352 "15. d 74-04-24 to tm: 00:00:00\n" +
4293 "15. d 74-04-24 to dt: 0074-04-24\n" + 4353 "15. d 74-04-24 to dt: 0074-04-24\n" +
4354 "15. d 74-04-24 to LocalDate: rs.getObject(colnm, class<T>): Failed to convert to LocalDate: Text '74-04-24' could not be parsed at index 0\n" +
4294 "16. d 4-04-24 to ts: 0004-04-24 00:00:00.0\n" + 4355 "16. d 4-04-24 to ts: 0004-04-24 00:00:00.0\n" +
4295 "16. d 4-04-24 to tm: 00:00:00\n" + 4356 "16. d 4-04-24 to tm: 00:00:00\n" +
4296 "16. d 4-04-24 to dt: 0004-04-24\n" + 4357 "16. d 4-04-24 to dt: 0004-04-24\n" +
4358 "16. d 4-04-24 to LocalDate: rs.getObject(colnm, class<T>): Failed to convert to LocalDate: Text '4-04-24' could not be parsed at index 0\n" +
4297 "17. vc 904-04-24 11:43:53.567 to ts: 0904-04-24 11:43:53.567\n" + 4359 "17. vc 904-04-24 11:43:53.567 to ts: 0904-04-24 11:43:53.567\n" +
4298 "17. vc 904-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 4 found: '-' in '904-04-24 11:43:53.567'\n" + 4360 "17. vc 904-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 4 found: '-' in '904-04-24 11:43:53.567'\n" +
4299 "17. vc 904-04-24 11:43:53.567 to dt: 0904-04-24\n" + 4361 "17. vc 904-04-24 11:43:53.567 to dt: 0904-04-24\n" +
4300 "18. vc 74-04-24 11:43:53.567 to ts: 0074-04-24 11:43:53.567\n" + 4362 "18. vc 74-04-24 11:43:53.567 to ts: 0074-04-24 11:43:53.567\n" +
4301 "18. vc 74-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 3 found: '-' in '74-04-24 11:43:53.567'\n" + 4363 "18. vc 74-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 3 found: '-' in '74-04-24 11:43:53.567'\n" +
4304 "19. vc 4-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 2 found: '-' in '4-04-24 11:43:53.567'\n" + 4366 "19. vc 4-04-24 11:43:53.567 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 2 found: '-' in '4-04-24 11:43:53.567'\n" +
4305 "19. vc 4-04-24 11:43:53.567 to dt: 0004-04-24\n" + 4367 "19. vc 4-04-24 11:43:53.567 to dt: 0004-04-24\n" +
4306 "21. ts -4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567\n" + 4368 "21. ts -4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567\n" +
4307 "21. ts -4-04-24 11:43:53.567000 to tm: 11:43:53\n" + 4369 "21. ts -4-04-24 11:43:53.567000 to tm: 11:43:53\n" +
4308 "21. ts -4-04-24 11:43:53.567000 to dt: 0004-04-24\n" + 4370 "21. ts -4-04-24 11:43:53.567000 to dt: 0004-04-24\n" +
4371 "21. ts -4-04-24 11:43:53.567000 to LocalDateTime: rs.getObject(colnm, class<T>): Failed to convert to LocalDateTime: Text '-4-04-24T11:43:53.567000' could not be parsed at index 1\n" +
4309 "22. ts -2004-04-24 11:43:53.567000 to ts: 2004-04-24 11:43:53.567\n" + 4372 "22. ts -2004-04-24 11:43:53.567000 to ts: 2004-04-24 11:43:53.567\n" +
4310 "22. ts -2004-04-24 11:43:53.567000 to tm: 11:43:53\n" + 4373 "22. ts -2004-04-24 11:43:53.567000 to tm: 11:43:53\n" +
4311 "22. ts -2004-04-24 11:43:53.567000 to dt: 2004-04-24\n" + 4374 "22. ts -2004-04-24 11:43:53.567000 to dt: 2004-04-24\n" +
4375 "22. ts -2004-04-24 11:43:53.567000 to LocalDateTime: -2004-04-24T11:43:53.567\n" +
4312 "23. d -4-04-24 to ts: 0004-04-24 00:00:00.0\n" + 4376 "23. d -4-04-24 to ts: 0004-04-24 00:00:00.0\n" +
4313 "23. d -4-04-24 to tm: 00:00:00\n" + 4377 "23. d -4-04-24 to tm: 00:00:00\n" +
4314 "23. d -4-04-24 to dt: 0004-04-24\n" + 4378 "23. d -4-04-24 to dt: 0004-04-24\n" +
4379 "23. d -4-04-24 to LocalDate: rs.getObject(colnm, class<T>): Failed to convert to LocalDate: Text '-4-04-24' could not be parsed at index 1\n" +
4315 "24. d -3004-04-24 to ts: 3004-04-24 00:00:00.0\n" + 4380 "24. d -3004-04-24 to ts: 3004-04-24 00:00:00.0\n" +
4316 "24. d -3004-04-24 to tm: 00:00:00\n" + 4381 "24. d -3004-04-24 to tm: 00:00:00\n" +
4317 "24. d -3004-04-24 to dt: 3004-04-24\n" + 4382 "24. d -3004-04-24 to dt: 3004-04-24\n" +
4383 "24. d -3004-04-24 to LocalDate: -3004-04-24\n" +
4318 "25. vc -2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321\n" + 4384 "25. vc -2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321\n" +
4319 "25. vc -2004-04-24 11:43:53.654321 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 6 found: '-' in '-2004-04-24 11:43:53.654321'\n" + 4385 "25. vc -2004-04-24 11:43:53.654321 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 6 found: '-' in '-2004-04-24 11:43:53.654321'\n" +
4320 "25. vc -2004-04-24 11:43:53.654321 to dt: 2004-04-24\n" + 4386 "25. vc -2004-04-24 11:43:53.654321 to dt: 2004-04-24\n" +
4321 "26. vc -3004-04-24 to ts: 3004-04-24 00:00:00.0\n" + 4387 "26. vc -3004-04-24 to ts: 3004-04-24 00:00:00.0\n" +
4322 "26. vc -3004-04-24 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 6 found: '-' in '-3004-04-24'\n" + 4388 "26. vc -3004-04-24 to tm: rs.getTime(colnm) failed with error: parsing failed at pos 6 found: '-' in '-3004-04-24'\n" +
4354 // getDate() may raise a conversion warning when the value is of type Time or a String which doesn't match format yyyy-mm-dd 4420 // getDate() may raise a conversion warning when the value is of type Time or a String which doesn't match format yyyy-mm-dd
4355 try { 4421 try {
4356 sb.append(data).append("dt: ").append(rs.getDate(colnm)).append("\n"); 4422 sb.append(data).append("dt: ").append(rs.getDate(colnm)).append("\n");
4357 } catch (SQLException e) { 4423 } catch (SQLException e) {
4358 sb.append("rs.getDate(colnm) failed with error: ").append(e.getMessage()).append("\n"); 4424 sb.append("rs.getDate(colnm) failed with error: ").append(e.getMessage()).append("\n");
4425 }
4426 readWarnings(rs.getWarnings());
4427 rs.clearWarnings();
4428
4429 // getObject(colnm, class<T>) may raise a conversion error
4430 try {
4431 switch(colnm) {
4432 case "d":
4433 sb.append(data).append("LocalDate: ").append(rs.getObject(colnm, java.time.LocalDate.class)).append("\n");
4434 break;
4435 case "ts":
4436 sb.append(data).append("LocalDateTime: ").append(rs.getObject(colnm, java.time.LocalDateTime.class)).append("\n");
4437 break;
4438 case "t":
4439 sb.append(data).append("LocalTime: ").append(rs.getObject(colnm, java.time.LocalTime.class)).append("\n");
4440 break;
4441 }
4442 } catch (SQLException e) {
4443 sb.append("rs.getObject(colnm, class<T>): ").append(e.getMessage()).append("\n");
4359 } 4444 }
4360 readWarnings(rs.getWarnings()); 4445 readWarnings(rs.getWarnings());
4361 rs.clearWarnings(); 4446 rs.clearWarnings();
4362 } 4447 }
4363 4448