Mercurial > hg > monetdb-java
comparison tests/JDBC_API_Tester.java @ 965:8aaa9964359a
Fix missing escaping of single back slashes in string data provided to
PreparedStatement methods setString(), setClob(), setObject() and setURL().
Also corrected and extended test Test_PSsetBytes.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 12 Feb 2025 21:53:06 +0100 (8 weeks ago) |
parents | 1c4a12a89282 |
children | 39b74cc688d2 |
comparison
equal
deleted
inserted
replaced
964:bbd6f2407d2e | 965:8aaa9964359a |
---|---|
1509 "getBestRowIdentifier(null, sys, tables, DatabaseMetaData.bestRowTransaction, true)", | 1509 "getBestRowIdentifier(null, sys, tables, DatabaseMetaData.bestRowTransaction, true)", |
1510 "Resultset with 8 columns\n" + | 1510 "Resultset with 8 columns\n" + |
1511 "SCOPE COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS PSEUDO_COLUMN\n" + | 1511 "SCOPE COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS PSEUDO_COLUMN\n" + |
1512 "smallint varchar(1024) int varchar(1024) int int smallint smallint\n"); | 1512 "smallint varchar(1024) int varchar(1024) int int smallint smallint\n"); |
1513 | 1513 |
1514 compareResultSet(dbmd.getBestRowIdentifier(null, "sys", "table\\_types", DatabaseMetaData.bestRowTransaction, false), | 1514 compareResultSet(dbmd.getBestRowIdentifier(null, "sys", "table_types", DatabaseMetaData.bestRowTransaction, false), |
1515 "getBestRowIdentifier(null, sys, table\\_types, DatabaseMetaData.bestRowTransaction, false)", | 1515 "getBestRowIdentifier(null, sys, table_types, DatabaseMetaData.bestRowTransaction, false)", |
1516 "Resultset with 8 columns\n" + | 1516 "Resultset with 8 columns\n" + |
1517 "SCOPE COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS PSEUDO_COLUMN\n" + | 1517 "SCOPE COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS PSEUDO_COLUMN\n" + |
1518 "smallint varchar(1024) int varchar(1024) int int smallint smallint\n" + | 1518 "smallint varchar(1024) int varchar(1024) int int smallint smallint\n" + |
1519 "2 table_type_id 5 smallint " + (isPostDec2023 ? "15" : "16") + " 0 0 1\n"); | 1519 "2 table_type_id 5 smallint " + (isPostDec2023 ? "15" : "16") + " 0 0 1\n"); |
1520 | 1520 |
2767 sb.append(" pstmt has ") | 2767 sb.append(" pstmt has ") |
2768 .append(pstmt.getMetaData().getColumnCount()) | 2768 .append(pstmt.getMetaData().getColumnCount()) |
2769 .append(" result columns and ") | 2769 .append(" result columns and ") |
2770 .append(pstmt.getParameterMetaData().getParameterCount()) | 2770 .append(pstmt.getParameterMetaData().getParameterCount()) |
2771 .append(" parameters\n"); | 2771 .append(" parameters\n"); |
2772 | |
2772 String val = "0123456789abcdef"; | 2773 String val = "0123456789abcdef"; |
2773 pstmt.setString(1, val); | 2774 pstmt.setString(1, val); |
2774 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); | 2775 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); |
2775 sb.append("3 Insert data row 1\n"); | 2776 sb.append("3 Insert data row 1\n"); |
2776 pstmt.execute(); | 2777 pstmt.execute(); |
2778 | |
2777 val = "~!@#$%^&*()_+`1-=][{}\\|';:,<.>/?"; | 2779 val = "~!@#$%^&*()_+`1-=][{}\\|';:,<.>/?"; |
2778 pstmt.setString(1, val); | 2780 pstmt.setString(1, val); |
2779 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); | 2781 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); |
2780 sb.append("4 Insert data row 2\n"); | 2782 sb.append("4 Insert data row 2\n"); |
2781 pstmt.execute(); | 2783 pstmt.execute(); |
2784 | |
2782 val = "\u00e0\u004f\u20f0\u0020\u00ea\u003a\u0069\u0010\u00a2\u00d8\u0008\u0001\u002b\u0030\u019c\u129e"; | 2785 val = "\u00e0\u004f\u20f0\u0020\u00ea\u003a\u0069\u0010\u00a2\u00d8\u0008\u0001\u002b\u0030\u019c\u129e"; |
2783 pstmt.setString(1, val); | 2786 pstmt.setString(1, val); |
2784 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); | 2787 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); |
2785 sb.append("4 Insert data row 3\n"); | 2788 sb.append("4 Insert data row 3\n"); |
2786 pstmt.execute(); | 2789 pstmt.execute(); |
2790 | |
2791 val = "\\X\\Y\\\\"; | |
2792 pstmt.setString(1, val); | |
2793 pstmt.setBytes(2, val.getBytes(StandardCharsets.UTF_8)); | |
2794 sb.append("4 Insert data row 4\n"); | |
2795 pstmt.execute(); | |
2796 | |
2787 pstmt.close(); | 2797 pstmt.close(); |
2788 | 2798 |
2789 sb.append("5 Prepare Select data\n"); | 2799 sb.append("5 Prepare Select data\n"); |
2790 pstmt = con.prepareStatement("select col1, length(col1) as len_col1, col2, length(col2) as len_col2 from t7346"); | 2800 pstmt = con.prepareStatement("select col1, length(col1) as len_col1, col2, length(col2) as len_col2 from t7346"); |
2791 sb.append(" pstmt has ") | 2801 sb.append(" pstmt has ") |
2848 "2 Prepare Insert data\n" + | 2858 "2 Prepare Insert data\n" + |
2849 " pstmt has 0 result columns and 2 parameters\n" + | 2859 " pstmt has 0 result columns and 2 parameters\n" + |
2850 "3 Insert data row 1\n" + | 2860 "3 Insert data row 1\n" + |
2851 "4 Insert data row 2\n" + | 2861 "4 Insert data row 2\n" + |
2852 "4 Insert data row 3\n" + | 2862 "4 Insert data row 3\n" + |
2863 "4 Insert data row 4\n" + | |
2853 "5 Prepare Select data\n" + | 2864 "5 Prepare Select data\n" + |
2854 " pstmt has 4 result columns and 0 parameters\n" + | 2865 " pstmt has 4 result columns and 0 parameters\n" + |
2855 "6 Execute Select\n" + | 2866 "6 Execute Select\n" + |
2856 " rs has 4 result columns\n" + | 2867 " rs has 4 result columns\n" + |
2857 "7 Show data rows\n" + | 2868 "7 Show data rows\n" + |
2858 "col1 len_col1 col2 len_col2\n" + | 2869 "col1 len_col1 col2 len_col2\n" + |
2859 "0123456789abcdef 16 30313233343536373839616263646566 30313233343536373839616263646566 16\n" + | 2870 "0123456789abcdef 16 30313233343536373839616263646566 30313233343536373839616263646566 16\n" + |
2860 "~!@#$%^&*()_+`1-=][{}|';:,<.>/? 31 7E21402324255E262A28295F2B60312D3D5D5B7B7D5C7C273B3A2C3C2E3E2F3F 7E21402324255E262A28295F2B60312D3D5D5B7B7D5C7C273B3A2C3C2E3E2F3F 32\n" + | 2871 "~!@#$%^&*()_+`1-=][{}\\|';:,<.>/? 32 7E21402324255E262A28295F2B60312D3D5D5B7B7D5C7C273B3A2C3C2E3E2F3F 7E21402324255E262A28295F2B60312D3D5D5B7B7D5C7C273B3A2C3C2E3E2F3F 32\n" + |
2861 "\u00e0\u004f\u20f0\u0020\u00ea\u003a\u0069\u0010\u00a2\u00d8\u0008\u0001\u002b\u0030\u019c\u129e 16 C3A04FE283B020C3AA3A6910C2A2C39808012B30C69CE18A9E C3A04FE283B020C3AA3A6910C2A2C39808012B30C69CE18A9E 25\n" + | 2872 "\u00e0\u004f\u20f0\u0020\u00ea\u003a\u0069\u0010\u00a2\u00d8\u0008\u0001\u002b\u0030\u019c\u129e 16 C3A04FE283B020C3AA3A6910C2A2C39808012B30C69CE18A9E C3A04FE283B020C3AA3A6910C2A2C39808012B30C69CE18A9E 25\n" + |
2873 "\\X\\Y\\\\ 6 5C585C595C5C 5C585C595C5C 6\n" + | |
2862 "8 Drop table\n" + | 2874 "8 Drop table\n" + |
2863 " pstmt has 0 result columns and 0 parameters\n"); | 2875 " pstmt has 0 result columns and 0 parameters\n"); |
2864 } | 2876 } |
2865 | 2877 |
2866 static private final char[] HEXES = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; | 2878 static private final char[] HEXES = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; |